tests/auth/keys-t.c: Don’t ignore return value of write
authorAnders Kaseorg <andersk@mit.edu>
Sat, 1 Aug 2015 03:26:43 +0000 (23:26 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Wed, 26 Aug 2015 03:53:51 +0000 (23:53 -0400)
Resolves this warning:

keys-t.c: In function ‘copy’:
keys-t.c:63:6: warning: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Wunused-result]
      write(out, block, len);
      ^

Change-Id: If2427f2658b428091ffba3d11643ad95f193a67d
Reviewed-on: http://gerrit.openafs.org/11957
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

tests/auth/keys-t.c

index 5c483c5..789b49b 100644 (file)
@@ -45,8 +45,9 @@ static int
 copy(char *inFile, char *outFile)
 {
     int in, out;
-    char *block;
-    size_t len;
+    char *block, *block_out;
+    ssize_t len;
+    size_t len_out;
 
     in = open(inFile, O_RDONLY);
     if (in<0)
@@ -59,8 +60,17 @@ copy(char *inFile, char *outFile)
     block = malloc(1024);
     do {
        len = read(in, block, 1024);
-       if (len > 0)
-           write(out, block, len);
+       if (len <= 0)
+           break;
+       len_out = len;
+       block_out = block;
+       do {
+           len = write(out, block_out, len_out);
+           if (len <= 0)
+               break;
+           block_out += len;
+           len_out -= len;
+       } while (len_out > 0);
     } while (len > 0);
     free(block);