* [Qemu-devel] [PATCH] tests/tcg: fix a few warnings
@ 2012-10-22 23:18 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
0 siblings, 2 replies; 6+ messages in thread
From: Catalin Patulea @ 2012-10-22 23:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Catalin Patulea
Signed-off-by: Catalin Patulea <catalinp@google.com>
---
This leaves a few of these:
warning: ignoring return value of 'write', declared with attribute warn_unused_result
How interesting is it to fix these? (Perhaps by asserting that the full write completed?)
tests/tcg/hello-i386.c | 3 ++-
tests/tcg/test-i386.c | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/tests/tcg/hello-i386.c b/tests/tcg/hello-i386.c
index 86afc34..fa00380 100644
--- a/tests/tcg/hello-i386.c
+++ b/tests/tcg/hello-i386.c
@@ -1,6 +1,6 @@
#include <asm/unistd.h>
-static inline volatile void exit(int status)
+static inline void exit(int status)
{
int __res;
__asm__ volatile ("movl %%ecx,%%ebx\n"\
@@ -17,6 +17,7 @@ static inline int write(int fd, const char * buf, int len)
"popl %%ebx\n"\
: "=a" (status) \
: "0" (__NR_write),"S" ((long)(fd)),"c" ((long)(buf)),"d" ((long)(len)));
+ return status;
}
void _start(void)
diff --git a/tests/tcg/test-i386.c b/tests/tcg/test-i386.c
index 64d929e..40392ac 100644
--- a/tests/tcg/test-i386.c
+++ b/tests/tcg/test-i386.c
@@ -785,7 +785,7 @@ void fpu_clear_exceptions(void)
long double fpregs[8];
} float_env32;
- asm volatile ("fnstenv %0\n" : : "m" (float_env32));
+ asm volatile ("fnstenv %0\n" : "=m" (float_env32));
float_env32.fpus &= ~0x7f;
asm volatile ("fldenv %0\n" : : "m" (float_env32));
}
--
1.7.7.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] tests/tcg: fix a few warnings
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
1 sibling, 0 replies; 6+ messages in thread
From: Blue Swirl @ 2012-10-27 16:53 UTC (permalink / raw)
To: Catalin Patulea; +Cc: qemu-devel
Thanks, applied.
On Mon, Oct 22, 2012 at 11:18 PM, Catalin Patulea <catalinp@google.com> wrote:
>
> Signed-off-by: Catalin Patulea <catalinp@google.com>
> ---
> This leaves a few of these:
> warning: ignoring return value of 'write', declared with attribute warn_unused_result
>
> How interesting is it to fix these? (Perhaps by asserting that the full write completed?)
>
> tests/tcg/hello-i386.c | 3 ++-
> tests/tcg/test-i386.c | 2 +-
> 2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tests/tcg/hello-i386.c b/tests/tcg/hello-i386.c
> index 86afc34..fa00380 100644
> --- a/tests/tcg/hello-i386.c
> +++ b/tests/tcg/hello-i386.c
> @@ -1,6 +1,6 @@
> #include <asm/unistd.h>
>
> -static inline volatile void exit(int status)
> +static inline void exit(int status)
> {
> int __res;
> __asm__ volatile ("movl %%ecx,%%ebx\n"\
> @@ -17,6 +17,7 @@ static inline int write(int fd, const char * buf, int len)
> "popl %%ebx\n"\
> : "=a" (status) \
> : "0" (__NR_write),"S" ((long)(fd)),"c" ((long)(buf)),"d" ((long)(len)));
> + return status;
> }
>
> void _start(void)
> diff --git a/tests/tcg/test-i386.c b/tests/tcg/test-i386.c
> index 64d929e..40392ac 100644
> --- a/tests/tcg/test-i386.c
> +++ b/tests/tcg/test-i386.c
> @@ -785,7 +785,7 @@ void fpu_clear_exceptions(void)
> long double fpregs[8];
> } float_env32;
>
> - asm volatile ("fnstenv %0\n" : : "m" (float_env32));
> + asm volatile ("fnstenv %0\n" : "=m" (float_env32));
> float_env32.fpus &= ~0x7f;
> asm volatile ("fldenv %0\n" : : "m" (float_env32));
> }
> --
> 1.7.7.3
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH] tests/tcg: fix unused result warnings
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 ` Catalin Patulea
2012-10-29 8:38 ` Peter Maydell
1 sibling, 1 reply; 6+ messages in thread
From: Catalin Patulea @ 2012-10-29 7:06 UTC (permalink / raw)
To: qemu-devel; +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 <catalinp@google.com>
---
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 <http://www.gnu.org/licenses/>.
*/
+#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
@@ -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 <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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] tests/tcg: fix unused result warnings
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 ` [Qemu-devel] [PATCHv2] " Catalin Patulea
0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2012-10-29 8:38 UTC (permalink / raw)
To: Catalin Patulea; +Cc: qemu-devel
On 29 October 2012 07:06, Catalin Patulea <catalinp@google.com> wrote:
> 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>
Looks good, but checkpatch.pl complains about a bunch of style
issues -- can you fix them, please?
thanks
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCHv2] tests/tcg: fix unused result warnings
2012-10-29 8:38 ` Peter Maydell
@ 2012-10-29 18:01 ` Catalin Patulea
2012-10-30 21:08 ` Blue Swirl
0 siblings, 1 reply; 6+ messages in thread
From: Catalin Patulea @ 2012-10-29 18:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Catalin Patulea
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCHv2] tests/tcg: fix unused result warnings
2012-10-29 18:01 ` [Qemu-devel] [PATCHv2] " Catalin Patulea
@ 2012-10-30 21:08 ` Blue Swirl
0 siblings, 0 replies; 6+ messages in thread
From: Blue Swirl @ 2012-10-30 21:08 UTC (permalink / raw)
To: Catalin Patulea; +Cc: Peter Maydell, qemu-devel
Thanks, applied.
On Mon, Oct 29, 2012 at 6:01 PM, Catalin Patulea <catalinp@google.com> wrote:
> 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
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-10-30 21:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [Qemu-devel] [PATCHv2] " Catalin Patulea
2012-10-30 21:08 ` Blue Swirl
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).