From: Florian Fainelli Date: Sat, 15 Jul 2017 17:59:51 +0000 (-0700) Subject: upgraded: Check chroot() return value X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fprocd.git;a=commitdiff_plain;h=13f252f39d2f870d01884d1b0cf0a91a1a669d03 upgraded: Check chroot() return value 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 Signed-off-by: Florian Fainelli --- diff --git a/upgraded/upgraded.c b/upgraded/upgraded.c index 09c623c..220da79 100644 --- a/upgraded/upgraded.c +++ b/upgraded/upgraded.c @@ -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));