diff mbox series

[1/4] m68k/nios2-semi: fix gettimeofday() result check

Message ID 20220304152704.3466036-2-marcandre.lureau@redhat.com
State Superseded
Headers show
Series RFC: remove qemu_gettimeofday() | expand

Commit Message

Marc-André Lureau March 4, 2022, 3:27 p.m. UTC
From: Marc-André Lureau <marcandre.lureau@redhat.com>

gettimeofday() returns 0 for success.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 target/m68k/m68k-semi.c   | 2 +-
 target/nios2/nios2-semi.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Laurent Vivier March 4, 2022, 3:45 p.m. UTC | #1
Le 04/03/2022 à 16:27, marcandre.lureau@redhat.com a écrit :
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
> 
> gettimeofday() returns 0 for success.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>   target/m68k/m68k-semi.c   | 2 +-
>   target/nios2/nios2-semi.c | 2 +-
>   2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c
> index 44ec7e4612c6..c5c164e096c8 100644
> --- a/target/m68k/m68k-semi.c
> +++ b/target/m68k/m68k-semi.c
> @@ -381,7 +381,7 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
>               qemu_timeval tv;
>               struct gdb_timeval *p;
>               result = qemu_gettimeofday(&tv);
> -            if (result != 0) {
> +            if (result == 0) {
>                   if (!(p = lock_user(VERIFY_WRITE,
>                                       arg0, sizeof(struct gdb_timeval), 0))) {
>                       /* FIXME - check error code? */
> diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c
> index fe5598bae4d7..5a7ad0c7108d 100644
> --- a/target/nios2/nios2-semi.c
> +++ b/target/nios2/nios2-semi.c
> @@ -403,7 +403,7 @@ void do_nios2_semihosting(CPUNios2State *env)
>               qemu_timeval tv;
>               struct gdb_timeval *p;
>               result = qemu_gettimeofday(&tv);
> -            if (result != 0) {
> +            if (result == 0) {
>                   p = lock_user(VERIFY_WRITE, arg0, sizeof(struct gdb_timeval),
>                                 0);
>                   if (!p) {

It seems to have never worked correctly...

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
diff mbox series

Patch

diff --git a/target/m68k/m68k-semi.c b/target/m68k/m68k-semi.c
index 44ec7e4612c6..c5c164e096c8 100644
--- a/target/m68k/m68k-semi.c
+++ b/target/m68k/m68k-semi.c
@@ -381,7 +381,7 @@  void do_m68k_semihosting(CPUM68KState *env, int nr)
             qemu_timeval tv;
             struct gdb_timeval *p;
             result = qemu_gettimeofday(&tv);
-            if (result != 0) {
+            if (result == 0) {
                 if (!(p = lock_user(VERIFY_WRITE,
                                     arg0, sizeof(struct gdb_timeval), 0))) {
                     /* FIXME - check error code? */
diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c
index fe5598bae4d7..5a7ad0c7108d 100644
--- a/target/nios2/nios2-semi.c
+++ b/target/nios2/nios2-semi.c
@@ -403,7 +403,7 @@  void do_nios2_semihosting(CPUNios2State *env)
             qemu_timeval tv;
             struct gdb_timeval *p;
             result = qemu_gettimeofday(&tv);
-            if (result != 0) {
+            if (result == 0) {
                 p = lock_user(VERIFY_WRITE, arg0, sizeof(struct gdb_timeval),
                               0);
                 if (!p) {