Skip to content

Commit 32f9929

Browse files
pks-tgitster
authored andcommitted
ident: add casts for fallback name and GECOS
In `xgetpwuid_self()`, we return a fallback identity when it was not possible to look up the current identity. This fallback identity needs to be internal and must never be written to by the calles as specified by getpwuid(3P). As both the `pw_name` and `pw_gecos` fields are marked as non-constant though, it will cause a warning to assign constant strings to them once compiling with `-Wwrite-strings`. Add explicit casts to avoid the warning. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b31607a commit 32f9929

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

ident.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ static struct passwd *xgetpwuid_self(int *is_bogus)
4646
pw = getpwuid(getuid());
4747
if (!pw) {
4848
static struct passwd fallback;
49-
fallback.pw_name = "unknown";
49+
fallback.pw_name = (char *) "unknown";
5050
#ifndef NO_GECOS_IN_PWENT
51-
fallback.pw_gecos = "Unknown";
51+
fallback.pw_gecos = (char *) "Unknown";
5252
#endif
5353
pw = &fallback;
5454
if (is_bogus)

0 commit comments

Comments
 (0)