From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSjQq-0000GS-DL for qemu-devel@nongnu.org; Mon, 29 Oct 2012 03:06:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TSjQp-0001ED-2M for qemu-devel@nongnu.org; Mon, 29 Oct 2012 03:06:44 -0400 Received: from mail-ia0-f173.google.com ([209.85.210.173]:46908) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TSjQo-0001E1-SG for qemu-devel@nongnu.org; Mon, 29 Oct 2012 03:06:42 -0400 Received: by mail-ia0-f173.google.com with SMTP id m10so3908450iam.4 for ; Mon, 29 Oct 2012 00:06:41 -0700 (PDT) From: Catalin Patulea Date: Mon, 29 Oct 2012 03:06:28 -0400 Message-Id: <1351494388-28583-1-git-send-email-catalinp@google.com> In-Reply-To: <1350947915-8213-1-git-send-email-catalinp@google.com> References: <1350947915-8213-1-git-send-email-catalinp@google.com> Subject: [Qemu-devel] [PATCH] tests/tcg: fix unused result warnings List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Catalin Patulea With i386-linux-user target on x86_64 host, this does not introduce any new test failures. Signed-off-by: Catalin Patulea --- tests/tcg/test-mmap.c | 15 +++++++++++---- tests/tcg/testthread.c | 11 +++++++++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/tcg/test-mmap.c b/tests/tcg/test-mmap.c index c418b67..d6d8288 100644 --- a/tests/tcg/test-mmap.c +++ b/tests/tcg/test-mmap.c @@ -22,6 +22,7 @@ * along with this program; if not, see . */ +#include #include #include #include @@ -429,6 +430,12 @@ void check_file_fixed_mmaps(void) fprintf (stderr, " passed\n"); } +void checked_write(int fd, const void *buf, size_t count) +{ + ssize_t rc = write (fd, buf, count); + fail_unless(rc == count); +} + int main(int argc, char **argv) { char tempname[] = "/tmp/.cmmapXXXXXX"; @@ -451,12 +458,12 @@ int main(int argc, char **argv) /* Fill the file with int's counting from zero and up. */ for (i = 0; i < (pagesize * 4) / sizeof i; i++) - write (test_fd, &i, sizeof i); + checked_write (test_fd, &i, sizeof i); /* Append a few extra writes to make the file end at non page boundary. */ - write (test_fd, &i, sizeof i); i++; - write (test_fd, &i, sizeof i); i++; - write (test_fd, &i, sizeof i); i++; + checked_write (test_fd, &i, sizeof i); i++; + checked_write (test_fd, &i, sizeof i); i++; + checked_write (test_fd, &i, sizeof i); i++; test_fsize = lseek(test_fd, 0, SEEK_CUR); diff --git a/tests/tcg/testthread.c b/tests/tcg/testthread.c index 27e4825..2679af1 100644 --- a/tests/tcg/testthread.c +++ b/tests/tcg/testthread.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -8,6 +9,12 @@ #include #include +void checked_write(int fd, const void *buf, size_t count) +{ + ssize_t rc = write(fd, buf, count); + assert(rc == count); +} + void *thread1_func(void *arg) { int i; @@ -15,7 +22,7 @@ void *thread1_func(void *arg) for(i=0;i<10;i++) { snprintf(buf, sizeof(buf), "thread1: %d %s\n", i, (char *)arg); - write(1, buf, strlen(buf)); + checked_write(1, buf, strlen(buf)); usleep(100 * 1000); } return NULL; @@ -27,7 +34,7 @@ void *thread2_func(void *arg) char buf[512]; for(i=0;i<20;i++) { snprintf(buf, sizeof(buf), "thread2: %d %s\n", i, (char *)arg); - write(1, buf, strlen(buf)); + checked_write(1, buf, strlen(buf)); usleep(150 * 1000); } return NULL; -- 1.7.7.3