Skip to content

Commit c34a89f

Browse files
authored
[WasmFS] Remove unnecessary cast and strlen. NFC (#23768)
1 parent 53f341c commit c34a89f

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

system/lib/wasmfs/syscalls.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -759,20 +759,17 @@ int __syscall_getcwd(intptr_t buf, size_t size) {
759759
return -ENOENT;
760760
}
761761

762-
auto parentDir = parent->dynCast<Directory>();
763-
764-
auto name = parentDir->locked().getName(curr);
762+
auto name = parent->locked().getName(curr);
765763
result = '/' + name + result;
766-
curr = parentDir;
764+
curr = parent;
767765
}
768766

769767
// Check if the cwd is the root directory.
770768
if (result.empty()) {
771769
result = "/";
772770
}
773771

774-
auto res = result.c_str();
775-
int len = strlen(res) + 1;
772+
int len = result.length() + 1;
776773

777774
// Check if the size argument is less than the length of the absolute
778775
// pathname of the working directory, including null terminator.
@@ -781,7 +778,7 @@ int __syscall_getcwd(intptr_t buf, size_t size) {
781778
}
782779

783780
// Return value is a null-terminated c string.
784-
strcpy((char*)buf, res);
781+
strcpy((char*)buf, result.c_str());
785782

786783
return len;
787784
}

0 commit comments

Comments
 (0)