Re: Sparse warning: "initializer entry defined twice"

From: AmÃrico Wang
Date: Fri May 07 2010 - 02:07:51 EST


On Thu, May 06, 2010 at 06:43:10PM -0500, Steve French wrote:
>Sparse, but not gcc, throws a warning ("make modules C=1") as follows
>on the first two lines of the following array of booleans
>
> CHECK fs/smb2/misc.c
>fs/smb2/misc.c:456:23: warning: Initializer entry defined twice
>fs/smb2/misc.c:457:27: also defined here
>
>
>static const bool has_smb2_data_area[NUMBER_OF_SMB2_COMMANDS] = {
>ÂÂÂ /* SMB2_NEGOTIATE */ true,
>ÂÂÂ /* SMB2_SESSION_SETUP */ true,
>ÂÂÂ /* SMB2_LOGOFF */ false,
>ÂÂÂ /* SMB2_TREE_CONNECT */ÂÂÂ false,
>ÂÂÂ /* SMB2_TREE_DISCONNECT */ false,
>ÂÂÂ /* SMB2_CREATE */ true,
>ÂÂÂ /* SMB2_CLOSE */ false,
>ÂÂÂ /* SMB2_FLUSH */ false,
>ÂÂÂ /* SMB2_READ */ÂÂÂ true,
>ÂÂÂ /* SMB2_WRITE */ false,
>ÂÂÂ /* SMB2_LOCK */ÂÂÂ false,
>ÂÂÂ /* SMB2_IOCTL */ true,
>ÂÂÂ /* SMB2_CANCEL */ false, /* BB CHECK this not listed in documentation */
>ÂÂÂ /* SMB2_ECHO */ false,
>ÂÂÂ /* SMB2_QUERY_DIRECTORY */ true,
>ÂÂÂ /* SMB2_CHANGE_NOTIFY */ true,
>ÂÂÂ /* SMB2_QUERY_INFO */ true,
>ÂÂÂ /* SMB2_SET_INFO */ false,
>ÂÂÂ /* SMB2_OPLOCK_BREAK */ false
>};
>
>
>Any idea why sparse is complaining about the first two lines of the
>arry of booleans? Is this just a sparse bug?
>

Hmm, looks weird, sparse doesn't understand bool well?

Can you construct a small C program to show this? Something like:

typedef _Bool bool;
enum {
false = 0,
true = 1
};

static const bool foo[10] = {
true,
true,
false,
false,
};
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/