@@ -2552,18 +2552,16 @@ static void Chmod(const FunctionCallbackInfo<Value>& args) {
2552
2552
CHECK (args[1 ]->IsInt32 ());
2553
2553
int mode = args[1 ].As <Int32>()->Value ();
2554
2554
2555
- FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
2556
- if ( req_wrap_async != nullptr ) { // chmod(path, mode, req)
2555
+ if (argc > 2 ) { // chmod(path, mode, req)
2556
+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
2557
2557
FS_ASYNC_TRACE_BEGIN1 (
2558
2558
UV_FS_CHMOD, req_wrap_async, " path" , TRACE_STR_COPY (*path))
2559
2559
AsyncCall (env, req_wrap_async, args, " chmod" , UTF8, AfterNoArgs,
2560
2560
uv_fs_chmod, *path, mode);
2561
- } else { // chmod(path, mode, undefined, ctx)
2562
- CHECK_EQ (argc, 4 );
2563
- FSReqWrapSync req_wrap_sync;
2561
+ } else { // chmod(path, mode)
2562
+ FSReqWrapSync req_wrap_sync (" chmod" , *path);
2564
2563
FS_SYNC_TRACE_BEGIN (chmod);
2565
- SyncCall (env, args[3 ], &req_wrap_sync, " chmod" ,
2566
- uv_fs_chmod, *path, mode);
2564
+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_chmod, *path, mode);
2567
2565
FS_SYNC_TRACE_END (chmod);
2568
2566
}
2569
2567
}
@@ -2584,17 +2582,15 @@ static void FChmod(const FunctionCallbackInfo<Value>& args) {
2584
2582
CHECK (args[1 ]->IsInt32 ());
2585
2583
const int mode = args[1 ].As <Int32>()->Value ();
2586
2584
2587
- FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
2588
- if ( req_wrap_async != nullptr ) { // fchmod(fd, mode, req)
2585
+ if (argc > 2 ) { // fchmod(fd, mode, req)
2586
+ FSReqBase* req_wrap_async = GetReqWrap (args, 2 );
2589
2587
FS_ASYNC_TRACE_BEGIN0 (UV_FS_FCHMOD, req_wrap_async)
2590
2588
AsyncCall (env, req_wrap_async, args, " fchmod" , UTF8, AfterNoArgs,
2591
2589
uv_fs_fchmod, fd, mode);
2592
- } else { // fchmod(fd, mode, undefined, ctx)
2593
- CHECK_EQ (argc, 4 );
2594
- FSReqWrapSync req_wrap_sync;
2590
+ } else { // fchmod(fd, mode)
2591
+ FSReqWrapSync req_wrap_sync (" fchmod" );
2595
2592
FS_SYNC_TRACE_BEGIN (fchmod);
2596
- SyncCall (env, args[3 ], &req_wrap_sync, " fchmod" ,
2597
- uv_fs_fchmod, fd, mode);
2593
+ SyncCallAndThrowOnError (env, &req_wrap_sync, uv_fs_fchmod, fd, mode);
2598
2594
FS_SYNC_TRACE_END (fchmod);
2599
2595
}
2600
2596
}
0 commit comments