Skip to content

Commit 772bf28

Browse files
committed
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; ```
1 parent 697c90b commit 772bf28

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/win/fs.c

+20-3
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,23 @@
4949
#define UV_FS_FREE_PTR 0x0008
5050
#define UV_FS_CLEANEDUP 0x0010
5151

52+
#ifndef S_IRWXU
53+
#define S_IRWXU 0000700 /* RWX mask for owner */
54+
#define S_IRUSR 0000400 /* R for owner */
55+
#define S_IWUSR 0000200 /* W for owner */
56+
#define S_IXUSR 0000100 /* X for owner */
57+
58+
#define S_IRWXG 0000070 /* RWX mask for group */
59+
#define S_IRGRP 0000040 /* R for group */
60+
#define S_IWGRP 0000020 /* W for group */
61+
#define S_IXGRP 0000010 /* X for group */
62+
63+
#define S_IRWXO 0000007 /* RWX mask for other */
64+
#define S_IROTH 0000004 /* R for other */
65+
#define S_IWOTH 0000002 /* W for other */
66+
#define S_IXOTH 0000001 /* X for other */
67+
#endif
68+
5269
/* number of attempts to generate a unique directory name before declaring failure */
5370
#define TMP_MAX 32767
5471

@@ -2120,7 +2137,7 @@ static void fs__access(uv_fs_t* req) {
21202137

21212138
DWORD sdLen = 0, err = 0, tokenAccess = 0, desiredAccess = 0,
21222139
grantedAccess = 0, privilegesLen = 0;
2123-
SECURITY_INFORMATION si = NULL;
2140+
SECURITY_INFORMATION si = (SECURITY_INFORMATION)NULL;
21242141
PSECURITY_DESCRIPTOR sd = NULL;
21252142
HANDLE hToken = NULL, hImpersonatedToken = NULL;
21262143
GENERIC_MAPPING mapping = { 0xFFFFFFFF };
@@ -2242,7 +2259,7 @@ static void fs__access(uv_fs_t* req) {
22422259
}
22432260

22442261
static void build_access_struct(EXPLICIT_ACCESS_W* ea, PSID owner,
2245-
TRUSTEE_TYPE user_type, mode_t mode_triplet,
2262+
TRUSTEE_TYPE user_type, DWORD mode_triplet,
22462263
ACCESS_MODE allow_deny) {
22472264
/*
22482265
* 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) {
23052322
psidNull = NULL, psidCreatorGroup = NULL;
23062323
PSECURITY_DESCRIPTOR pSD = NULL;
23072324
PEXPLICIT_ACCESS_W ea = NULL, pOldEAs = NULL;
2308-
SECURITY_INFORMATION si = NULL;
2325+
SECURITY_INFORMATION si = (SECURITY_INFORMATION)NULL;
23092326
DWORD numGroups = 0, tokenAccess = 0, u_mode = 0, g_mode = 0, o_mode = 0,
23102327
u_deny_mode = 0, g_deny_mode = 0, attr = 0, new_attr = 0;
23112328
HANDLE hToken = NULL, hImpersonatedToken = NULL;

0 commit comments

Comments
 (0)