All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH target-arm] display: avoid multi-statement macro
@ 2014-01-24 17:47 Paolo Bonzini
  2014-01-24 17:52 ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2014-01-24 17:47 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell

For blizzard, pl110 and tc6393xb this is harmless, but for pxa2xx
Coverity noticed that it is used inside an "if" statement.
Fix it because it's the file with the highest number of defects
in the whole QEMU tree!

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/display/blizzard_template.h | 10 +++++-----
 hw/display/pl110_template.h    |  6 +++---
 hw/display/pxa2xx_template.h   |  8 ++++----
 hw/display/tc6393xb_template.h |  8 ++++----
 4 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/hw/display/blizzard_template.h b/hw/display/blizzard_template.h
index a8a8899..b899a29 100644
--- a/hw/display/blizzard_template.h
+++ b/hw/display/blizzard_template.h
@@ -21,21 +21,21 @@
 #define SKIP_PIXEL(to)		to += deststep
 #if DEPTH == 8
 # define PIXEL_TYPE		uint8_t
-# define COPY_PIXEL(to, from)	*to = from; SKIP_PIXEL(to)
+# define COPY_PIXEL(to, from)	*to = from, SKIP_PIXEL(to)
 # define COPY_PIXEL1(to, from)	*to ++ = from
 #elif DEPTH == 15 || DEPTH == 16
 # define PIXEL_TYPE		uint16_t
-# define COPY_PIXEL(to, from)	*to = from; SKIP_PIXEL(to)
+# define COPY_PIXEL(to, from)	*to = from, SKIP_PIXEL(to)
 # define COPY_PIXEL1(to, from)	*to ++ = from
 #elif DEPTH == 24
 # define PIXEL_TYPE		uint8_t
 # define COPY_PIXEL(to, from)	\
-    to[0] = from; to[1] = (from) >> 8; to[2] = (from) >> 16; SKIP_PIXEL(to)
+    to[0] = from, to[1] = (from) >> 8, to[2] = (from) >> 16, SKIP_PIXEL(to)
 # define COPY_PIXEL1(to, from)	\
-    *to ++ = from; *to ++ = (from) >> 8; *to ++ = (from) >> 16
+    *to ++ = from, *to ++ = (from) >> 8, *to ++ = (from) >> 16
 #elif DEPTH == 32
 # define PIXEL_TYPE		uint32_t
-# define COPY_PIXEL(to, from)	*to = from; SKIP_PIXEL(to)
+# define COPY_PIXEL(to, from)	*to = from, SKIP_PIXEL(to)
 # define COPY_PIXEL1(to, from)	*to ++ = from
 #else
 # error unknown bit depth
diff --git a/hw/display/pl110_template.h b/hw/display/pl110_template.h
index e738e4a..3ff42e0 100644
--- a/hw/display/pl110_template.h
+++ b/hw/display/pl110_template.h
@@ -14,12 +14,12 @@
 #if BITS == 8
 #define COPY_PIXEL(to, from) *(to++) = from
 #elif BITS == 15 || BITS == 16
-#define COPY_PIXEL(to, from) *(uint16_t *)to = from; to += 2;
+#define COPY_PIXEL(to, from) *(uint16_t *)to = from, to += 2
 #elif BITS == 24
 #define COPY_PIXEL(to, from) \
-  *(to++) = from; *(to++) = (from) >> 8; *(to++) = (from) >> 16
+  *(to++) = from, *(to++) = (from) >> 8, *(to++) = (from) >> 16
 #elif BITS == 32
-#define COPY_PIXEL(to, from) *(uint32_t *)to = from; to += 4;
+#define COPY_PIXEL(to, from) *(uint32_t *)to = from, to += 4
 #else
 #error unknown bit depth
 #endif
diff --git a/hw/display/pxa2xx_template.h b/hw/display/pxa2xx_template.h
index 1cbe36c..806f573 100644
--- a/hw/display/pxa2xx_template.h
+++ b/hw/display/pxa2xx_template.h
@@ -11,14 +11,14 @@
 
 # define SKIP_PIXEL(to)		to += deststep
 #if BITS == 8
-# define COPY_PIXEL(to, from)	*to = from; SKIP_PIXEL(to)
+# define COPY_PIXEL(to, from)	*to = from, SKIP_PIXEL(to)
 #elif BITS == 15 || BITS == 16
-# define COPY_PIXEL(to, from)	*(uint16_t *) to = from; SKIP_PIXEL(to)
+# define COPY_PIXEL(to, from)	*(uint16_t *) to = from, SKIP_PIXEL(to)
 #elif BITS == 24
 # define COPY_PIXEL(to, from)	\
-	*(uint16_t *) to = from; *(to + 2) = (from) >> 16; SKIP_PIXEL(to)
+	*(uint16_t *) to = from, *(to + 2) = (from) >> 16, SKIP_PIXEL(to)
 #elif BITS == 32
-# define COPY_PIXEL(to, from)	*(uint32_t *) to = from; SKIP_PIXEL(to)
+# define COPY_PIXEL(to, from)	*(uint32_t *) to = from, SKIP_PIXEL(to)
 #else
 # error unknown bit depth
 #endif
diff --git a/hw/display/tc6393xb_template.h b/hw/display/tc6393xb_template.h
index 154aafd..8fbdd5c 100644
--- a/hw/display/tc6393xb_template.h
+++ b/hw/display/tc6393xb_template.h
@@ -22,14 +22,14 @@
  */
 
 #if BITS == 8
-# define SET_PIXEL(addr, color)	*(uint8_t*)addr = color;
+# define SET_PIXEL(addr, color)	*(uint8_t*)addr = color
 #elif BITS == 15 || BITS == 16
-# define SET_PIXEL(addr, color)	*(uint16_t*)addr = color;
+# define SET_PIXEL(addr, color)	*(uint16_t*)addr = color
 #elif BITS == 24
 # define SET_PIXEL(addr, color)	\
-    addr[0] = color; addr[1] = (color) >> 8; addr[2] = (color) >> 16;
+    addr[0] = color, addr[1] = (color) >> 8, addr[2] = (color) >> 16
 #elif BITS == 32
-# define SET_PIXEL(addr, color)	*(uint32_t*)addr = color;
+# define SET_PIXEL(addr, color)	*(uint32_t*)addr = color
 #else
 # error unknown bit depth
 #endif
-- 
1.8.4.2

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

* Re: [Qemu-devel] [PATCH target-arm] display: avoid multi-statement macro
  2014-01-24 17:47 [Qemu-devel] [PATCH target-arm] display: avoid multi-statement macro Paolo Bonzini
@ 2014-01-24 17:52 ` Peter Maydell
  2014-01-24 17:53   ` Paolo Bonzini
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2014-01-24 17:52 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: QEMU Developers

On 24 January 2014 17:47, Paolo Bonzini <pbonzini@redhat.com> wrote:
> For blizzard, pl110 and tc6393xb this is harmless, but for pxa2xx
> Coverity noticed that it is used inside an "if" statement.
> Fix it because it's the file with the highest number of defects
> in the whole QEMU tree!
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/display/blizzard_template.h | 10 +++++-----
>  hw/display/pl110_template.h    |  6 +++---
>  hw/display/pxa2xx_template.h   |  8 ++++----
>  hw/display/tc6393xb_template.h |  8 ++++----
>  4 files changed, 22 insertions(+), 23 deletions(-)
>
> diff --git a/hw/display/blizzard_template.h b/hw/display/blizzard_template.h
> index a8a8899..b899a29 100644
> --- a/hw/display/blizzard_template.h
> +++ b/hw/display/blizzard_template.h
> @@ -21,21 +21,21 @@
>  #define SKIP_PIXEL(to)         to += deststep
>  #if DEPTH == 8
>  # define PIXEL_TYPE            uint8_t
> -# define COPY_PIXEL(to, from)  *to = from; SKIP_PIXEL(to)
> +# define COPY_PIXEL(to, from)  *to = from, SKIP_PIXEL(to)

Why not use the standard do { ... } while(0) idiom ?

thanks
-- PMM

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

* Re: [Qemu-devel] [PATCH target-arm] display: avoid multi-statement macro
  2014-01-24 17:52 ` Peter Maydell
@ 2014-01-24 17:53   ` Paolo Bonzini
  2014-01-24 18:26     ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2014-01-24 17:53 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers

Il 24/01/2014 18:52, Peter Maydell ha scritto:
> On 24 January 2014 17:47, Paolo Bonzini <pbonzini@redhat.com> wrote:
>> For blizzard, pl110 and tc6393xb this is harmless, but for pxa2xx
>> Coverity noticed that it is used inside an "if" statement.
>> Fix it because it's the file with the highest number of defects
>> in the whole QEMU tree!
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  hw/display/blizzard_template.h | 10 +++++-----
>>  hw/display/pl110_template.h    |  6 +++---
>>  hw/display/pxa2xx_template.h   |  8 ++++----
>>  hw/display/tc6393xb_template.h |  8 ++++----
>>  4 files changed, 22 insertions(+), 23 deletions(-)
>>
>> diff --git a/hw/display/blizzard_template.h b/hw/display/blizzard_template.h
>> index a8a8899..b899a29 100644
>> --- a/hw/display/blizzard_template.h
>> +++ b/hw/display/blizzard_template.h
>> @@ -21,21 +21,21 @@
>>  #define SKIP_PIXEL(to)         to += deststep
>>  #if DEPTH == 8
>>  # define PIXEL_TYPE            uint8_t
>> -# define COPY_PIXEL(to, from)  *to = from; SKIP_PIXEL(to)
>> +# define COPY_PIXEL(to, from)  *to = from, SKIP_PIXEL(to)
>
> Why not use the standard do { ... } while(0) idiom ?

I figured that this would make the patch easier to review, but I can use 
"do {...} while(0)" too (either directly or as a follow up).

Paolo

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

* Re: [Qemu-devel] [PATCH target-arm] display: avoid multi-statement macro
  2014-01-24 17:53   ` Paolo Bonzini
@ 2014-01-24 18:26     ` Peter Maydell
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2014-01-24 18:26 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: QEMU Developers

On 24 January 2014 17:53, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Il 24/01/2014 18:52, Peter Maydell ha scritto:
>> On 24 January 2014 17:47, Paolo Bonzini <pbonzini@redhat.com> wrote:
>>> --- a/hw/display/blizzard_template.h
>>> +++ b/hw/display/blizzard_template.h
>>> @@ -21,21 +21,21 @@
>>>  #define SKIP_PIXEL(to)         to += deststep
>>>  #if DEPTH == 8
>>>  # define PIXEL_TYPE            uint8_t
>>> -# define COPY_PIXEL(to, from)  *to = from; SKIP_PIXEL(to)
>>> +# define COPY_PIXEL(to, from)  *to = from, SKIP_PIXEL(to)
>>
>>
>> Why not use the standard do { ... } while(0) idiom ?
>
>
> I figured that this would make the patch easier to review, but I can use "do
> {...} while(0)" too (either directly or as a follow up).

I'd prefer do ... while(0), just as a single patch fix.
I'm not convinced the average QEMU programmer could tell
you whether comma is a sequence point without going and
looking it up :-)

thanks
-- PMM

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

end of thread, other threads:[~2014-01-24 18:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-24 17:47 [Qemu-devel] [PATCH target-arm] display: avoid multi-statement macro Paolo Bonzini
2014-01-24 17:52 ` Peter Maydell
2014-01-24 17:53   ` Paolo Bonzini
2014-01-24 18:26     ` Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.