[pisa-src] r1313 - trunk/libpisa/pisaconf.c

  • From: Thomas Jansen <mithi@xxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Tue, 27 Oct 2009 14:17:14 +0100

Author: tjansen
Date: Tue Oct 27 14:17:14 2009
New Revision: 1313

Log:
Fixed warning:

pisaconf.c: In function ‘pisa_conf_read_file’:
pisaconf.c:398: warning: ignoring return value of ‘fgets’, declared with 
attribute warn_unused_result

Modified:
   trunk/libpisa/pisaconf.c

Modified: trunk/libpisa/pisaconf.c
==============================================================================
--- trunk/libpisa/pisaconf.c    Tue Oct 27 14:02:44 2009        (r1312)
+++ trunk/libpisa/pisaconf.c    Tue Oct 27 14:17:14 2009        (r1313)
@@ -385,7 +385,7 @@
 void pisa_conf_read_file(char *filename, pisa_conf_parse_cb parse)
 {
        FILE *f;
-       char buffer[1024], *argv[64], *end;
+       char buffer[1024] = "", *argv[64], *end;
        int argc;
 
        assert(filename);
@@ -393,16 +393,15 @@
        if (!f)
                return;
 
-       while (!feof(f)) {
-               buffer[0] = '\0';
-               fgets(buffer, sizeof(buffer), f);
+       while (fgets(buffer, sizeof(buffer), f)) {
                for (end = buffer; *end; end++);
                if (buffer == end)
-                       break;
+                       continue;
                *(end - 1) = '\0';
                pisa_conf_tokenize_line(buffer, &argc, argv);
                if (argc > 0)
                        parse(argc, argv);
+               buffer[0] = '\0';
        }
 
        fclose(f);

Other related posts:

  • » [pisa-src] r1313 - trunk/libpisa/pisaconf.c - Thomas Jansen