Message ID | 1458837548-10413-1-git-send-email-sw@weilnetz.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 24 March 2016 at 16:39, Stefan Weil <sw@weilnetz.de> wrote: > Signed-off-by: Stefan Weil <sw@weilnetz.de> > --- > > This patch is rather old, but it still can be applied. > It avoids duplicate definitions for some array indices > (which are allowed by gcc, but cgcc complains). > > hw/arm/pxa2xx_pic.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c > index 8a39b1c..a8a68e8 100644 > --- a/hw/arm/pxa2xx_pic.c > +++ b/hw/arm/pxa2xx_pic.c > @@ -204,7 +204,6 @@ static void pxa2xx_pic_mem_write(void *opaque, hwaddr offset, > > /* Interrupt Controller Coprocessor Space Register Mapping */ > static const int pxa2xx_cp_reg_map[0x10] = { > - [0x0 ... 0xf] = -1, > [0x0] = ICIP, > [0x1] = ICMR, > [0x2] = ICLR, > @@ -216,6 +215,7 @@ static const int pxa2xx_cp_reg_map[0x10] = { > [0x8] = ICLR2, > [0x9] = ICFP2, > [0xa] = ICPR2, > + [0xb ... 0xf] = -1, > }; This is more bug-prone than the current code, because now if we add or remove an entry in the array we have to change the final line. The point of [ 0x0 ... 0xf ] is to specify a default value for the array. We use -Wno-initializer-overrides to silence a clang warning about this, because we want to be able to use this "set the default" idiom. thanks -- PMM
diff --git a/hw/arm/pxa2xx_pic.c b/hw/arm/pxa2xx_pic.c index 8a39b1c..a8a68e8 100644 --- a/hw/arm/pxa2xx_pic.c +++ b/hw/arm/pxa2xx_pic.c @@ -204,7 +204,6 @@ static void pxa2xx_pic_mem_write(void *opaque, hwaddr offset, /* Interrupt Controller Coprocessor Space Register Mapping */ static const int pxa2xx_cp_reg_map[0x10] = { - [0x0 ... 0xf] = -1, [0x0] = ICIP, [0x1] = ICMR, [0x2] = ICLR, @@ -216,6 +215,7 @@ static const int pxa2xx_cp_reg_map[0x10] = { [0x8] = ICLR2, [0x9] = ICFP2, [0xa] = ICPR2, + [0xb ... 0xf] = -1, }; static uint64_t pxa2xx_pic_cp_read(CPUARMState *env, const ARMCPRegInfo *ri)
Signed-off-by: Stefan Weil <sw@weilnetz.de> --- This patch is rather old, but it still can be applied. It avoids duplicate definitions for some array indices (which are allowed by gcc, but cgcc complains). hw/arm/pxa2xx_pic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)