RE: [PATCH v2] perf tools: Fix arm64 build error with gcc-11

From: David Laight
Date: Wed Feb 10 2021 - 10:22:44 EST


...
> > @@ -691,6 +691,7 @@ static int regs_map(struct regs_dump *regs, uint64_t mask, char *bf, int size)
> > {
> > unsigned int i = 0, r;
> > int printed = 0;
> > + const char *reg_name;
> >
> > bf[0] = 0;
> >
> > @@ -700,9 +701,10 @@ static int regs_map(struct regs_dump *regs, uint64_t mask, char *bf, int size)
> > for_each_set_bit(r, (unsigned long *) &mask, sizeof(mask) * 8) {
>
> a good practice is to limit scope of variables as much as possible, so
> reg_name could be declared here

I'd go for either function scope or a very small inner block
(like this one).

Otherwise it gets very difficult for the average human (or other
intelligent being) to locate the definition.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)