[CRIU] [PATCH] chdir: need to check return value

Tikhomirov Pavel snorcht at gmail.com
Tue Feb 4 01:40:42 PST 2014


otherwise it won't compile:

util.c: In function ‘cr_daemon’:
util.c:594:8: error: ignoring return value of ‘chdir’, declared
with attribute warn_unused_result [-Werror=unused-result]
   chdir("/");
        ^

Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
---
 util.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/util.c b/util.c
index 38d8dd9..4304a91 100644
--- a/util.c
+++ b/util.c
@@ -591,7 +591,8 @@ int cr_daemon(int nochdir, int noclose)
 
 	setsid();
 	if (!nochdir)
-		chdir("/");
+		if (chdir("/") == -1)
+			pr_perror("Can't change directory");
 	if (!noclose) {
 		int fd;
 
-- 
1.8.3.2



More information about the CRIU mailing list