All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, Alistair Francis <alistair@alistair23.me>
Subject: Re: [PATCH] hw/registerfields: Prefix local variables with underscore in macros
Date: Tue, 26 May 2020 18:46:40 +0200	[thread overview]
Message-ID: <7bdb49c1-5396-0bf4-5f83-3849910e5d68@amsat.org> (raw)
In-Reply-To: <20200510203457.10546-1-f4bug@amsat.org>

ping?

On 5/10/20 10:34 PM, Philippe Mathieu-Daudé wrote:
> One can name a local variable holding a value as 'v', but it
> currently clashes with the registerfields macros. To save others
> to debug the same mistake, prefix the macro's local variables
> with an underscore.
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  include/hw/registerfields.h | 40 ++++++++++++++++++-------------------
>  1 file changed, 20 insertions(+), 20 deletions(-)
> 
> diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h
> index 0407edb7ec..93fa4a84c2 100644
> --- a/include/hw/registerfields.h
> +++ b/include/hw/registerfields.h
> @@ -66,35 +66,35 @@
>  #define FIELD_DP8(storage, reg, field, val) ({                            \
>      struct {                                                              \
>          unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;                \
> -    } v = { .v = val };                                                   \
> -    uint8_t d;                                                            \
> -    d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT,           \
> -                  R_ ## reg ## _ ## field ## _LENGTH, v.v);               \
> -    d; })
> +    } _v = { .v = val };                                                  \
> +    uint8_t _d;                                                           \
> +    _d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT,          \
> +                  R_ ## reg ## _ ## field ## _LENGTH, _v.v);              \
> +    _d; })
>  #define FIELD_DP16(storage, reg, field, val) ({                           \
>      struct {                                                              \
>          unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;                \
> -    } v = { .v = val };                                                   \
> -    uint16_t d;                                                           \
> -    d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT,           \
> -                  R_ ## reg ## _ ## field ## _LENGTH, v.v);               \
> -    d; })
> +    } _v = { .v = val };                                                  \
> +    uint16_t _d;                                                          \
> +    _d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT,          \
> +                  R_ ## reg ## _ ## field ## _LENGTH, _v.v);              \
> +    _d; })
>  #define FIELD_DP32(storage, reg, field, val) ({                           \
>      struct {                                                              \
>          unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;                \
> -    } v = { .v = val };                                                   \
> -    uint32_t d;                                                           \
> -    d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT,           \
> -                  R_ ## reg ## _ ## field ## _LENGTH, v.v);               \
> -    d; })
> +    } _v = { .v = val };                                                  \
> +    uint32_t _d;                                                          \
> +    _d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT,          \
> +                  R_ ## reg ## _ ## field ## _LENGTH, _v.v);              \
> +    _d; })
>  #define FIELD_DP64(storage, reg, field, val) ({                           \
>      struct {                                                              \
>          unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;                \
> -    } v = { .v = val };                                                   \
> -    uint64_t d;                                                           \
> -    d = deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT,           \
> -                  R_ ## reg ## _ ## field ## _LENGTH, v.v);               \
> -    d; })
> +    } _v = { .v = val };                                                  \
> +    uint64_t _d;                                                          \
> +    _d = deposit64((storage), R_ ## reg ## _ ## field ## _SHIFT,          \
> +                  R_ ## reg ## _ ## field ## _LENGTH, _v.v);              \
> +    _d; })
>  
>  /* Deposit a field to array of registers.  */
>  #define ARRAY_FIELD_DP32(regs, reg, field, val)                           \
> 


  parent reply	other threads:[~2020-05-26 16:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-10 20:34 [PATCH] hw/registerfields: Prefix local variables with underscore in macros Philippe Mathieu-Daudé
2020-05-11 16:39 ` Alistair Francis
2020-05-26 16:46 ` Philippe Mathieu-Daudé [this message]
2020-05-26 22:49   ` Alistair Francis
2020-05-27  7:34     ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7bdb49c1-5396-0bf4-5f83-3849910e5d68@amsat.org \
    --to=f4bug@amsat.org \
    --cc=alistair@alistair23.me \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.