* [PATCH] hw/registerfields: Prefix local variables with underscore in macros
@ 2020-05-10 20:34 Philippe Mathieu-Daudé
2020-05-11 16:39 ` Alistair Francis
2020-05-26 16:46 ` Philippe Mathieu-Daudé
0 siblings, 2 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-10 20:34 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Alistair Francis, Philippe Mathieu-Daudé
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) \
--
2.21.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] hw/registerfields: Prefix local variables with underscore in macros
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é
1 sibling, 0 replies; 5+ messages in thread
From: Alistair Francis @ 2020-05-11 16:39 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: QEMU Trivial, Alistair Francis, qemu-devel@nongnu.org Developers
On Sun, May 10, 2020 at 1:35 PM Philippe Mathieu-Daudé <f4bug@amsat.org> 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>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> 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) \
> --
> 2.21.3
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hw/registerfields: Prefix local variables with underscore in macros
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é
2020-05-26 22:49 ` Alistair Francis
1 sibling, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-26 16:46 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Alistair Francis
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) \
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hw/registerfields: Prefix local variables with underscore in macros
2020-05-26 16:46 ` Philippe Mathieu-Daudé
@ 2020-05-26 22:49 ` Alistair Francis
2020-05-27 7:34 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 5+ messages in thread
From: Alistair Francis @ 2020-05-26 22:49 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: QEMU Trivial, Alistair Francis, qemu-devel@nongnu.org Developers
On Tue, May 26, 2020 at 9:50 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> ping?
I'll send a PR with this.
Alistair
>
> 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) \
> >
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] hw/registerfields: Prefix local variables with underscore in macros
2020-05-26 22:49 ` Alistair Francis
@ 2020-05-27 7:34 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-05-27 7:34 UTC (permalink / raw)
To: Alistair Francis
Cc: QEMU Trivial, Alistair Francis, qemu-devel@nongnu.org Developers
Hi Alistair,
On 5/27/20 12:49 AM, Alistair Francis wrote:
> On Tue, May 26, 2020 at 9:50 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>>
>> ping?
>
> I'll send a PR with this.
Well, this was only a "friendly ping", there is no hurry, I can wait for
the next qemu-trivial pull request.
Thanks!
Phil.
>
> Alistair
>
>>
>> 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) \
>>>
>>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-05-27 7:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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é
2020-05-26 22:49 ` Alistair Francis
2020-05-27 7:34 ` Philippe Mathieu-Daudé
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.