[LEDE-DEV] [PATCH mountd 1/5] mountd: Fix unused results warnings in autofs.c for chdir()

Florian Fainelli f.fainelli at gmail.com
Sun Mar 5 16:50:12 PST 2017


Fixes the following warnings:

mountd-2016-12-19-dd5799c9/autofs.c: In function 'autofs_loop':
mountd-2016-12-19-dd5799c9/autofs.c:227:7: error: ignoring return value of 'chdir', declared with attribute warn_unused_result [-Werror=unused-result]
  chdir("/");
       ^
mountd-2016-12-19-dd5799c9/autofs.c: In function 'autofs_process_request':
mountd-2016-12-19-dd5799c9/autofs.c:100:7: error: ignoring return value of 'chdir', declared with attribute warn_unused_result [-Werror=unused-result]
  chdir("/tmp/run/mountd/");
       ^
mountd-2016-12-19-dd5799c9/autofs.c:112:7: error: ignoring return value of 'chdir', declared with attribute warn_unused_result [-Werror=unused-result]
  chdir("/");

Signed-off-by: Florian Fainelli <f.fainelli at gmail.com>
---
 autofs.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/autofs.c b/autofs.c
index 8c69cbea5c76..f77b929ab7ce 100644
--- a/autofs.c
+++ b/autofs.c
@@ -95,9 +95,12 @@ static void send_fail(unsigned int wait_queue_token)
 
 static int autofs_process_request(const struct autofs_v5_packet *pkt)
 {
+	int ret;
 	struct stat st;
 	log_printf("kernel is requesting a mount -> %s\n", pkt->name);
-	chdir("/tmp/run/mountd/");
+	ret = chdir("/tmp/run/mountd/");
+	if (ret < 0)
+		return ret;
 	if (lstat(pkt->name, &st) == -1 || (S_ISDIR(st.st_mode) && st.st_dev == dev)) {
 		if(!mount_new("/tmp/run/mountd/", (char*)pkt->name))
 		{
@@ -109,9 +112,7 @@ static int autofs_process_request(const struct autofs_v5_packet *pkt)
 	} else {
 		send_ready(pkt->wait_queue_token);
 	}
-	chdir("/");
-
-	return 0;
+	return chdir("/");
 }
 
 static void expire_proc(void)
@@ -224,7 +225,10 @@ static void autofs_init(void)
 
 int autofs_loop(void)
 {
-	chdir("/");
+	int ret;
+	ret = chdir("/");
+	if (ret < 0)
+		return 1;
 	autofs_init();
 	while(1)
 	{
@@ -234,9 +238,11 @@ int autofs_loop(void)
 			continue;
 		}
 		log_printf("Got a autofs packet\n");
-		if(pkt.hdr.type == autofs_ptype_missing_indirect)
-			autofs_process_request(&pkt.missing_indirect);
-		else
+		if(pkt.hdr.type == autofs_ptype_missing_indirect) {
+			ret = autofs_process_request(&pkt.missing_indirect);
+			if (ret < 0)
+				return 1;
+		} else
 			log_printf("unknown packet type %d\n", pkt.hdr.type);
 		poll(0, 0, 200);
 	}
-- 
2.9.3




More information about the Lede-dev mailing list