[git commit] devfsd: remove static variable

Denys Vlasenko vda.linux at googlemail.com
Tue Nov 26 11:12:27 UTC 2013


commit: http://git.busybox.net/busybox/commit/?id=4d8ad381abe9a37a8e2abc4d27afb0dea78b4f76
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

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 <vda.linux at googlemail.com>
---
 miscutils/devfsd.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c
index 24c953b..96ffe07 100644
--- a/miscutils/devfsd.c
+++ b/miscutils/devfsd.c
@@ -1083,21 +1083,23 @@ static int get_uid_gid(int flag, const char *string)
 {
 	struct passwd *pw_ent;
 	struct group *grp_ent;
-	static const char *msg;
+	const char *msg;
 
-	if (ENABLE_DEVFSD_VERBOSE)
-		msg = "user";
-
-	if (isdigit(string[0]) ||((string[0] == '-') && isdigit(string[1])))
+	if (isdigit(string[0]) || ((string[0] == '-') && isdigit(string[1])))
 		return atoi(string);
 
 	if (flag == UID && (pw_ent = getpwnam(string)) != NULL)
 		return pw_ent->pw_uid;
 
-	if (flag == GID && (grp_ent = getgrnam(string)) != NULL)
-		return grp_ent->gr_gid;
-	else if (ENABLE_DEVFSD_VERBOSE)
-		msg = "group";
+	if (ENABLE_DEVFSD_VERBOSE)
+		msg = "user";
+
+	if (flag == GID) {
+		if ((grp_ent = getgrnam(string)) != NULL)
+			return grp_ent->gr_gid;
+		if (ENABLE_DEVFSD_VERBOSE)
+			msg = "group";
+	}
 
 	if (ENABLE_DEVFSD_VERBOSE)
 		msg_logger(LOG_ERR, "unknown %s: %s, defaulting to %cid=0",  msg, string, msg[0]);


More information about the busybox-cvs mailing list