diff options
author | Darren Tucker <dtucker@dtucker.net> | 2019-07-06 13:02:34 +1000 |
---|---|---|
committer | Darren Tucker <dtucker@dtucker.net> | 2019-07-06 13:02:34 +1000 |
commit | 4c3e00b1ed7e596610f34590eb5d54ee50d77878 (patch) | |
tree | 646e12361a847bb01aa1e3da580077a723e9ff5a /openbsd-compat | |
parent | 2753521e899f30d1d58b5da0b4e68fde6fcf341e (diff) |
Cast *ID types to unsigned long when printing.
UID and GID types vary by platform so cast to u_long and use %lu when
printing them to prevent warnings.
Diffstat (limited to 'openbsd-compat')
-rw-r--r-- | openbsd-compat/bsd-setres_id.c | 12 | ||||
-rw-r--r-- | openbsd-compat/pwcache.c | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/openbsd-compat/bsd-setres_id.c b/openbsd-compat/bsd-setres_id.c index 696ae7b28..a8e76bf60 100644 --- a/openbsd-compat/bsd-setres_id.c +++ b/openbsd-compat/bsd-setres_id.c | |||
@@ -37,20 +37,20 @@ setresgid(gid_t rgid, gid_t egid, gid_t sgid) | |||
37 | #if defined(HAVE_SETREGID) && !defined(BROKEN_SETREGID) | 37 | #if defined(HAVE_SETREGID) && !defined(BROKEN_SETREGID) |
38 | if (setregid(rgid, egid) < 0) { | 38 | if (setregid(rgid, egid) < 0) { |
39 | saved_errno = errno; | 39 | saved_errno = errno; |
40 | error("setregid %u: %.100s", rgid, strerror(errno)); | 40 | error("setregid %lu: %.100s", (u_long)rgid, strerror(errno)); |
41 | errno = saved_errno; | 41 | errno = saved_errno; |
42 | ret = -1; | 42 | ret = -1; |
43 | } | 43 | } |
44 | #else | 44 | #else |
45 | if (setegid(egid) < 0) { | 45 | if (setegid(egid) < 0) { |
46 | saved_errno = errno; | 46 | saved_errno = errno; |
47 | error("setegid %u: %.100s", (u_int)egid, strerror(errno)); | 47 | error("setegid %lu: %.100s", (u_long)egid, strerror(errno)); |
48 | errno = saved_errno; | 48 | errno = saved_errno; |
49 | ret = -1; | 49 | ret = -1; |
50 | } | 50 | } |
51 | if (setgid(rgid) < 0) { | 51 | if (setgid(rgid) < 0) { |
52 | saved_errno = errno; | 52 | saved_errno = errno; |
53 | error("setgid %u: %.100s", rgid, strerror(errno)); | 53 | error("setgid %ul: %.100s", (u_long)rgid, strerror(errno)); |
54 | errno = saved_errno; | 54 | errno = saved_errno; |
55 | ret = -1; | 55 | ret = -1; |
56 | } | 56 | } |
@@ -72,7 +72,7 @@ setresuid(uid_t ruid, uid_t euid, uid_t suid) | |||
72 | #if defined(HAVE_SETREUID) && !defined(BROKEN_SETREUID) | 72 | #if defined(HAVE_SETREUID) && !defined(BROKEN_SETREUID) |
73 | if (setreuid(ruid, euid) < 0) { | 73 | if (setreuid(ruid, euid) < 0) { |
74 | saved_errno = errno; | 74 | saved_errno = errno; |
75 | error("setreuid %u: %.100s", ruid, strerror(errno)); | 75 | error("setreuid %lu: %.100s", (u_long)ruid, strerror(errno)); |
76 | errno = saved_errno; | 76 | errno = saved_errno; |
77 | ret = -1; | 77 | ret = -1; |
78 | } | 78 | } |
@@ -81,14 +81,14 @@ setresuid(uid_t ruid, uid_t euid, uid_t suid) | |||
81 | # ifndef SETEUID_BREAKS_SETUID | 81 | # ifndef SETEUID_BREAKS_SETUID |
82 | if (seteuid(euid) < 0) { | 82 | if (seteuid(euid) < 0) { |
83 | saved_errno = errno; | 83 | saved_errno = errno; |
84 | error("seteuid %u: %.100s", euid, strerror(errno)); | 84 | error("seteuid %lu: %.100s", (u_long)euid, strerror(errno)); |
85 | errno = saved_errno; | 85 | errno = saved_errno; |
86 | ret = -1; | 86 | ret = -1; |
87 | } | 87 | } |
88 | # endif | 88 | # endif |
89 | if (setuid(ruid) < 0) { | 89 | if (setuid(ruid) < 0) { |
90 | saved_errno = errno; | 90 | saved_errno = errno; |
91 | error("setuid %u: %.100s", ruid, strerror(errno)); | 91 | error("setuid %lu: %.100s", (u_long)ruid, strerror(errno)); |
92 | errno = saved_errno; | 92 | errno = saved_errno; |
93 | ret = -1; | 93 | ret = -1; |
94 | } | 94 | } |
diff --git a/openbsd-compat/pwcache.c b/openbsd-compat/pwcache.c index 5a8b78801..826c2378b 100644 --- a/openbsd-compat/pwcache.c +++ b/openbsd-compat/pwcache.c | |||
@@ -67,7 +67,7 @@ user_from_uid(uid_t uid, int nouser) | |||
67 | if ((pw = getpwuid(uid)) == NULL) { | 67 | if ((pw = getpwuid(uid)) == NULL) { |
68 | if (nouser) | 68 | if (nouser) |
69 | return (NULL); | 69 | return (NULL); |
70 | (void)snprintf(nbuf, sizeof(nbuf), "%u", uid); | 70 | (void)snprintf(nbuf, sizeof(nbuf), "%lu", (u_long)uid); |
71 | } | 71 | } |
72 | cp->uid = uid; | 72 | cp->uid = uid; |
73 | if (cp->name != NULL) | 73 | if (cp->name != NULL) |
@@ -102,7 +102,7 @@ group_from_gid(gid_t gid, int nogroup) | |||
102 | if ((gr = getgrgid(gid)) == NULL) { | 102 | if ((gr = getgrgid(gid)) == NULL) { |
103 | if (nogroup) | 103 | if (nogroup) |
104 | return (NULL); | 104 | return (NULL); |
105 | (void)snprintf(nbuf, sizeof(nbuf), "%u", gid); | 105 | (void)snprintf(nbuf, sizeof(nbuf), "%lu", (u_long)gid); |
106 | } | 106 | } |
107 | cp->gid = gid; | 107 | cp->gid = gid; |
108 | if (cp->name != NULL) | 108 | if (cp->name != NULL) |