upgraded: Check chroot() return value
authorFlorian Fainelli <f.fainelli@gmail.com>
Sat, 15 Jul 2017 17:59:51 +0000 (10:59 -0700)
committerFlorian Fainelli <f.fainelli@gmail.com>
Thu, 20 Jul 2017 15:31:37 +0000 (08:31 -0700)
Check the chroot() return value, fixes unused return value warnings/errors:

procd-2017-06-22-e5e99c46/upgraded/upgraded.c:78:8: error: ignoring return
value of 'chroot', declared with attribute warn_unused_result
[-Werror=unused-result] chroot(".");

Fixes: 056d8ddda8d5 ("upgraded: link dynamically, chroot during exec")
Reviewed-by: Matthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
upgraded/upgraded.c

index 09c623cf804b43c826190300a40e2c4bf9aabfa3..220da7903f92f65554c2d4c978691a1cd30cdca4 100644 (file)
@@ -78,7 +78,10 @@ int main(int argc, char **argv)
                return 1;
        }
 
-       chroot(".");
+       if (chroot(".") < 0) {
+               fprintf(stderr, "failed to chroot: %s\n", strerror(errno));
+               return 1;
+       }
 
        if (fchdir(fd) == -1) {
                fprintf(stderr, "failed to chdir to prefix directory: %s\n", strerror(errno));