[Pkg-wmaker-commits] [wmifs] 20/118: wmifs: Use result of fgets.
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Thu Aug 27 02:37:47 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to branch master
in repository wmifs.
commit 56a023fd24572180386360d4b2a279c511bd2f00
Author: Doug Torrance <dtorrance at monmouthcollege.edu>
Date: Wed Oct 22 16:34:49 2014 -0500
wmifs: Use result of fgets.
Remove several compiler warnings of the form
wmifs.c:666:7: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
fgets(temp, BUFFER_SIZE, fp);
^
---
wmifs/wmifs.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/wmifs/wmifs.c b/wmifs/wmifs.c
index a0abaff..2d04aa0 100644
--- a/wmifs/wmifs.c
+++ b/wmifs/wmifs.c
@@ -664,8 +664,14 @@ int get_statistics(char *devname, long *ip, long *op, long *is, long *os)
/* Read from /proc/net/dev the stats! */
fp = fopen("/proc/net/dev", "r");
- fgets(temp, BUFFER_SIZE, fp);
- fgets(temp, BUFFER_SIZE, fp);
+ if (!fgets(temp, BUFFER_SIZE, fp)) {
+ fclose(fp);
+ return -1;
+ }
+ if (!fgets(temp, BUFFER_SIZE, fp)) {
+ fclose(fp);
+ return -1;
+ }
input = -1;
output = -1;
@@ -757,8 +763,14 @@ int checknetdevs(void)
fd = fopen("/proc/net/dev", "r");
if (fd) {
/* Skip the first 2 lines */
- fgets(temp, BUFFER_SIZE, fd);
- fgets(temp, BUFFER_SIZE, fd);
+ if (!fgets(temp, BUFFER_SIZE, fd)) {
+ fclose(fd);
+ return -1;
+ }
+ if (!fgets(temp, BUFFER_SIZE, fd)) {
+ fclose(fd);
+ return -1;
+ }
while (fgets(temp, BUFFER_SIZE, fd)) {
p = strtok(temp, tokens);
if (p == NULL) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmifs.git
More information about the Pkg-wmaker-commits
mailing list