@@ -2506,18 +2506,16 @@ static void Chmod(const FunctionCallbackInfo<Value>& args) {
25062506 CHECK (args[1 ]->IsInt32 ());
25072507 int mode = args[1 ].As <Int32>()->Value ();
25082508
2509- FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
2510- if ( req_wrap_async != nullptr ) { // chmod(path, mode, req)
2509+ if (argc > 2 ) { // chmod(path, mode, req)
2510+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
25112511 FS_ASYNC_TRACE_BEGIN1 (
25122512 UV_FS_CHMOD, req_wrap_async, " path" , TRACE_STR_COPY (*path))
25132513 AsyncCall (env, req_wrap_async, args, " chmod" , UTF8, AfterNoArgs,
25142514 uv_fs_chmod, *path, mode);
2515- } else { // chmod(path, mode, undefined, ctx)
2516- CHECK_EQ (argc, 4 );
2517- FSReqWrapSync req_wrap_sync;
2515+ } else { // chmod(path, mode)
2516+ FSReqWrapSync req_wrap_sync (" chmod" , *path);
25182517 FS_SYNC_TRACE_BEGIN (chmod);
2519- SyncCall (env, args[3 ], &req_wrap_sync, " chmod" ,
2520- uv_fs_chmod, *path, mode);
2518+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_chmod, *path, mode);
25212519 FS_SYNC_TRACE_END (chmod);
25222520 }
25232521}
@@ -2538,17 +2536,15 @@ static void FChmod(const FunctionCallbackInfo<Value>& args) {
25382536 CHECK (args[1 ]->IsInt32 ());
25392537 const int mode = args[1 ].As <Int32>()->Value ();
25402538
2541- FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
2542- if ( req_wrap_async != nullptr ) { // fchmod(fd, mode, req)
2539+ if (argc > 2 ) { // fchmod(fd, mode, req)
2540+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
25432541 FS_ASYNC_TRACE_BEGIN0 (UV_FS_FCHMOD, req_wrap_async)
25442542 AsyncCall (env, req_wrap_async, args, " fchmod" , UTF8, AfterNoArgs,
25452543 uv_fs_fchmod, fd, mode);
2546- } else { // fchmod(fd, mode, undefined, ctx)
2547- CHECK_EQ (argc, 4 );
2548- FSReqWrapSync req_wrap_sync;
2544+ } else { // fchmod(fd, mode)
2545+ FSReqWrapSync req_wrap_sync (" fchmod" );
25492546 FS_SYNC_TRACE_BEGIN (fchmod);
2550- SyncCall (env, args[3 ], &req_wrap_sync, " fchmod" ,
2551- uv_fs_fchmod, fd, mode);
2547+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_fchmod, fd, mode);
25522548 FS_SYNC_TRACE_END (fchmod);
25532549 }
25542550}
0 commit comments