From 12c6211783bb1002d721a632cacca5120c494ef5 Mon Sep 17 00:00:00 2001 From: Elliot Saba Date: Tue, 21 Jan 2025 19:25:16 -0800 Subject: [PATCH] win,fs: Fix compiler warnings and errors * Use `DWORD` instead of `mode_t` on Windows. It's not needed to use `mode_t` here, and it just confuses VS. * Define `S_IRWXU` and others if not already defined. * When compiling on my windows testing box, I get the error: ``` error: initialization of 'SECURITY_INFORMATION' {aka 'long unsigned int'} from 'void *' makes integer from pointer without a cast [-Wint-conversion] 2317 | SECURITY_INFORMATION si = NULL; ``` --- src/win/fs.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/win/fs.c b/src/win/fs.c index b7114edda43..7d60c7f0f6a 100644 --- a/src/win/fs.c +++ b/src/win/fs.c @@ -49,6 +49,23 @@ #define UV_FS_FREE_PTR 0x0008 #define UV_FS_CLEANEDUP 0x0010 +#ifndef S_IRWXU +#define S_IRWXU 0000700 /* RWX mask for owner */ +#define S_IRUSR 0000400 /* R for owner */ +#define S_IWUSR 0000200 /* W for owner */ +#define S_IXUSR 0000100 /* X for owner */ + +#define S_IRWXG 0000070 /* RWX mask for group */ +#define S_IRGRP 0000040 /* R for group */ +#define S_IWGRP 0000020 /* W for group */ +#define S_IXGRP 0000010 /* X for group */ + +#define S_IRWXO 0000007 /* RWX mask for other */ +#define S_IROTH 0000004 /* R for other */ +#define S_IWOTH 0000002 /* W for other */ +#define S_IXOTH 0000001 /* X for other */ +#endif + /* number of attempts to generate a unique directory name before declaring failure */ #define TMP_MAX 32767 @@ -2120,7 +2137,7 @@ static void fs__access(uv_fs_t* req) { DWORD sdLen = 0, err = 0, tokenAccess = 0, desiredAccess = 0, grantedAccess = 0, privilegesLen = 0; - SECURITY_INFORMATION si = NULL; + SECURITY_INFORMATION si = (SECURITY_INFORMATION)NULL; PSECURITY_DESCRIPTOR sd = NULL; HANDLE hToken = NULL, hImpersonatedToken = NULL; GENERIC_MAPPING mapping = { 0xFFFFFFFF }; @@ -2242,7 +2259,7 @@ static void fs__access(uv_fs_t* req) { } static void build_access_struct(EXPLICIT_ACCESS_W* ea, PSID owner, - TRUSTEE_TYPE user_type, mode_t mode_triplet, + TRUSTEE_TYPE user_type, DWORD mode_triplet, ACCESS_MODE allow_deny) { /* * We map the typical POSIX mode bits r/w/x as the Windows @@ -2305,7 +2322,7 @@ static void fs__chmod(uv_fs_t* req) { psidNull = NULL, psidCreatorGroup = NULL; PSECURITY_DESCRIPTOR pSD = NULL; PEXPLICIT_ACCESS_W ea = NULL, pOldEAs = NULL; - SECURITY_INFORMATION si = NULL; + SECURITY_INFORMATION si = (SECURITY_INFORMATION)NULL; DWORD numGroups = 0, tokenAccess = 0, u_mode = 0, g_mode = 0, o_mode = 0, u_deny_mode = 0, g_deny_mode = 0, attr = 0, new_attr = 0; HANDLE hToken = NULL, hImpersonatedToken = NULL;