Browse Source

Check the return value from an fwrite()

This fixes the following warning, which was mentioned in issue #44:
docsis.c:576: warning: ignoring return value of ‘fwrite’, declared with attribute warn_unused_result
Richard Laager 9 years ago
parent
commit
965831e962
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/docsis.c

+ 5 - 1
src/docsis.c

@@ -573,7 +573,11 @@ int encode_one_file ( char *input_file, char *output_file,
       fprintf (stderr, "docsis: error: can't open output file %s\n", output_file);
       return -2;
     }
-  fwrite (buffer, sizeof (unsigned char), buflen, of);
+  if (fwrite (buffer, 1, buflen, of) != buflen)
+    {
+      fprintf (stderr, "docsis: error: can't write to output file %s\n", output_file);
+      return -2;
+    }
   fclose (of);
   free(buffer);
   return 0;