diff mbox series

[v2,11/14] hw/net/stellaris_enet: Use qemu_log_mask(GUEST_ERROR) instead of hw_error

Message ID 20180622134036.23182-12-f4bug@amsat.org
State New
Headers show
Series hw/arm: use qemu_log_mask instead of fprintf | expand

Commit Message

Philippe Mathieu-Daudé June 22, 2018, 1:40 p.m. UTC
hw_error() finally calls abort(), but there is no need to abort here.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/net/stellaris_enet.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Thomas Huth June 22, 2018, 7:50 p.m. UTC | #1
On 22.06.2018 15:40, Philippe Mathieu-Daudé wrote:
> hw_error() finally calls abort(), but there is no need to abort here.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/net/stellaris_enet.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
> index 04bd10ada3..f8edebdecd 100644
> --- a/hw/net/stellaris_enet.c
> +++ b/hw/net/stellaris_enet.c
> @@ -9,6 +9,7 @@
>  #include "qemu/osdep.h"
>  #include "hw/sysbus.h"
>  #include "net/net.h"
> +#include "qemu/log.h"
>  #include <zlib.h>
>  
>  //#define DEBUG_STELLARIS_ENET 1
> @@ -343,7 +344,9 @@ static uint64_t stellaris_enet_read(void *opaque, hwaddr offset,
>      case 0x3c: /* Undocuented: Timestamp? */

I guess it's trivial enough that you could fix the above type in your
patch here, too (just mention it in the patch description).

>          return 0;
>      default:
> -        hw_error("stellaris_enet_read: Bad offset %x\n", (int)offset);
> +        qemu_log_mask(LOG_GUEST_ERROR, "stellaris_enet_rd%d: Illegal register"
> +                                       " 0x02%" HWADDR_PRIx "\n",
> +                      size << 2, offset);

Why "<< 2" ? Shouldn't that be "<< 3" or "* 8" instead?

>          return 0;
>      }
>  }
> @@ -442,7 +445,9 @@ static void stellaris_enet_write(void *opaque, hwaddr offset,
>          /* Ignored.  */
>          break;
>      default:
> -        hw_error("stellaris_enet_write: Bad offset %x\n", (int)offset);
> +        qemu_log_mask(LOG_GUEST_ERROR, "stellaris_enet_wr%d: Illegal register"
> +                                       " 0x02%" HWADDR_PRIx " = 0x%lx\n",
> +                      size << 2, offset, value);

dito.

 Thomas
Philippe Mathieu-Daudé June 22, 2018, 8:15 p.m. UTC | #2
On 06/22/2018 04:50 PM, Thomas Huth wrote:
> On 22.06.2018 15:40, Philippe Mathieu-Daudé wrote:
>> hw_error() finally calls abort(), but there is no need to abort here.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
>>  hw/net/stellaris_enet.c | 9 +++++++--
>>  1 file changed, 7 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
>> index 04bd10ada3..f8edebdecd 100644
>> --- a/hw/net/stellaris_enet.c
>> +++ b/hw/net/stellaris_enet.c
>> @@ -9,6 +9,7 @@
>>  #include "qemu/osdep.h"
>>  #include "hw/sysbus.h"
>>  #include "net/net.h"
>> +#include "qemu/log.h"
>>  #include <zlib.h>
>>  
>>  //#define DEBUG_STELLARIS_ENET 1
>> @@ -343,7 +344,9 @@ static uint64_t stellaris_enet_read(void *opaque, hwaddr offset,
>>      case 0x3c: /* Undocuented: Timestamp? */
> 
> I guess it's trivial enough that you could fix the above type in your
> patch here, too (just mention it in the patch description).

Well I guess it depends the maintainer taking it :)

Since I expect this series to go via the ARM tree, I'll fix this typo in
another patch.

> 
>>          return 0;
>>      default:
>> -        hw_error("stellaris_enet_read: Bad offset %x\n", (int)offset);
>> +        qemu_log_mask(LOG_GUEST_ERROR, "stellaris_enet_rd%d: Illegal register"
>> +                                       " 0x02%" HWADDR_PRIx "\n",
>> +                      size << 2, offset);
> 
> Why "<< 2" ? Shouldn't that be "<< 3" or "* 8" instead?

Oops "* 8" indeed.

> 
>>          return 0;
>>      }
>>  }
>> @@ -442,7 +445,9 @@ static void stellaris_enet_write(void *opaque, hwaddr offset,
>>          /* Ignored.  */
>>          break;
>>      default:
>> -        hw_error("stellaris_enet_write: Bad offset %x\n", (int)offset);
>> +        qemu_log_mask(LOG_GUEST_ERROR, "stellaris_enet_wr%d: Illegal register"
>> +                                       " 0x02%" HWADDR_PRIx " = 0x%lx\n",
>> +                      size << 2, offset, value);
> 
> dito.
> 
>  Thomas
>
diff mbox series

Patch

diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
index 04bd10ada3..f8edebdecd 100644
--- a/hw/net/stellaris_enet.c
+++ b/hw/net/stellaris_enet.c
@@ -9,6 +9,7 @@ 
 #include "qemu/osdep.h"
 #include "hw/sysbus.h"
 #include "net/net.h"
+#include "qemu/log.h"
 #include <zlib.h>
 
 //#define DEBUG_STELLARIS_ENET 1
@@ -343,7 +344,9 @@  static uint64_t stellaris_enet_read(void *opaque, hwaddr offset,
     case 0x3c: /* Undocuented: Timestamp? */
         return 0;
     default:
-        hw_error("stellaris_enet_read: Bad offset %x\n", (int)offset);
+        qemu_log_mask(LOG_GUEST_ERROR, "stellaris_enet_rd%d: Illegal register"
+                                       " 0x02%" HWADDR_PRIx "\n",
+                      size << 2, offset);
         return 0;
     }
 }
@@ -442,7 +445,9 @@  static void stellaris_enet_write(void *opaque, hwaddr offset,
         /* Ignored.  */
         break;
     default:
-        hw_error("stellaris_enet_write: Bad offset %x\n", (int)offset);
+        qemu_log_mask(LOG_GUEST_ERROR, "stellaris_enet_wr%d: Illegal register"
+                                       " 0x02%" HWADDR_PRIx " = 0x%lx\n",
+                      size << 2, offset, value);
     }
 }