[LEDE-DEV] [PATCH procd v3 2/2] upgraded: Check chroot() return value

Florian Fainelli f.fainelli at gmail.com
Wed Jul 19 08:24:33 PDT 2017


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")
Signed-off-by: Florian Fainelli <f.fainelli at gmail.com>
---
 upgraded/upgraded.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/upgraded/upgraded.c b/upgraded/upgraded.c
index 09c623cf804b..220da7903f92 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));
-- 
2.11.0




More information about the Lede-dev mailing list