From: Catalin Patulea <catalinp@google.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Catalin Patulea <catalinp@google.com>
Subject: [Qemu-devel] [PATCHv2] tests/tcg: fix unused result warnings
Date: Mon, 29 Oct 2012 14:01:07 -0400 [thread overview]
Message-ID: <1351533667-7669-1-git-send-email-catalinp@google.com> (raw)
In-Reply-To: <CAFEAcA8=kKEnABRC5M5Ap6uRE_4E2YWJ4KRgRaycj-XN2-Zgeg@mail.gmail.com>
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>
---
v2:
- Fixes style issues from checkpatch.pl
- For some reason, the patch from the list wouldn't apply for me onto master on
a different machine. This grabs a new master from
git://git.qemu.org/qemu.git. Let me know if there are any issues.
tests/tcg/test-mmap.c | 18 +++++++++++++-----
tests/tcg/testthread.c | 11 +++++++++--
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/tests/tcg/test-mmap.c b/tests/tcg/test-mmap.c
index c418b67..3982fa2 100644
--- a/tests/tcg/test-mmap.c
+++ b/tests/tcg/test-mmap.c
@@ -429,6 +429,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";
@@ -450,13 +456,15 @@ int main(int argc, char **argv)
unlink(tempname);
/* 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);
+ for (i = 0; i < (pagesize * 4) / sizeof i; 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 <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;
--
1.7.7.3
next prev parent reply other threads:[~2012-10-29 18:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-22 23:18 [Qemu-devel] [PATCH] tests/tcg: fix a few warnings Catalin Patulea
2012-10-27 16:53 ` Blue Swirl
2012-10-29 7:06 ` [Qemu-devel] [PATCH] tests/tcg: fix unused result warnings Catalin Patulea
2012-10-29 8:38 ` Peter Maydell
2012-10-29 18:01 ` Catalin Patulea [this message]
2012-10-30 21:08 ` [Qemu-devel] [PATCHv2] " Blue Swirl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1351533667-7669-1-git-send-email-catalinp@google.com \
--to=catalinp@google.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).