Skip to contentSkip to conversation

A smatch warning I dont understand in drivers/hwmon/max16065.c

DISCUSSION Dan Carpenter 2 participants 2 messages Aug 6, 2013 1 message not in the archive Sparse checker

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 9 lines · Guenter Roeck

Hi all,

I get the following warning while scanning drivers/hwmon/max16065.c.

drivers/hwmon/max16065.c:67:10: warning: Initializer entry defined twice
drivers/hwmon/max16065.c:68:10: also defined here
drivers/hwmon/max16065.c:76:10: warning: Initializer entry defined twice
drivers/hwmon/max16065.c:77:10: also defined here

Quoted 4 lines

I must have looked at the code half a dozen times, but I just don't see what might be wrong.

Any idea, anyone ?

This is actually a Sparse warning not a Smatch warning. To get the Smatch warnings (there aren't any) do:
~/path/to/smatch/smatch_scripts/kchecker --spammy drivers/hwmon/max16065.c

This problem is here is a bug in Sparse handling arrays of _Bool. Let me add the Sparse people to the CC list and a small test case.

static _Bool array_name[] = {
	[0] = 0,
	[1] = 0,
	[2] = 0,
	[3] = 0,
};

Sparse complains that element 1 was already initialized.

regards,
dan carpenter

#2 lore raw

Re: A sparse warning I dont understand in drivers/hwmon/max16065.c [was: smatch warning]

Quoted 10 lines · Dan Carpenter
Quoted 9 lines · Guenter Roeck

Hi all,

I get the following warning while scanning drivers/hwmon/max16065.c.

drivers/hwmon/max16065.c:67:10: warning: Initializer entry defined twice
drivers/hwmon/max16065.c:68:10: also defined here
drivers/hwmon/max16065.c:76:10: warning: Initializer entry defined twice
drivers/hwmon/max16065.c:77:10: also defined here

Quoted 7 lines
Quoted 4 lines

I must have looked at the code half a dozen times, but I just don't see what might be wrong.

Any idea, anyone ?

This is actually a Sparse warning not a Smatch warning. To get the Smatch warnings (there aren't any) do:

Thanks for the clarification. I updated the subject.

Guenter

Quoted 19 lines

~/path/to/smatch/smatch_scripts/kchecker --spammy drivers/hwmon/max16065.c

This problem is here is a bug in Sparse handling arrays of _Bool. Let me add the Sparse people to the CC list and a small test case.

static _Bool array_name[] = {
	[0] = 0,
	[1] = 0,
	[2] = 0,
	[3] = 0,
};

Sparse complains that element 1 was already initialized.

regards,
dan carpenter