Browse Source

ptr_valid: fix warn-unused-result warning (-O2)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell 9 years ago
parent
commit
ca8bfcc49a
1 changed files with 8 additions and 3 deletions
  1. 8 3
      ccan/ptr_valid/ptr_valid.c

+ 8 - 3
ccan/ptr_valid/ptr_valid.c

@@ -246,9 +246,14 @@ static bool check_with_child(struct ptr_valid_batch *batch,
 			return false;
 	}
 
-	write(batch->to_child, &p, sizeof(p));
-	write(batch->to_child, &size, sizeof(size));
-	write(batch->to_child, &is_write, sizeof(is_write));
+	if (write(batch->to_child, &p, sizeof(p))
+	    + write(batch->to_child, &size, sizeof(size))
+	    + write(batch->to_child, &is_write, sizeof(is_write))
+	    != sizeof(p) + sizeof(size) + sizeof(is_write)) {
+		finish_child(batch);
+		errno = EFAULT;
+		return false;
+	}
 
 	if (read(batch->from_child, &ret, sizeof(ret)) != sizeof(ret)) {
 		finish_child(batch);