@@ -1186,27 +1186,25 @@ static void LStat(const FunctionCallbackInfo<Value>& args) {
11861186 Environment* env = realm->env ();
11871187
11881188 const int argc = args.Length ();
1189- CHECK_GE (argc, 3 );
1189+ CHECK_GE (argc, 2 );
11901190
11911191 BufferValue path (realm->isolate (), args[0 ]);
11921192 CHECK_NOT_NULL (*path);
11931193
11941194 bool use_bigint = args[1 ]->IsTrue ();
1195- FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
1196- if ( req_wrap_async != nullptr ) { // lstat(path, use_bigint, req)
1195+ if (argc > 2 ) { // lstat(path, use_bigint, req)
1196+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
11971197 FS_ASYNC_TRACE_BEGIN1 (
11981198 UV_FS_LSTAT, req_wrap_async, " path" , TRACE_STR_COPY (*path))
11991199 AsyncCall (env, req_wrap_async, args, " lstat" , UTF8, AfterStat,
12001200 uv_fs_lstat, *path);
12011201 } else { // lstat(path, use_bigint, undefined, ctx)
1202- CHECK_EQ (argc, 4 );
1203- FSReqWrapSync req_wrap_sync;
1202+ FSReqWrapSync req_wrap_sync (" lstat" , *path);
12041203 FS_SYNC_TRACE_BEGIN (lstat);
1205- int err = SyncCall (env, args[3 ], &req_wrap_sync, " lstat" , uv_fs_lstat,
1206- *path);
1204+ int err = SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_lstat, *path);
12071205 FS_SYNC_TRACE_END (lstat);
1208- if (err != 0 ) {
1209- return ; // error info is in ctx
1206+ if (is_uv_error ( err) ) {
1207+ return ;
12101208 }
12111209
12121210 Local<Value> arr = FillGlobalStatsArray (binding_data, use_bigint,
@@ -1227,19 +1225,18 @@ static void FStat(const FunctionCallbackInfo<Value>& args) {
12271225 int fd = args[0 ].As <Int32>()->Value ();
12281226
12291227 bool use_bigint = args[1 ]->IsTrue ();
1230- FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
1231- if ( req_wrap_async != nullptr ) { // fstat(fd, use_bigint, req)
1228+ if (argc > 2 ) { // fstat(fd, use_bigint, req)
1229+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 , use_bigint);
12321230 FS_ASYNC_TRACE_BEGIN0 (UV_FS_FSTAT, req_wrap_async)
12331231 AsyncCall (env, req_wrap_async, args, " fstat" , UTF8, AfterStat,
12341232 uv_fs_fstat, fd);
1235- } else { // fstat(fd, use_bigint, undefined, ctx)
1236- CHECK_EQ (argc, 4 );
1237- FSReqWrapSync req_wrap_sync;
1233+ } else { // fstat(fd, use_bigint)
1234+ FSReqWrapSync req_wrap_sync (" fstat" );
12381235 FS_SYNC_TRACE_BEGIN (fstat);
1239- int err = SyncCall (env, args[ 3 ], &req_wrap_sync, " fstat " , uv_fs_fstat, fd);
1236+ int err = SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_fstat, fd);
12401237 FS_SYNC_TRACE_END (fstat);
1241- if (err != 0 ) {
1242- return ; // error info is in ctx
1238+ if (is_uv_error ( err) ) {
1239+ return ;
12431240 }
12441241
12451242 Local<Value> arr = FillGlobalStatsArray (binding_data, use_bigint,
0 commit comments