lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 20 Jul 2013 21:58:18 +0200
From:	Christoph Paasch <christoph.paasch@...ouvain.be>
To:	Stephen Hemminger <stephen@...workplumber.org>
Cc:	netdev@...r.kernel.org
Subject: [PATCH iproute2 2/2] lnstat: Fix compiler errors of unused return-values

Many errors when compiling with gcc 4.7.3 about unused return-values
upon the calls to fgets:

lnstat_util.c: In function ‘lnstat_scan_fields’:
lnstat_util.c:145:7: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
lnstat_util.c: In function ‘lnstat_update’:
lnstat_util.c:97:10: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
lnstat_util.c:111:9: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
lnstat_util.c: In function ‘scan_lines’:
lnstat_util.c:52:8: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
cc1: all warnings being treated as errors
make[1]: *** [lnstat_util.o] Error 1
make[1]: Leaving directory `/home/christoph/workspace/linux/iproute2/misc'
make: *** [all] Error 2

Signed-off-by: Christoph Paasch <christoph.paasch@...ouvain.be>
---
 misc/lnstat_util.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/misc/lnstat_util.c b/misc/lnstat_util.c
index 9492baf..103c05d 100644
--- a/misc/lnstat_util.c
+++ b/misc/lnstat_util.c
@@ -49,7 +49,8 @@ static int scan_lines(struct lnstat_file *lf, int i)
 
 		num_lines++;
 
-		fgets(buf, sizeof(buf)-1, lf->fp);
+		if (!fgets(buf, sizeof(buf)-1, lf->fp))
+			return num_lines;
 		gettimeofday(&lf->last_read, NULL);
 
 		for (j = 0; j < lf->num_fields; j++) {
@@ -94,7 +95,8 @@ int lnstat_update(struct lnstat_file *lnstat_files)
 			rewind(lf->fp);
 			if (!lf->compat) {
 				/* skip first line */
-				fgets(buf, sizeof(buf)-1, lf->fp);
+				if (!fgets(buf, sizeof(buf)-1, lf->fp))
+					return 0;
 			}
 			scan_lines(lf, 1);
 
@@ -108,7 +110,8 @@ int lnstat_update(struct lnstat_file *lnstat_files)
 			}
 
 			rewind(lf->fp);
-			fgets(buf, sizeof(buf)-1, lf->fp);
+			if (!fgets(buf, sizeof(buf)-1, lf->fp))
+				return 0;
 			scan_lines(lf, 0);
 		}
 	}
@@ -142,7 +145,8 @@ static int lnstat_scan_fields(struct lnstat_file *lf)
 	char buf[FGETS_BUF_SIZE];
 
 	rewind(lf->fp);
-	fgets(buf, sizeof(buf)-1, lf->fp);
+	if (!fgets(buf, sizeof(buf)-1, lf->fp))
+		return -1;
 
 	return __lnstat_scan_fields(lf, buf);
 }
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ