fs: fix to not return for void function

PR-URL: https://github.com/nodejs/node/pull/50769
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Qingyu Deng <i@ayase-lab.com>
This commit is contained in:
Jungku Lee 2023-11-25 02:47:59 +09:00 committed by GitHub
parent 6dbf678ae5
commit ec79232938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -530,7 +530,7 @@ function close(fd, callback = defaultCloseCallback) {
function closeSync(fd) { function closeSync(fd) {
fd = getValidatedFd(fd); fd = getValidatedFd(fd);
return binding.close(fd); binding.close(fd);
} }
/** /**
@ -782,7 +782,7 @@ function readv(fd, buffers, position, callback) {
if (typeof position !== 'number') if (typeof position !== 'number')
position = null; position = null;
return binding.readBuffers(fd, buffers, position, req); binding.readBuffers(fd, buffers, position, req);
} }
ObjectDefineProperty(readv, kCustomPromisifyArgsSymbol, ObjectDefineProperty(readv, kCustomPromisifyArgsSymbol,
@ -858,7 +858,8 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) {
const req = new FSReqCallback(); const req = new FSReqCallback();
req.oncomplete = wrapper; req.oncomplete = wrapper;
return binding.writeBuffer(fd, buffer, offset, length, position, req); binding.writeBuffer(fd, buffer, offset, length, position, req);
return;
} }
validateStringAfterArrayBufferView(buffer, 'buffer'); validateStringAfterArrayBufferView(buffer, 'buffer');
@ -879,7 +880,7 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) {
const req = new FSReqCallback(); const req = new FSReqCallback();
req.oncomplete = wrapper; req.oncomplete = wrapper;
return binding.writeString(fd, str, offset, length, req); binding.writeString(fd, str, offset, length, req);
} }
ObjectDefineProperty(write, kCustomPromisifyArgsSymbol, ObjectDefineProperty(write, kCustomPromisifyArgsSymbol,
@ -969,7 +970,7 @@ function writev(fd, buffers, position, callback) {
if (typeof position !== 'number') if (typeof position !== 'number')
position = null; position = null;
return binding.writeBuffers(fd, buffers, position, req); binding.writeBuffers(fd, buffers, position, req);
} }
ObjectDefineProperty(writev, kCustomPromisifyArgsSymbol, { ObjectDefineProperty(writev, kCustomPromisifyArgsSymbol, {
@ -1175,7 +1176,8 @@ function rmdir(path, options, callback) {
if (err === false) { if (err === false) {
const req = new FSReqCallback(); const req = new FSReqCallback();
req.oncomplete = callback; req.oncomplete = callback;
return binding.rmdir(path, req); binding.rmdir(path, req);
return;
} }
if (err) { if (err) {
return callback(err); return callback(err);
@ -1188,7 +1190,7 @@ function rmdir(path, options, callback) {
validateRmdirOptions(options); validateRmdirOptions(options);
const req = new FSReqCallback(); const req = new FSReqCallback();
req.oncomplete = callback; req.oncomplete = callback;
return binding.rmdir(path, req); binding.rmdir(path, req);
} }
} }
@ -1294,7 +1296,7 @@ function fdatasync(fd, callback) {
*/ */
function fdatasyncSync(fd) { function fdatasyncSync(fd) {
fd = getValidatedFd(fd); fd = getValidatedFd(fd);
return binding.fdatasync(fd); binding.fdatasync(fd);
} }
/** /**
@ -1319,7 +1321,7 @@ function fsync(fd, callback) {
*/ */
function fsyncSync(fd) { function fsyncSync(fd) {
fd = getValidatedFd(fd); fd = getValidatedFd(fd);
return binding.fsync(fd); binding.fsync(fd);
} }
/** /**
@ -1877,7 +1879,7 @@ function unlink(path, callback) {
*/ */
function unlinkSync(path) { function unlinkSync(path) {
path = pathModule.toNamespacedPath(getValidatedPath(path)); path = pathModule.toNamespacedPath(getValidatedPath(path));
return binding.unlink(path); binding.unlink(path);
} }
/** /**
@ -2921,7 +2923,7 @@ realpath.native = (path, options, callback) => {
path = getValidatedPath(path); path = getValidatedPath(path);
const req = new FSReqCallback(); const req = new FSReqCallback();
req.oncomplete = callback; req.oncomplete = callback;
return binding.realpath(pathModule.toNamespacedPath(path), options.encoding, req); binding.realpath(pathModule.toNamespacedPath(path), options.encoding, req);
}; };
/** /**