Skip to content

Commit 4d8ad38

Browse files
author
Denys Vlasenko
committed
devfsd: remove static variable
function old new delta static.msg 4 - -4 get_uid_gid 114 107 -7 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-11) Total: -11 bytes Signed-off-by: Denys Vlasenko <[email protected]>
1 parent 924a179 commit 4d8ad38

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Diff for: miscutils/devfsd.c

+11-9
Original file line numberDiff line numberDiff line change
@@ -1083,21 +1083,23 @@ static int get_uid_gid(int flag, const char *string)
10831083
{
10841084
struct passwd *pw_ent;
10851085
struct group *grp_ent;
1086-
static const char *msg;
1086+
const char *msg;
10871087

1088-
if (ENABLE_DEVFSD_VERBOSE)
1089-
msg = "user";
1090-
1091-
if (isdigit(string[0]) ||((string[0] == '-') && isdigit(string[1])))
1088+
if (isdigit(string[0]) || ((string[0] == '-') && isdigit(string[1])))
10921089
return atoi(string);
10931090

10941091
if (flag == UID && (pw_ent = getpwnam(string)) != NULL)
10951092
return pw_ent->pw_uid;
10961093

1097-
if (flag == GID && (grp_ent = getgrnam(string)) != NULL)
1098-
return grp_ent->gr_gid;
1099-
else if (ENABLE_DEVFSD_VERBOSE)
1100-
msg = "group";
1094+
if (ENABLE_DEVFSD_VERBOSE)
1095+
msg = "user";
1096+
1097+
if (flag == GID) {
1098+
if ((grp_ent = getgrnam(string)) != NULL)
1099+
return grp_ent->gr_gid;
1100+
if (ENABLE_DEVFSD_VERBOSE)
1101+
msg = "group";
1102+
}
11011103

11021104
if (ENABLE_DEVFSD_VERBOSE)
11031105
msg_logger(LOG_ERR, "unknown %s: %s, defaulting to %cid=0", msg, string, msg[0]);

0 commit comments

Comments
 (0)