ptr_valid: fix warn-unused-result warning (-O2)
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 25 Oct 2016 04:46:07 +0000 (15:16 +1030)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 25 Oct 2016 04:46:07 +0000 (15:16 +1030)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan/ptr_valid/ptr_valid.c

index ef95d34f39c7a145a2b0c3621c8c764ea65d140b..dc61dd27cbc1fbd46a06e73ad25d4c1bb6fb9848 100644 (file)
@@ -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);