Code

unit tests: Fixed some -Werror=unused-result compiler errors.
authorSebastian Harl <sh@tokkee.org>
Fri, 1 Aug 2014 18:35:31 +0000 (20:35 +0200)
committerSebastian Harl <sh@tokkee.org>
Fri, 1 Aug 2014 18:35:31 +0000 (20:35 +0200)
t/unit/frontend/connection_test.c
t/unit/frontend/sock_test.c

index a38c262c3febeba6715b884245d343e15acb92c3..ea933233d2f8bf9e21611a761b0ecc4a7f20e35f 100644 (file)
@@ -113,8 +113,12 @@ mock_conn_rewind(sdb_conn_t *conn)
 static void
 mock_conn_truncate(sdb_conn_t *conn)
 {
+       int status;
        lseek(conn->fd, 0, SEEK_SET);
-       ftruncate(conn->fd, 0);
+       status = ftruncate(conn->fd, 0);
+       fail_unless(status == 0,
+                       "INTERNAL ERROR: ftruncate(%d, 0) = %d; expected: 0",
+                       conn->fd, status);
 } /* mock_conn_truncate */
 
 static int
@@ -207,8 +211,9 @@ START_TEST(test_conn_accept)
        fail_unless(conn == NULL,
                        "sdb_connection_accept(-1) = %p; expected: NULL", conn);
 
-       mkstemp(socket_path);
+       fd = mkstemp(socket_path);
        unlink(socket_path);
+       close(fd);
 
        fd = mock_unixsock_listener(socket_path);
        check = pthread_create(&thr, /* attr = */ NULL, mock_client, socket_path);
index 09f8ae91cc597341b2d186643f790ef697d9451d..be2c46d5536a7b455275883685327852eedbc348 100644 (file)
@@ -111,7 +111,7 @@ START_TEST(test_listen_and_serve)
 
        pthread_t thr;
 
-       int sock_fd;
+       int fd, sock_fd;
        struct sockaddr_un sa;
 
        check = sdb_fe_sock_listen_and_serve(sock, &loop);
@@ -119,8 +119,9 @@ START_TEST(test_listen_and_serve)
                        "sdb_fe_sock_listen_and_serve() = %i; "
                        "expected: <0 (before adding listeners)", check);
 
-       mkstemp(tmp_file);
+       fd = mkstemp(tmp_file);
        unlink(tmp_file);
+       close(fd);
        sock_listen(tmp_file);
 
        loop.do_loop = 1;