summaryrefslogtreecommitdiff
path: root/tests/tcg/testthread.c
diff options
context:
space:
mode:
authorCatalin Patulea <catalinp@google.com>2012-10-29 14:01:07 -0400
committerBlue Swirl <blauwirbel@gmail.com>2012-10-30 18:55:02 +0000
commitf71d61216ea8eb914ee79459a58dc5343d95ddec (patch)
treec98ed8eedba172e87fcabcaae6c9d275d85cfe54 /tests/tcg/testthread.c
parenta1d29d6c1d4002a5c7b19eda61d794f4c22538dd (diff)
downloadqemu-f71d61216ea8eb914ee79459a58dc5343d95ddec.tar.gz
qemu-f71d61216ea8eb914ee79459a58dc5343d95ddec.tar.bz2
qemu-f71d61216ea8eb914ee79459a58dc5343d95ddec.zip
tests/tcg: fix unused result warnings
With i386-linux-user target on x86_64 host, this does not introduce any new test failures. Signed-off-by: Catalin Patulea <catalinp@google.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Diffstat (limited to 'tests/tcg/testthread.c')
-rw-r--r--tests/tcg/testthread.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/tcg/testthread.c b/tests/tcg/testthread.c
index 27e4825bc6..2679af119a 100644
--- a/tests/tcg/testthread.c
+++ b/tests/tcg/testthread.c
@@ -1,3 +1,4 @@
+#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -8,6 +9,12 @@
#include <sys/wait.h>
#include <sched.h>
+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;