procd: fix compiler warning
authorJohn Crispin <[email protected]>
Tue, 26 Jan 2021 10:19:10 +0000 (11:19 +0100)
committerJohn Crispin <[email protected]>
Tue, 26 Jan 2021 10:19:10 +0000 (11:19 +0100)
[ 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 <[email protected]>
state.c

diff --git a/state.c b/state.c
index 44f56c6ea5bd533c4c1db032a330c7dbd2326785..fb81248fd7e7bc7b588a82a5e667424af188cbab 100644 (file)
--- a/state.c
+++ b/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");
                }