All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] nbd-client: Use correct macro parenthesization
@ 2017-09-18 21:46 Eric Blake
  2017-09-18 22:13 ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Eric Blake @ 2017-09-18 21:46 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-trivial, Paolo Bonzini, Kevin Wolf, Max Reitz,
	open list:Network Block Dev...

If 'bs' is a complex expression, we were only casting the front half
rather than the full expression.  Luckily, none of the callers were
passing bad arguments, but it's better to be robust up front.

Signed-off-by: Eric Blake <eblake@redhat.com>
---

I plan to take this through my NBD queue, unless it is picked up
by qemu-trivial first...

 block/nbd-client.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/nbd-client.c b/block/nbd-client.c
index 5f241ecc22..2a528dd217 100644
--- a/block/nbd-client.c
+++ b/block/nbd-client.c
@@ -31,8 +31,8 @@
 #include "qapi/error.h"
 #include "nbd-client.h"

-#define HANDLE_TO_INDEX(bs, handle) ((handle) ^ ((uint64_t)(intptr_t)bs))
-#define INDEX_TO_HANDLE(bs, index)  ((index)  ^ ((uint64_t)(intptr_t)bs))
+#define HANDLE_TO_INDEX(bs, handle) ((handle) ^ (uint64_t)(intptr_t)(bs))
+#define INDEX_TO_HANDLE(bs, index)  ((index)  ^ (uint64_t)(intptr_t)(bs))

 static void nbd_recv_coroutines_wake_all(NBDClientSession *s)
 {
-- 
2.13.5

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

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] nbd-client: Use correct macro parenthesization
  2017-09-18 21:46 [Qemu-devel] [PATCH] nbd-client: Use correct macro parenthesization Eric Blake
@ 2017-09-18 22:13 ` Philippe Mathieu-Daudé
  2017-09-18 22:42   ` Eric Blake
  2017-09-19  9:13 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
  2017-09-24 20:59 ` [Qemu-devel] " Michael Tokarev
  2 siblings, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-09-18 22:13 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: qemu-trivial, Paolo Bonzini, open list:Network Block Dev...,
	Kevin Wolf, Max Reitz

Hi Eric,

On 09/18/2017 06:46 PM, Eric Blake wrote:
> If 'bs' is a complex expression, we were only casting the front half
> rather than the full expression.  Luckily, none of the callers were
> passing bad arguments, but it's better to be robust up front.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Any magic cocci script to verify there aren't no more?

> ---
> 
> I plan to take this through my NBD queue, unless it is picked up
> by qemu-trivial first...
> 
>   block/nbd-client.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/block/nbd-client.c b/block/nbd-client.c
> index 5f241ecc22..2a528dd217 100644
> --- a/block/nbd-client.c
> +++ b/block/nbd-client.c
> @@ -31,8 +31,8 @@
>   #include "qapi/error.h"
>   #include "nbd-client.h"
> 
> -#define HANDLE_TO_INDEX(bs, handle) ((handle) ^ ((uint64_t)(intptr_t)bs))
> -#define INDEX_TO_HANDLE(bs, index)  ((index)  ^ ((uint64_t)(intptr_t)bs))
> +#define HANDLE_TO_INDEX(bs, handle) ((handle) ^ (uint64_t)(intptr_t)(bs))
> +#define INDEX_TO_HANDLE(bs, index)  ((index)  ^ (uint64_t)(intptr_t)(bs))
> 
>   static void nbd_recv_coroutines_wake_all(NBDClientSession *s)
>   {
> 

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

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] nbd-client: Use correct macro parenthesization
  2017-09-18 22:13 ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
@ 2017-09-18 22:42   ` Eric Blake
  2017-09-19 10:32     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Blake @ 2017-09-18 22:42 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: qemu-trivial, Paolo Bonzini, open list:Network Block Dev...,
	Kevin Wolf, Max Reitz

[-- Attachment #1: Type: text/plain, Size: 858 bytes --]

On 09/18/2017 05:13 PM, Philippe Mathieu-Daudé wrote:
> Hi Eric,
> 
> On 09/18/2017 06:46 PM, Eric Blake wrote:
>> If 'bs' is a complex expression, we were only casting the front half
>> rather than the full expression.  Luckily, none of the callers were
>> passing bad arguments, but it's better to be robust up front.
>>
>> Signed-off-by: Eric Blake <eblake@redhat.com>
> 
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 
> Any magic cocci script to verify there aren't no more?

I don't know if cocci can do it; checkpatch tries to check whether macro
arguments are parenthesized, but even that's prone to missing things.  I
just spotted this particular one while reviewing a related patch.


-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

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

* Re: [Qemu-devel] [Qemu-block] [PATCH] nbd-client: Use correct macro parenthesization
  2017-09-18 21:46 [Qemu-devel] [PATCH] nbd-client: Use correct macro parenthesization Eric Blake
  2017-09-18 22:13 ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
@ 2017-09-19  9:13 ` Stefan Hajnoczi
  2017-09-24 20:59 ` [Qemu-devel] " Michael Tokarev
  2 siblings, 0 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2017-09-19  9:13 UTC (permalink / raw)
  To: Eric Blake
  Cc: qemu-devel, qemu-trivial, Paolo Bonzini,
	open list:Network Block Dev...,
	Kevin Wolf, Max Reitz

On Mon, Sep 18, 2017 at 04:46:49PM -0500, Eric Blake wrote:
> If 'bs' is a complex expression, we were only casting the front half
> rather than the full expression.  Luckily, none of the callers were
> passing bad arguments, but it's better to be robust up front.
> 
> Signed-off-by: Eric Blake <eblake@redhat.com>
> ---
> 
> I plan to take this through my NBD queue, unless it is picked up
> by qemu-trivial first...
> 
>  block/nbd-client.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

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

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] nbd-client: Use correct macro parenthesization
  2017-09-18 22:42   ` Eric Blake
@ 2017-09-19 10:32     ` Philippe Mathieu-Daudé
  2017-09-19 14:16       ` Eric Blake
  0 siblings, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-09-19 10:32 UTC (permalink / raw)
  To: Eric Blake; +Cc: qemu-devel

On 09/18/2017 07:42 PM, Eric Blake wrote:
> On 09/18/2017 05:13 PM, Philippe Mathieu-Daudé wrote:
>> Any magic cocci script to verify there aren't no more?
> 
> I don't know if cocci can do it; checkpatch tries to check whether macro
> arguments are parenthesized, but even that's prone to missing things.  I
> just spotted this particular one while reviewing a related patch.

couldn't figure out.

grep -E '^\s*#define\s+\w+\([^\)]+\)\s+.*\(\w+\)\w+' (no multiline) 
found those unharmful:

target/mips/dsp_helper.c:#define MIPSDSP_RETURN64_16(a, b, c, d) 
(((uint64_t)a << 48) | \
target/mips/dsp_helper.c:#define MIPSDSP_RETURN64_32(a, b) 
(((uint64_t)a << 32) | (uint64_t)b)
include/hw/ppc/pnv_xscom.h:#define PNV_XSCOM_EX_CORE_BASE(base, i) (base 
| (((uint64_t)i) << 24))

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

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] nbd-client: Use correct macro parenthesization
  2017-09-19 10:32     ` Philippe Mathieu-Daudé
@ 2017-09-19 14:16       ` Eric Blake
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Blake @ 2017-09-19 14:16 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1124 bytes --]

On 09/19/2017 05:32 AM, Philippe Mathieu-Daudé wrote:
> On 09/18/2017 07:42 PM, Eric Blake wrote:
>> On 09/18/2017 05:13 PM, Philippe Mathieu-Daudé wrote:
>>> Any magic cocci script to verify there aren't no more?
>>
>> I don't know if cocci can do it; checkpatch tries to check whether macro
>> arguments are parenthesized, but even that's prone to missing things.  I
>> just spotted this particular one while reviewing a related patch.
> 
> couldn't figure out.
> 
> grep -E '^\s*#define\s+\w+\([^\)]+\)\s+.*\(\w+\)\w+' (no multiline)
> found those unharmful:
> 
> target/mips/dsp_helper.c:#define MIPSDSP_RETURN64_16(a, b, c, d)
> (((uint64_t)a << 48) | \
> target/mips/dsp_helper.c:#define MIPSDSP_RETURN64_32(a, b) (((uint64_t)a
> << 32) | (uint64_t)b)
> include/hw/ppc/pnv_xscom.h:#define PNV_XSCOM_EX_CORE_BASE(base, i) (base
> | (((uint64_t)i) << 24))

There's probably more, but I submitted patches for these two files as
separate threads for qemu-trivial.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

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

* Re: [Qemu-devel] [PATCH] nbd-client: Use correct macro parenthesization
  2017-09-18 21:46 [Qemu-devel] [PATCH] nbd-client: Use correct macro parenthesization Eric Blake
  2017-09-18 22:13 ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
  2017-09-19  9:13 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
@ 2017-09-24 20:59 ` Michael Tokarev
  2 siblings, 0 replies; 7+ messages in thread
From: Michael Tokarev @ 2017-09-24 20:59 UTC (permalink / raw)
  To: Eric Blake, qemu-devel
  Cc: qemu-trivial, Paolo Bonzini, open list:Network Block Dev...,
	Kevin Wolf, Max Reitz

19.09.2017 00:46, Eric Blake wrote:
> If 'bs' is a complex expression, we were only casting the front half
> rather than the full expression.  Luckily, none of the callers were
> passing bad arguments, but it's better to be robust up front.

Applied to -trivial.

/mjt

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

end of thread, other threads:[~2017-09-24 21:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-18 21:46 [Qemu-devel] [PATCH] nbd-client: Use correct macro parenthesization Eric Blake
2017-09-18 22:13 ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
2017-09-18 22:42   ` Eric Blake
2017-09-19 10:32     ` Philippe Mathieu-Daudé
2017-09-19 14:16       ` Eric Blake
2017-09-19  9:13 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-09-24 20:59 ` [Qemu-devel] " Michael Tokarev

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.