qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] sh4: Fix potential crash in debug code
@ 2011-07-20 18:56 Stefan Weil
  2011-07-20 18:56 ` [Qemu-devel] [PATCH] tcg/mips: Fix regression caused by typo (copy + paste bug) Stefan Weil
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Stefan Weil @ 2011-07-20 18:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial

cppcheck reports this error:

qemu/hw/sh_intc.c:390: error: Possible null pointer dereference:
 s - otherwise it is redundant to check if s is null at line 385

If s were NULL, the printf() statement would crash.
Setting braces fixes this bug.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 hw/sh_intc.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/sh_intc.c b/hw/sh_intc.c
index 0734da9..f73a4b0 100644
--- a/hw/sh_intc.c
+++ b/hw/sh_intc.c
@@ -382,13 +382,14 @@ void sh_intc_register_sources(struct intc_desc *desc,
 
 	sh_intc_register_source(desc, vect->enum_id, groups, nr_groups);
 	s = sh_intc_source(desc, vect->enum_id);
-	if (s)
-	    s->vect = vect->vect;
+        if (s) {
+            s->vect = vect->vect;
 
 #ifdef DEBUG_INTC_SOURCES
-	printf("sh_intc: registered source %d -> 0x%04x (%d/%d)\n",
-	       vect->enum_id, s->vect, s->enable_count, s->enable_max);
+            printf("sh_intc: registered source %d -> 0x%04x (%d/%d)\n",
+                   vect->enum_id, s->vect, s->enable_count, s->enable_max);
 #endif
+        }
     }
 
     if (groups) {
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH] tcg/mips: Fix regression caused by typo (copy + paste bug)
  2011-07-20 18:56 [Qemu-devel] [PATCH] sh4: Fix potential crash in debug code Stefan Weil
@ 2011-07-20 18:56 ` Stefan Weil
  2011-07-25 10:22 ` [Qemu-devel] [Qemu-trivial] [PATCH] sh4: Fix potential crash in debug code Stefan Hajnoczi
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Stefan Weil @ 2011-07-20 18:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial, Blue Swirl

cppcheck reports an error:
qemu/tcg/mips/tcg-target.c:1487: error: Invalid number of character (()

The unpatched code won't compile on mips hosts starting with commit
cea5f9a28faa528b6b1b117c9ab2d8828f473fef.

Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 tcg/mips/tcg-target.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c
index 12ff9d5..a33d21f 100644
--- a/tcg/mips/tcg-target.c
+++ b/tcg/mips/tcg-target.c
@@ -1484,7 +1484,7 @@ static void tcg_target_qemu_prologue(TCGContext *s)
     }
 
     /* Call generated code */
-    tcg_out_opc_reg(s, OPC_JR, 0, tcg_target_call_iarg_regs[1]), 0);
+    tcg_out_opc_reg(s, OPC_JR, 0, tcg_target_call_iarg_regs[1], 0);
     tcg_out_mov(s, TCG_TYPE_PTR, TCG_AREG0, tcg_target_call_iarg_regs[0]);
     tb_ret_addr = s->code_ptr;
 
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] sh4: Fix potential crash in debug code
  2011-07-20 18:56 [Qemu-devel] [PATCH] sh4: Fix potential crash in debug code Stefan Weil
  2011-07-20 18:56 ` [Qemu-devel] [PATCH] tcg/mips: Fix regression caused by typo (copy + paste bug) Stefan Weil
@ 2011-07-25 10:22 ` Stefan Hajnoczi
  2011-08-13  9:25 ` [Qemu-devel] " Stefan Weil
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2011-07-25 10:22 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, qemu-devel, Aurelien Jarno

On Wed, Jul 20, 2011 at 08:56:35PM +0200, Stefan Weil wrote:
> cppcheck reports this error:
> 
> qemu/hw/sh_intc.c:390: error: Possible null pointer dereference:
>  s - otherwise it is redundant to check if s is null at line 385
> 
> If s were NULL, the printf() statement would crash.
> Setting braces fixes this bug.
> 
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  hw/sh_intc.c |    9 +++++----
>  1 files changed, 5 insertions(+), 4 deletions(-)

Aurelien Jarno is listed as active maintainer for this code.  Patches
should go through him.

Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] sh4: Fix potential crash in debug code
  2011-07-20 18:56 [Qemu-devel] [PATCH] sh4: Fix potential crash in debug code Stefan Weil
  2011-07-20 18:56 ` [Qemu-devel] [PATCH] tcg/mips: Fix regression caused by typo (copy + paste bug) Stefan Weil
  2011-07-25 10:22 ` [Qemu-devel] [Qemu-trivial] [PATCH] sh4: Fix potential crash in debug code Stefan Hajnoczi
@ 2011-08-13  9:25 ` Stefan Weil
  2011-08-27 19:27   ` Stefan Weil
  2011-08-28 11:13 ` Andreas Färber
  2011-08-29 11:39 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
  4 siblings, 1 reply; 7+ messages in thread
From: Stefan Weil @ 2011-08-13  9:25 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: qemu-trivial, qemu-devel

Am 20.07.2011 20:56, schrieb Stefan Weil:
> cppcheck reports this error:
>
> qemu/hw/sh_intc.c:390: error: Possible null pointer dereference:
>   s - otherwise it is redundant to check if s is null at line 385
>
> If s were NULL, the printf() statement would crash.
> Setting braces fixes this bug.
>
> Signed-off-by: Stefan Weil<weil@mail.berlios.de>
> ---
>   hw/sh_intc.c |    9 +++++----
>   1 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/hw/sh_intc.c b/hw/sh_intc.c
> index 0734da9..f73a4b0 100644
> --- a/hw/sh_intc.c
> +++ b/hw/sh_intc.c
> @@ -382,13 +382,14 @@ void sh_intc_register_sources(struct intc_desc *desc,
>
>   	sh_intc_register_source(desc, vect->enum_id, groups, nr_groups);
>   	s = sh_intc_source(desc, vect->enum_id);
> -	if (s)
> -	    s->vect = vect->vect;
> +        if (s) {
> +            s->vect = vect->vect;
>
>   #ifdef DEBUG_INTC_SOURCES
> -	printf("sh_intc: registered source %d ->  0x%04x (%d/%d)\n",
> -	       vect->enum_id, s->vect, s->enable_count, s->enable_max);
> +            printf("sh_intc: registered source %d ->  0x%04x (%d/%d)\n",
> +                   vect->enum_id, s->vect, s->enable_count, s->enable_max);
>   #endif
> +        }
>       }
>
>       if (groups) {
>    

Ping?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] sh4: Fix potential crash in debug code
  2011-08-13  9:25 ` [Qemu-devel] " Stefan Weil
@ 2011-08-27 19:27   ` Stefan Weil
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Weil @ 2011-08-27 19:27 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Aurelien Jarno

Am 13.08.2011 11:25, schrieb Stefan Weil:
> Am 20.07.2011 20:56, schrieb Stefan Weil:
>> cppcheck reports this error:
>>
>> qemu/hw/sh_intc.c:390: error: Possible null pointer dereference:
>>   s - otherwise it is redundant to check if s is null at line 385
>>
>> If s were NULL, the printf() statement would crash.
>> Setting braces fixes this bug.
>>
>> Signed-off-by: Stefan Weil<weil@mail.berlios.de>
>> ---
>>   hw/sh_intc.c |    9 +++++----
>>   1 files changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/hw/sh_intc.c b/hw/sh_intc.c
>> index 0734da9..f73a4b0 100644
>> --- a/hw/sh_intc.c
>> +++ b/hw/sh_intc.c
>> @@ -382,13 +382,14 @@ void sh_intc_register_sources(struct intc_desc 
>> *desc,
>>
>>       sh_intc_register_source(desc, vect->enum_id, groups, nr_groups);
>>       s = sh_intc_source(desc, vect->enum_id);
>> -    if (s)
>> -        s->vect = vect->vect;
>> +        if (s) {
>> +            s->vect = vect->vect;
>>
>>   #ifdef DEBUG_INTC_SOURCES
>> -    printf("sh_intc: registered source %d ->  0x%04x (%d/%d)\n",
>> -           vect->enum_id, s->vect, s->enable_count, s->enable_max);
>> +            printf("sh_intc: registered source %d ->  0x%04x 
>> (%d/%d)\n",
>> +                   vect->enum_id, s->vect, s->enable_count, 
>> s->enable_max);
>>   #endif
>> +        }
>>       }
>>
>>       if (groups) {
>
> Ping?


Please add the patch to the trivial queue. More than a month time
for review and comments should be sufficient for trivial patches.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [PATCH] sh4: Fix potential crash in debug code
  2011-07-20 18:56 [Qemu-devel] [PATCH] sh4: Fix potential crash in debug code Stefan Weil
                   ` (2 preceding siblings ...)
  2011-08-13  9:25 ` [Qemu-devel] " Stefan Weil
@ 2011-08-28 11:13 ` Andreas Färber
  2011-08-29 11:39 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi
  4 siblings, 0 replies; 7+ messages in thread
From: Andreas Färber @ 2011-08-28 11:13 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, QEMU Developers, Aurelien Jarno

Am 20.07.2011 um 20:56 schrieb Stefan Weil:

> cppcheck reports this error:
>
> qemu/hw/sh_intc.c:390: error: Possible null pointer dereference:
> s - otherwise it is redundant to check if s is null at line 385
>
> If s were NULL, the printf() statement would crash.
> Setting braces fixes this bug.
>
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>

Apart from the stated addition of brackets, this reindents the  
bracketed block, replacing tabs with spaces.
Reindenting further code or introducing a trace point is beyond the  
scope of a trivial bugfix, so patch looks fine to me.

Reviewed-by: Andreas Färber <andreas.faerber@web.de>

Andreas

> ---
> hw/sh_intc.c |    9 +++++----
> 1 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/hw/sh_intc.c b/hw/sh_intc.c
> index 0734da9..f73a4b0 100644
> --- a/hw/sh_intc.c
> +++ b/hw/sh_intc.c
> @@ -382,13 +382,14 @@ void sh_intc_register_sources(struct intc_desc  
> *desc,
>
> 	sh_intc_register_source(desc, vect->enum_id, groups, nr_groups);
> 	s = sh_intc_source(desc, vect->enum_id);
> -	if (s)
> -	    s->vect = vect->vect;
> +        if (s) {
> +            s->vect = vect->vect;
>
> #ifdef DEBUG_INTC_SOURCES
> -	printf("sh_intc: registered source %d -> 0x%04x (%d/%d)\n",
> -	       vect->enum_id, s->vect, s->enable_count, s->enable_max);
> +            printf("sh_intc: registered source %d -> 0x%04x (%d/%d) 
> \n",
> +                   vect->enum_id, s->vect, s->enable_count, s- 
> >enable_max);
> #endif
> +        }
>     }
>
>     if (groups) {
> -- 
> 1.7.2.5

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] sh4: Fix potential crash in debug code
  2011-07-20 18:56 [Qemu-devel] [PATCH] sh4: Fix potential crash in debug code Stefan Weil
                   ` (3 preceding siblings ...)
  2011-08-28 11:13 ` Andreas Färber
@ 2011-08-29 11:39 ` Stefan Hajnoczi
  4 siblings, 0 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2011-08-29 11:39 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-trivial, qemu-devel

On Wed, Jul 20, 2011 at 08:56:35PM +0200, Stefan Weil wrote:
> cppcheck reports this error:
> 
> qemu/hw/sh_intc.c:390: error: Possible null pointer dereference:
>  s - otherwise it is redundant to check if s is null at line 385
> 
> If s were NULL, the printf() statement would crash.
> Setting braces fixes this bug.
> 
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>
> ---
>  hw/sh_intc.c |    9 +++++----
>  1 files changed, 5 insertions(+), 4 deletions(-)

Thanks, applied to the trivial patches tree:
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/trivial-patches

Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-08-29 11:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-20 18:56 [Qemu-devel] [PATCH] sh4: Fix potential crash in debug code Stefan Weil
2011-07-20 18:56 ` [Qemu-devel] [PATCH] tcg/mips: Fix regression caused by typo (copy + paste bug) Stefan Weil
2011-07-25 10:22 ` [Qemu-devel] [Qemu-trivial] [PATCH] sh4: Fix potential crash in debug code Stefan Hajnoczi
2011-08-13  9:25 ` [Qemu-devel] " Stefan Weil
2011-08-27 19:27   ` Stefan Weil
2011-08-28 11:13 ` Andreas Färber
2011-08-29 11:39 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi

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).