Explorar o código

user: Only declare variables in the beginning

Aaron Marcher %!s(int64=7) %!d(string=hai) anos
pai
achega
709549b4bd
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      components/user.c

+ 2 - 2
components/user.c

@@ -17,9 +17,9 @@ gid(void)
 const char *
 username(void)
 {
-	struct passwd *pw = getpwuid(geteuid());
+	struct passwd *pw;
 
-	if (pw == NULL) {
+	if (!(pw = getpwuid(geteuid()))) {
 		fprintf(stderr, "getpwuid '%d': %s\n", geteuid(), strerror(errno));
 		return NULL;
 	}