From a694cb601a92a1e4eded89f4c13793c9d12e33b6 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 7 Jul 2024 12:51:51 +0100 Subject: win32: code shrink system drive handling A previous commit (e3bfe3695) revised the use of getsysdir() to obtain the system directory, and hence the system drive. See the commit message for the history to that point. Further improvements are possible: - Remove getsysdir() and push the calls to GetSystemDirectory() down into get_system_drive() and get_proc_addr(). - Check the return value of GetSystemDirectory(). It's unlikely to fail, but better safe than sorry. - Instead of making all callers of get_system_drive() check for a NULL return value always return a non-NULL pointer. If the drive can't be found an empty string is returned instead (which is what the callers were using anyway). - The function need_system_drive() was only used in one place (in httpd). Move the code there and remove the function. - Use concat_path_file() where possible. Saves 76-144 bytes. --- shell/ash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index e2dcb0962..881bc12ab 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -16292,7 +16292,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv) state = 1; #if ENABLE_PLATFORM_MINGW32 - hp = xasprintf("%s/etc/profile", get_system_drive() ?: ""); + hp = concat_path_file(get_system_drive(), "/etc/profile"); read_profile(hp); free((void *)hp); #else -- cgit v1.2.3-55-g6feb