Skip to content

Commit

Permalink
Remove second argument to ErrnoError. NFC
Browse files Browse the repository at this point in the history
This was only passed in one 1 out of 199 call sites, and never read
(AFIACT).
  • Loading branch information
sbc100 committed Jan 23, 2024
1 parent 7e6366d commit 039ddd2
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/library_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ FS.staticInit();` +
lookupNode(parent, name) {
var errCode = FS.mayLookup(parent);
if (errCode) {
throw new FS.ErrnoError(errCode, parent);
throw new FS.ErrnoError(errCode);
}
var hash = FS.hashName(parent.id, name);
#if CASE_INSENSITIVE_FS
Expand Down Expand Up @@ -316,6 +316,7 @@ FS.staticInit();` +
return 0;
},
mayLookup(dir) {
if (!FS.isDir(dir.mode)) return {{{ cDefs.ENOTDIR }}};
var errCode = FS.nodePermissions(dir, 'x');
if (errCode) return errCode;
if (!dir.node_ops.lookup) return {{{ cDefs.EACCES }}};
Expand Down Expand Up @@ -1408,15 +1409,14 @@ FS.staticInit();` +
},
ensureErrnoError() {
if (FS.ErrnoError) return;
FS.ErrnoError = /** @this{Object} */ function ErrnoError(errno, node) {
FS.ErrnoError = /** @this{Object} */ function ErrnoError(errno) {
// We set the `name` property to be able to identify `FS.ErrnoError`
// - the `name` is a standard ECMA-262 property of error objects. Kind of good to have it anyway.
// - when using PROXYFS, an error can come from an underlying FS
// as different FS objects have their own FS.ErrnoError each,
// the test `err instanceof FS.ErrnoError` won't detect an error coming from another filesystem, causing bugs.
// we'll use the reliable test `err.name == "ErrnoError"` instead
this.name = 'ErrnoError';
this.node = node;
this.setErrno = /** @this{Object} */ function(errno) {
this.errno = errno;
#if ASSERTIONS
Expand Down
10 changes: 1 addition & 9 deletions src/library_syscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,7 @@ var SyscallsLibrary = {
},

doStat(func, path, buf) {
try {
var stat = func(path);
} catch (e) {
if (e && e.node && PATH.normalize(path) !== PATH.normalize(FS.getPath(e.node))) {
// an error occurred while trying to look up the path; we should just report ENOTDIR
return -{{{ cDefs.ENOTDIR }}};
}
throw e;
}
var stat = func(path);
{{{ makeSetValue('buf', C_STRUCTS.stat.st_dev, 'stat.dev', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_mode, 'stat.mode', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_nlink, 'stat.nlink', SIZE_TYPE) }}};
Expand Down
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_ctors1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9936
9927
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_ctors1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24683
24667
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_ctors2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9921
9909
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_ctors2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24651
24635
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11015
11003
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
28573
28557
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except_wasm.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9903
9893
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_except_wasm.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24576
24560
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_mangle.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
11021
11010
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_mangle.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
28573
28557
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_noexcept.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9936
9927
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_cxx_noexcept.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24683
24667
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_files_js_fs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7874
7866
2 changes: 1 addition & 1 deletion test/other/metadce/test_metadce_files_js_fs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
19705
19689

0 comments on commit 039ddd2

Please sign in to comment.