From 1eb113f18ac28c545dc82cc41030434db0402df1 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 26 Feb 2025 11:33:42 -0800 Subject: [PATCH] [WasmFS] Remove unnecessary cast and strlen. NFC --- system/lib/wasmfs/syscalls.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/system/lib/wasmfs/syscalls.cpp b/system/lib/wasmfs/syscalls.cpp index f52eb65ad9ec2..4e26759a3c106 100644 --- a/system/lib/wasmfs/syscalls.cpp +++ b/system/lib/wasmfs/syscalls.cpp @@ -759,11 +759,9 @@ int __syscall_getcwd(intptr_t buf, size_t size) { return -ENOENT; } - auto parentDir = parent->dynCast(); - - auto name = parentDir->locked().getName(curr); + auto name = parent->locked().getName(curr); result = '/' + name + result; - curr = parentDir; + curr = parent; } // Check if the cwd is the root directory. @@ -771,8 +769,7 @@ int __syscall_getcwd(intptr_t buf, size_t size) { result = "/"; } - auto res = result.c_str(); - int len = strlen(res) + 1; + int len = result.length() + 1; // Check if the size argument is less than the length of the absolute // pathname of the working directory, including null terminator. @@ -781,7 +778,7 @@ int __syscall_getcwd(intptr_t buf, size_t size) { } // Return value is a null-terminated c string. - strcpy((char*)buf, res); + strcpy((char*)buf, result.c_str()); return len; }