Skip to contentSkip to conversation

checkpatch.pl misreporting bugs with array fillings

DISCUSSION Marek Vasut 4 participants 6 messages Dec 16, 2011 – Dec 19, 2011

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
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_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE

testcase.c has style problems, please review.

Hmmm will have a look...

-apw

#2 lore raw
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_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE

testcase.c has 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

#3 lore raw
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_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

testcase.c has 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

#4 lore raw
In reply to Marek Vasut
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 },
};	
#5 lore raw
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