Browse Source

Fix unused result in fgets warning

Renato Golin 13 years ago
parent
commit
34f2476279
4 changed files with 13 additions and 10 deletions
  1. 2 2
      ecl/eclplus/main.cpp
  2. 5 4
      esp/tools/soapplus/http.cpp
  3. 5 2
      system/jlib/jdebug.cpp
  4. 1 2
      system/security/test/myssl/main.cpp

+ 2 - 2
ecl/eclplus/main.cpp

@@ -127,8 +127,8 @@ void promptFor(const char *prompt, const char *prop, bool hide, IProperties * gl
     else
     {
         char buf[100];
-        fgets(buf, 100, stdin);
-        result.append(buf);
+        if (fgets(buf, 100, stdin))
+            result.append(buf);
         if (result.length() && result.charAt(result.length()-1)=='\n')
             result.remove(result.length()-1, 1);
     }

+ 5 - 4
esp/tools/soapplus/http.cpp

@@ -640,10 +640,11 @@ void HttpClient::start()
             if(!(m_globals && m_globals->getPropBool("useDefault")))
             {
                 fprintf(stderr, "Pick one method, or just press enter to generate a request for each method:\n");
-                fgets(seqbuf, 19, stdin);
-                while(ind < 19 && seqbuf[ind] != '\0' && isdigit(seqbuf[ind]))
-                    ind++;
-                seqbuf[ind] = 0;
+                if (fgets(seqbuf, 19, stdin)) {
+                    while(ind < 19 && seqbuf[ind] != '\0' && isdigit(seqbuf[ind]))
+                        ind++;
+                    seqbuf[ind] = 0;
+                }
             }
             if(ind > 0)
             {

+ 5 - 2
system/jlib/jdebug.cpp

@@ -1498,8 +1498,11 @@ class CExtendedStats  // Disk network and cpu stats
         if (!netfp)
             return false;
         char ln[512];
-        fgets(ln, sizeof(ln), netfp);   
-        fgets(ln, sizeof(ln), netfp);
+        // Read two lines
+        if (!fgets(ln, sizeof(ln), netfp) || !fgets(ln, sizeof(ln), netfp)) {
+            fclose(netfp);
+            return false;
+        }
         unsigned txskip = 2;
         bool hasbyt = false;
         if (strstr(ln,"compressed")) {

+ 1 - 2
system/security/test/myssl/main.cpp

@@ -26,8 +26,7 @@
 
 char *myfgets(char *s, int size, FILE *stream)
 {
-    fgets(s, size, stream);
-    int len = strlen(s);
+    int len = strlen(fgets(s, size, stream));
     if(len > 0)
         s[len - 1] = '\0';