Skip to content

Commit

Permalink
win,fs: Fix compiler warnings and errors
Browse files Browse the repository at this point in the history
* 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;
```
  • Loading branch information
staticfloat committed Feb 6, 2025
1 parent c1e06dd commit 46ca7fe
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/win/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 46ca7fe

Please sign in to comment.