examples:smbclient:write: fix O3 error unused result of fgets
authorMichael Adam <obnox@samba.org>
Tue, 5 Apr 2016 21:07:11 +0000 (23:07 +0200)
committerMichael Adam <obnox@samba.org>
Thu, 12 May 2016 22:16:17 +0000 (00:16 +0200)
Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Christian Ambach <ambi@samba.org>
examples/libsmbclient/testwrite.c

index 636cb2046de126f66c5768de937994c110335655..1837839d298127bbe6b21710ca34d18a6b676336 100644 (file)
@@ -22,14 +22,22 @@ int main(int argc, char * argv[])
     
     printf("CAUTION: This program will overwrite a file.  "
            "Press ENTER to continue.");
-    fgets(buffer, sizeof(buffer), stdin);
+    p = fgets(buffer, sizeof(buffer), stdin);
+    if (p == NULL) {
+        fprintf(stderr, "failed to read from stdin\n");
+        return 1;
+    }
            
 
     for (;;)
     {
         fprintf(stdout, "\nPath: ");
         *path = '\0';
-        fgets(path, sizeof(path) - 1, stdin);
+        p = fgets(path, sizeof(path) - 1, stdin);
+        if (p == NULL) {
+            fprintf(stderr, "failed to read from stdin\n");
+            return 1;
+        }
         if (strlen(path) == 0)
         {
             return 0;