ctdb-tests: Check result of write() in ARP and TCP tests
authorMartin Schwenke <martin@meltin.net>
Wed, 5 Sep 2018 02:42:07 +0000 (12:42 +1000)
committerAmitay Isaacs <amitay@samba.org>
Thu, 6 Sep 2018 06:33:59 +0000 (08:33 +0200)
CTDB -O3 --picky-developer build is failing.  Not sure how this
slipped through.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Thu Sep  6 08:33:59 CEST 2018 on sn-devel-144

ctdb/tests/src/system_socket_test.c

index 6dd9e432ef7fddb999fef64a781beb99ca33bf77..f7d0c7c7701f2300475fe73ebc381b258e97c552 100644 (file)
@@ -59,6 +59,7 @@ static void test_arp(const char *addr_str, const char *hwaddr_str, bool reply)
        uint8_t buf[512];
        size_t buflen = sizeof(buf);
        size_t len;
+       ssize_t num_written;
        int ret;
 
        ret = ctdb_sock_addr_from_string(addr_str, &addr, false);
@@ -80,7 +81,8 @@ static void test_arp(const char *addr_str, const char *hwaddr_str, bool reply)
 
        assert(ret == 0);
 
-       write(STDOUT_FILENO, buf, len);
+       num_written = write(STDOUT_FILENO, buf, len);
+       assert(num_written == len);
 }
 
 #else /* HAVE_PACKETSOCKET  */
@@ -104,6 +106,7 @@ static void test_tcp(const char *src_str,
        uint8_t buf[512];
        struct ether_header *eth;
        size_t expected_len, len;
+       ssize_t num_written;
        char src_str_out[64], dst_str_out[64];
        uint32_t seq_out, ack_out;
        int rst_out;
@@ -156,7 +159,10 @@ static void test_tcp(const char *src_str,
        assert(ret == 0);
        assert(len == expected_len);
 
-       write(STDOUT_FILENO, buf + sizeof(struct ether_header), len);
+       num_written = write(STDOUT_FILENO,
+                           buf + sizeof(struct ether_header),
+                           len);
+       assert(num_written == len);
 
        switch (ntohs(eth->ether_type)) {
        case ETHERTYPE_IP: