Browse Source

procd: fix compiler warning

[ 37%] Building C object CMakeFiles/procd.dir/state.c.o
/projects/procd/state.c: In function ‘state_enter’:
/projects/procd/state.c:147:4: error: ignoring return value of ‘chown’, declared with attribute warn_unused_result [-Werror=unused-result]
  147 |    chown(p->pw_dir, p->pw_uid, p->pw_gid);
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/procd.dir/build.make:89: CMakeFiles/procd.dir/state.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:241: CMakeFiles/procd.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Signed-off-by: John Crispin <john@phrozen.org>
John Crispin 2 months ago
parent
commit
d6dda317db
1 changed files with 4 additions and 1 deletions
  1. 4 1
      state.c

+ 4 - 1
state.c

@@ -142,9 +142,12 @@ static void state_enter(void)
 		set_stdio("console");
 		p = getpwnam("ubus");
 		if (p) {
+			int ret;
 			LOG("- ubus -\n");
 			mkdir(p->pw_dir, 0755);
-			chown(p->pw_dir, p->pw_uid, p->pw_gid);
+			ret = chown(p->pw_dir, p->pw_uid, p->pw_gid);
+			if (ret)
+				LOG("- ubus - failed to chown(%s)\n", p->pw_dir);
 		} else {
 			LOG("- ubus (running as root!) -\n");
 		}