Check the return code from fgets in memcapable
authorTrond Norbye <trond@ubuntu>
Tue, 24 Aug 2010 17:28:46 +0000 (19:28 +0200)
committerTrond Norbye <trond@ubuntu>
Tue, 24 Aug 2010 17:28:46 +0000 (19:28 +0200)
clients/memcapable.c

index e64655b98d2eba49ffe1d97eeaedcb203e032c96..6ef5bc69285028a3787ae14a98caf98418c54110 100644 (file)
@@ -1944,16 +1944,17 @@ int main(int argc, char **argv)
     {
       fprintf(stdout, "\nPress <return> when you are ready? ");
       char buffer[80] = {0};
-      (void)fgets(buffer, sizeof(buffer), stdin);
-      if (strncmp(buffer, "skip", 4) == 0)
-      {
-        fprintf(stdout, "%-40s%s\n", testcases[ii].description,
-                status_msg[TEST_SKIP]);
-        fflush(stdout);
-        continue;
+      if (fgets(buffer, sizeof(buffer), stdin) != NULL) {
+        if (strncmp(buffer, "skip", 4) == 0)
+        {
+          fprintf(stdout, "%-40s%s\n", testcases[ii].description,
+                  status_msg[TEST_SKIP]);
+          fflush(stdout);
+          continue;
+        }
+        if (strncmp(buffer, "quit", 4) == 0)
+          exit(0);
       }
-      if (strncmp(buffer, "quit", 4) == 0)
-        exit(0);
 
       fprintf(stdout, "%-40s", testcases[ii].description);
       fflush(stdout);