Skip to content

Commit

Permalink
fs: use Number::New since all fields are uint64_t
Browse files Browse the repository at this point in the history
PR-URL: #16705
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Khaidi Chu <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
  • Loading branch information
JLHwung authored and MylesBorins committed Nov 28, 2017
1 parent 925e58f commit 644989c
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -436,39 +436,26 @@ Local<Value> BuildStatsObject(Environment* env, const uv_stat_t* s) {
// We need to check the return value of Number::New() and Date::New()
// and make sure that we bail out when V8 returns an empty handle.

// Unsigned integers. It does not actually seem to be specified whether
// uid and gid are unsigned or not, but in practice they are unsigned,
// and Node’s (F)Chown functions do check their arguments for unsignedness.
// Numbers.
#define X(name) \
Local<Value> name = Integer::NewFromUnsigned(env->isolate(), s->st_##name); \
Local<Value> name = Number::New(env->isolate(), \
static_cast<double>(s->st_##name)); \
if (name.IsEmpty()) \
return Local<Object>(); \

X(uid)
X(gid)
# if defined(__POSIX__)
X(blksize)
# else
Local<Value> blksize = Undefined(env->isolate());
# endif
X(ino)
X(size)
X(dev)
X(mode)
X(nlink)
X(rdev)
#undef X

// Numbers.
#define X(name) \
Local<Value> name = Number::New(env->isolate(), \
static_cast<double>(s->st_##name)); \
if (name.IsEmpty()) \
return Local<Object>(); \

X(ino)
X(size)
# if defined(__POSIX__)
X(blksize)
X(blocks)
# else
Local<Value> blksize = Undefined(env->isolate());
Local<Value> blocks = Undefined(env->isolate());
# endif
#undef X
Expand Down

0 comments on commit 644989c

Please sign in to comment.