@@ -2517,18 +2517,16 @@ static void Chmod(const FunctionCallbackInfo<Value>& args) {
25172517 CHECK (args[1 ]->IsInt32 ());
25182518 int mode = args[1 ].As <Int32>()->Value ();
25192519
2520- FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
2521- if ( req_wrap_async != nullptr ) { // chmod(path, mode, req)
2520+ if (argc > 2 ) { // chmod(path, mode, req)
2521+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
25222522 FS_ASYNC_TRACE_BEGIN1 (
25232523 UV_FS_CHMOD, req_wrap_async, " path" , TRACE_STR_COPY (*path))
25242524 AsyncCall (env, req_wrap_async, args, " chmod" , UTF8, AfterNoArgs,
25252525 uv_fs_chmod, *path, mode);
2526- } else { // chmod(path, mode, undefined, ctx)
2527- CHECK_EQ (argc, 4 );
2528- FSReqWrapSync req_wrap_sync;
2526+ } else { // chmod(path, mode)
2527+ FSReqWrapSync req_wrap_sync (" chmod" , *path);
25292528 FS_SYNC_TRACE_BEGIN (chmod);
2530- SyncCall (env, args[3 ], &req_wrap_sync, " chmod" ,
2531- uv_fs_chmod, *path, mode);
2529+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_chmod, *path, mode);
25322530 FS_SYNC_TRACE_END (chmod);
25332531 }
25342532}
@@ -2549,17 +2547,15 @@ static void FChmod(const FunctionCallbackInfo<Value>& args) {
25492547 CHECK (args[1 ]->IsInt32 ());
25502548 const int mode = args[1 ].As <Int32>()->Value ();
25512549
2552- FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
2553- if ( req_wrap_async != nullptr ) { // fchmod(fd, mode, req)
2550+ if (argc > 2 ) { // fchmod(fd, mode, req)
2551+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
25542552 FS_ASYNC_TRACE_BEGIN0 (UV_FS_FCHMOD, req_wrap_async)
25552553 AsyncCall (env, req_wrap_async, args, " fchmod" , UTF8, AfterNoArgs,
25562554 uv_fs_fchmod, fd, mode);
2557- } else { // fchmod(fd, mode, undefined, ctx)
2558- CHECK_EQ (argc, 4 );
2559- FSReqWrapSync req_wrap_sync;
2555+ } else { // fchmod(fd, mode)
2556+ FSReqWrapSync req_wrap_sync (" fchmod" );
25602557 FS_SYNC_TRACE_BEGIN (fchmod);
2561- SyncCall (env, args[3 ], &req_wrap_sync, " fchmod" ,
2562- uv_fs_fchmod, fd, mode);
2558+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_fchmod, fd, mode);
25632559 FS_SYNC_TRACE_END (fchmod);
25642560 }
25652561}
0 commit comments