]> err.no Git - util-linux/commitdiff
swapon: clean up gcc warnings
authorRandy Dunlap <randy.dunlap@oracle.com>
Wed, 3 Oct 2007 21:15:32 +0000 (14:15 -0700)
committerKarel Zak <kzak@redhat.com>
Wed, 10 Oct 2007 21:39:06 +0000 (23:39 +0200)
Fix strict gcc warnings in tailf that come from using:
  ("-Wall -Wp,-D_FORTIFY_SOURCE=2")

swapon.c:102: warning: ignoring return value of 'fgets', declared with attribute warn_unused_result

Builds cleanly on x86_32 and x86_64.

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
mount/swapon.c

index ed91afc0c2ce0b2532d8e9d12b20d3c76affcdfd..84b047da26adf093a5754d58fd5e912d0fcf40ac 100644 (file)
@@ -99,8 +99,12 @@ read_proc_swaps(void) {
                return;         /* nothing wrong */
 
        /* skip the first line */
-       fgets(line, sizeof(line), swaps);
-
+       if (!fgets(line, sizeof(line), swaps)) {
+               fprintf (stderr, _("%s: %s: unexpected file format\n"),
+                       progname, PROC_SWAPS);
+               fclose(swaps);
+               return;
+       }
        while (fgets(line, sizeof(line), swaps)) {
                /*
                 * Cut the line "swap_device  ... more info" after device.