checkpatch.pl misreporting bugs with array fillings
Hi,
the following testcase is probably misreported by checkpatch.pl:
static const unsigned char pci_irq_swizzle[2][PCI_MAX_DEVICES] = {
{0, 0, 0, 0, 0, 0, 0, 27, 27, [9 ... PCI_MAX_DEVICES - 1] = 0 },
{0, 0, 0, 0, 0, 0, 0, 29, 29, [9 ... PCI_MAX_DEVICES - 1] = 0 },
};The result is:
ERROR: space prohibited before open square bracket '[' #2: FILE: testcase.c:2:
+ {0, 0, 0, 0, 0, 0, 0, 27, 27, [9 ... PCI_MAX_DEVICES - 1] = 0 },
ERROR: space prohibited before open square bracket '[' #3: FILE: testcase.c:3:
+ {0, 0, 0, 0, 0, 0, 0, 29, 29, [9 ... PCI_MAX_DEVICES - 1] = 0 },
total: 2 errors, 0 warnings, 5 lines checked
NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE
testcase.c has style problems, please review.
If any of these errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Cheers!
M
Quoted 19 lines · Marek Vasut
Hi,
the following testcase is probably misreported by checkpatch.pl:
static const unsigned char pci_irq_swizzle[2][PCI_MAX_DEVICES] = { {0, 0, 0, 0, 0, 0, 0, 27, 27, [9 ...
PCI_MAX_DEVICES- 1] = 0 }, {0, 0, 0, 0, 0, 0, 0, 29, 29, [9 ...PCI_MAX_DEVICES- 1] = 0 }, };The result is:
ERROR: space prohibited before open square bracket '['
#2: FILE: testcase.c:2:
+ {0, 0, 0, 0, 0, 0, 0, 27, 27, [9 ...PCI_MAX_DEVICES- 1] = 0 },ERROR: space prohibited before open square bracket '['
#3: FILE: testcase.c:3:
+ {0, 0, 0, 0, 0, 0, 0, 29, 29, [9 ...PCI_MAX_DEVICES- 1] = 0 },
Quoted 6 lines
total: 2 errors, 0 warnings, 5 lines checked
NOTE: Ignored message types:
COMPLEX_MACROCONSIDER_KSTRTOMINMAXMULTISTATEMENT_MACRO_USE_DO_WHILE
testcase.chas style problems, please review.
Hmmm will have a look...
-apw
Quoted 20 lines · Marek Vasut
Quoted 19 lines
Hi,
the following testcase is probably misreported by checkpatch.pl:
static const unsigned char pci_irq_swizzle[2][PCI_MAX_DEVICES] = { {0, 0, 0, 0, 0, 0, 0, 27, 27, [9 ... PCI_MAX_DEVICES - 1] = 0 }, {0, 0, 0, 0, 0, 0, 0, 29, 29, [9 ... PCI_MAX_DEVICES - 1] = 0 }, };The result is:
ERROR: space prohibited before open square bracket '[' #2: FILE: testcase.c:2:
+ {0, 0, 0, 0, 0, 0, 0, 27, 27, [9 ...PCI_MAX_DEVICES- 1] = 0 },ERROR: space prohibited before open square bracket '[' #3: FILE: testcase.c:3:
+ {0, 0, 0, 0, 0, 0, 0, 29, 29, [9 ...PCI_MAX_DEVICES- 1] = 0 },
Quoted 8 lines
Quoted 6 lines
total: 2 errors, 0 warnings, 5 lines checked
NOTE: Ignored message types:
COMPLEX_MACROCONSIDER_KSTRTOMINMAXMULTISTATEMENT_MACRO_USE_DO_WHILE
testcase.chas style problems, please review.Hmmm will have a look...
Thanks! I'd send a patch, but I'm now doing checkpatch cleanup of uboot sources so I'm just submitting a testcase and delegating the issue.
M
Quoted 4 lines · Marek Vasut
static const unsigned char pci_irq_swizzle[2][PCI_MAX_DEVICES] = {
{0, 0, 0, 0, 0, 0, 0, 27, 27, [9 ... PCI_MAX_DEVICES - 1] = 0 },
{0, 0, 0, 0, 0, 0, 0, 29, 29, [9 ... PCI_MAX_DEVICES - 1] = 0 },
};True.
Andy will probably figure it out.
He's the maintainer.
Still, in this case all the 0's are unnecessary.
I'd probably write that code as:
static const unsigned char pci_irq_swizzle[2][PCI_MAX_DEVICES] = {
{ [7] = 27, [8] = 27 },
{ [7] = 29, [8] = 29 },
}; Quoted 13 lines · Marek Vasut
Quoted 6 lines
static const unsigned char pci_irq_swizzle[2][PCI_MAX_DEVICES] = {
{0, 0, 0, 0, 0, 0, 0, 27, 27, [9 ... PCI_MAX_DEVICES - 1] = 0 }, {0, 0, 0, 0, 0, 0, 0, 29, 29, [9 ... PCI_MAX_DEVICES - 1] = 0 },};
True.
Andy will probably figure it out.
He's the maintainer.
Quoted 7 lines
Still, in this case all the 0's are unnecessary.
I'd probably write that code as:static const unsigned char pci_irq_swizzle[2][PCI_MAX_DEVICES] = { { [7] = 27, [8] = 27 }, { [7] = 29, [8] = 29 }, };
I suspect this is some remnant of ancient code where the people writing it were not sure if the memory under this is all-zeroes. (or the section this lands in wasn't zeroed-out)
M
Quoted 25 lines · Marek Vasut
Quoted 25 lines · Marek Vasut
Quoted 24 lines
Hi,
the following testcase is probably misreported by checkpatch.pl:
static const unsigned char pci_irq_swizzle[2][PCI_MAX_DEVICES] = { {0, 0, 0, 0, 0, 0, 0, 27, 27, [9 ... PCI_MAX_DEVICES - 1] = 0 }, {0, 0, 0, 0, 0, 0, 0, 29, 29, [9 ... PCI_MAX_DEVICES - 1] = 0 }, };The result is:
ERROR: space prohibited before open square bracket '[' #2: FILE: testcase.c:2:
+ {0, 0, 0, 0, 0, 0, 0, 27, 27, [9 ...PCI_MAX_DEVICES- 1] = 0 },ERROR: space prohibited before open square bracket '[' #3: FILE: testcase.c:3:
+ {0, 0, 0, 0, 0, 0, 0, 29, 29, [9 ...PCI_MAX_DEVICES- 1] = 0 },total: 2 errors, 0 warnings, 5 lines checked
NOTE: Ignored message types:
COMPLEX_MACROCONSIDER_KSTRTOMINMAXMULTISTATEMENT_MACRO_USE_DO_WHILE
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
testcase.chas style problems, please review.Hmmm will have a look...
Thanks! I'd send a patch, but I'm now doing checkpatch cleanup of uboot sources so I'm just submitting a testcase and delegating the issue.
Ok, this one may well be simple to fix. Does the version of checkpatch below work ok for you:
http://people.canonical.com/~apw/checkpatch/checkpatch-next.pl
-apw