From c9761df62da5b51aab02c94ed0a2a7b50aacfafd Mon Sep 17 00:00:00 2001 From: Jungku Lee Date: Sat, 25 Nov 2023 02:47:59 +0900 Subject: [PATCH] fs: fix to not return for void function PR-URL: https://github.com/nodejs/node/pull/50769 Reviewed-By: Matthew Aitken Reviewed-By: Yagiz Nizipli Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Qingyu Deng --- lib/fs.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index 59724e884e6dbe..5e1165453367f7 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -534,7 +534,7 @@ function close(fd, callback = defaultCloseCallback) { function closeSync(fd) { fd = getValidatedFd(fd); - return binding.close(fd); + binding.close(fd); } /** @@ -784,7 +784,7 @@ function readv(fd, buffers, position, callback) { if (typeof position !== 'number') position = null; - return binding.readBuffers(fd, buffers, position, req); + binding.readBuffers(fd, buffers, position, req); } ObjectDefineProperty(readv, kCustomPromisifyArgsSymbol, @@ -860,7 +860,8 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) { const req = new FSReqCallback(); req.oncomplete = wrapper; - return binding.writeBuffer(fd, buffer, offset, length, position, req); + binding.writeBuffer(fd, buffer, offset, length, position, req); + return; } validateStringAfterArrayBufferView(buffer, 'buffer'); @@ -881,7 +882,7 @@ function write(fd, buffer, offsetOrOptions, length, position, callback) { const req = new FSReqCallback(); req.oncomplete = wrapper; - return binding.writeString(fd, str, offset, length, req); + binding.writeString(fd, str, offset, length, req); } ObjectDefineProperty(write, kCustomPromisifyArgsSymbol, @@ -971,7 +972,7 @@ function writev(fd, buffers, position, callback) { if (typeof position !== 'number') position = null; - return binding.writeBuffers(fd, buffers, position, req); + binding.writeBuffers(fd, buffers, position, req); } ObjectDefineProperty(writev, kCustomPromisifyArgsSymbol, { @@ -1177,7 +1178,8 @@ function rmdir(path, options, callback) { if (err === false) { const req = new FSReqCallback(); req.oncomplete = callback; - return binding.rmdir(path, req); + binding.rmdir(path, req); + return; } if (err) { return callback(err); @@ -1190,7 +1192,7 @@ function rmdir(path, options, callback) { validateRmdirOptions(options); const req = new FSReqCallback(); req.oncomplete = callback; - return binding.rmdir(path, req); + binding.rmdir(path, req); } } @@ -1296,7 +1298,7 @@ function fdatasync(fd, callback) { */ function fdatasyncSync(fd) { fd = getValidatedFd(fd); - return binding.fdatasync(fd); + binding.fdatasync(fd); } /** @@ -1321,7 +1323,7 @@ function fsync(fd, callback) { */ function fsyncSync(fd) { fd = getValidatedFd(fd); - return binding.fsync(fd); + binding.fsync(fd); } /** @@ -1888,7 +1890,7 @@ function unlink(path, callback) { */ function unlinkSync(path) { path = pathModule.toNamespacedPath(getValidatedPath(path)); - return binding.unlink(path); + binding.unlink(path); } /** @@ -2929,7 +2931,7 @@ realpath.native = (path, options, callback) => { path = getValidatedPath(path); const req = new FSReqCallback(); req.oncomplete = callback; - return binding.realpath(pathModule.toNamespacedPath(path), options.encoding, req); + binding.realpath(pathModule.toNamespacedPath(path), options.encoding, req); }; /**