@@ -2517,18 +2517,16 @@ static void Chmod(const FunctionCallbackInfo<Value>& args) {
2517
2517
CHECK (args[1 ]->IsInt32 ());
2518
2518
int mode = args[1 ].As <Int32>()->Value ();
2519
2519
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 );
2522
2522
FS_ASYNC_TRACE_BEGIN1 (
2523
2523
UV_FS_CHMOD, req_wrap_async, " path" , TRACE_STR_COPY (*path))
2524
2524
AsyncCall (env, req_wrap_async, args, " chmod" , UTF8, AfterNoArgs,
2525
2525
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);
2529
2528
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);
2532
2530
FS_SYNC_TRACE_END (chmod);
2533
2531
}
2534
2532
}
@@ -2549,17 +2547,15 @@ static void FChmod(const FunctionCallbackInfo<Value>& args) {
2549
2547
CHECK (args[1 ]->IsInt32 ());
2550
2548
const int mode = args[1 ].As <Int32>()->Value ();
2551
2549
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 );
2554
2552
FS_ASYNC_TRACE_BEGIN0 (UV_FS_FCHMOD, req_wrap_async)
2555
2553
AsyncCall (env, req_wrap_async, args, " fchmod" , UTF8, AfterNoArgs,
2556
2554
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" );
2560
2557
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);
2563
2559
FS_SYNC_TRACE_END (fchmod);
2564
2560
}
2565
2561
}
0 commit comments