linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Sparse warning: "initializer entry defined twice" - sparse can't handle bool?
@ 2014-10-19  9:46 Mariusz Gorski
  2014-10-19 17:21 ` Randy Dunlap
  0 siblings, 1 reply; 4+ messages in thread
From: Mariusz Gorski @ 2014-10-19  9:46 UTC (permalink / raw)
  To: linux-kernel

Sparse throws the following warning, which I can't really understand:

$ make drivers/staging/vt6655/ C=2
[...]
  CHECK   drivers/staging/vt6655/datarate.c
drivers/staging/vt6655/datarate.c:302:40: warning: Initializer entry
defined twice
drivers/staging/vt6655/datarate.c:302:46:   also defined here

The code looks fine to me:
bool bAutoRate[MAX_RATE]    = {true, true, true, true, false, false,
true, true, true, true, true, true};

I've googled it and found only this LKML discussion:
https://lkml.org/lkml/2010/5/7/31

I've tested the suggested code sample and here are the results:
$ cat foo.c
typedef _Bool bool;
enum {
     false = 0,
     true = 1
};
static const bool foo[10] = {
       true,
       true,
       false,
       false,
};

$ sparse foo.c
foo.c:7:8: warning: Initializer entry defined twice
foo.c:8:8:   also defined here

It this a sparse problem?

Thanks,
Mariusz

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sparse warning: "initializer entry defined twice" - sparse can't handle bool?
  2014-10-19  9:46 Sparse warning: "initializer entry defined twice" - sparse can't handle bool? Mariusz Gorski
@ 2014-10-19 17:21 ` Randy Dunlap
  2014-10-19 21:40   ` Ramsay Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Randy Dunlap @ 2014-10-19 17:21 UTC (permalink / raw)
  To: Mariusz Gorski, linux-kernel, Linux-Sparse

[adding linux-sparse mailing list]

On 10/19/14 02:46, Mariusz Gorski wrote:
> Sparse throws the following warning, which I can't really understand:
> 
> $ make drivers/staging/vt6655/ C=2
> [...]
>   CHECK   drivers/staging/vt6655/datarate.c
> drivers/staging/vt6655/datarate.c:302:40: warning: Initializer entry
> defined twice
> drivers/staging/vt6655/datarate.c:302:46:   also defined here
> 
> The code looks fine to me:
> bool bAutoRate[MAX_RATE]    = {true, true, true, true, false, false,
> true, true, true, true, true, true};
> 
> I've googled it and found only this LKML discussion:
> https://lkml.org/lkml/2010/5/7/31
> 
> I've tested the suggested code sample and here are the results:
> $ cat foo.c
> typedef _Bool bool;
> enum {
>      false = 0,
>      true = 1
> };
> static const bool foo[10] = {
>        true,
>        true,
>        false,
>        false,
> };
> 
> $ sparse foo.c
> foo.c:7:8: warning: Initializer entry defined twice
> foo.c:8:8:   also defined here
> 
> It this a sparse problem?
> 
> Thanks,
> Mariusz
> --


-- 
~Randy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sparse warning: "initializer entry defined twice" - sparse can't handle bool?
  2014-10-19 17:21 ` Randy Dunlap
@ 2014-10-19 21:40   ` Ramsay Jones
  2014-10-20 21:00     ` Mariusz Gorski
  0 siblings, 1 reply; 4+ messages in thread
From: Ramsay Jones @ 2014-10-19 21:40 UTC (permalink / raw)
  To: Randy Dunlap, Mariusz Gorski, linux-kernel, Linux-Sparse

On 19/10/14 18:21, Randy Dunlap wrote:
> [adding linux-sparse mailing list]
> 
> On 10/19/14 02:46, Mariusz Gorski wrote:
>> Sparse throws the following warning, which I can't really understand:
>>
>> $ make drivers/staging/vt6655/ C=2
>> [...]
>>   CHECK   drivers/staging/vt6655/datarate.c
>> drivers/staging/vt6655/datarate.c:302:40: warning: Initializer entry
>> defined twice
>> drivers/staging/vt6655/datarate.c:302:46:   also defined here
>>
>> The code looks fine to me:
>> bool bAutoRate[MAX_RATE]    = {true, true, true, true, false, false,
>> true, true, true, true, true, true};
>>
>> I've googled it and found only this LKML discussion:
>> https://lkml.org/lkml/2010/5/7/31
>>
>> I've tested the suggested code sample and here are the results:
>> $ cat foo.c
>> typedef _Bool bool;
>> enum {
>>      false = 0,
>>      true = 1
>> };
>> static const bool foo[10] = {
>>        true,
>>        true,
>>        false,
>>        false,
>> };
>>
>> $ sparse foo.c
>> foo.c:7:8: warning: Initializer entry defined twice
>> foo.c:8:8:   also defined here
>>
>> It this a sparse problem?

Yes, I imagine you are using a sparse version of v0.5.0 or
earlier right?

This was fixed by commit b3e9d87c6 ("sparse: make bits_to_bytes
round up instead of down", 16-07-2014), which describes to
v0.5.0-17-gb3e9d87, which has not been included in a released
version yet. (if you don't mind building from source, you could
build the master branch using a clone the git repository at
git://git.kernel.org/pub/scm/devel/sparse/sparse.git).

I'm afraid that I don't know when the next release is due.

HTH

ATB,
Ramsay Jones



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Sparse warning: "initializer entry defined twice" - sparse can't handle bool?
  2014-10-19 21:40   ` Ramsay Jones
@ 2014-10-20 21:00     ` Mariusz Gorski
  0 siblings, 0 replies; 4+ messages in thread
From: Mariusz Gorski @ 2014-10-20 21:00 UTC (permalink / raw)
  To: Ramsay Jones; +Cc: Randy Dunlap, linux-kernel, Linux-Sparse

Yes, I've actually used outdated sparse in version 0.4.3. After
updating to the latest one, built from master in git repo, the issue
is gone. Thanks.

On 19 October 2014 23:40, Ramsay Jones <ramsay@ramsay1.demon.co.uk> wrote:
> On 19/10/14 18:21, Randy Dunlap wrote:
>> [adding linux-sparse mailing list]
>>
>> On 10/19/14 02:46, Mariusz Gorski wrote:
>>> Sparse throws the following warning, which I can't really understand:
>>>
>>> $ make drivers/staging/vt6655/ C=2
>>> [...]
>>>   CHECK   drivers/staging/vt6655/datarate.c
>>> drivers/staging/vt6655/datarate.c:302:40: warning: Initializer entry
>>> defined twice
>>> drivers/staging/vt6655/datarate.c:302:46:   also defined here
>>>
>>> The code looks fine to me:
>>> bool bAutoRate[MAX_RATE]    = {true, true, true, true, false, false,
>>> true, true, true, true, true, true};
>>>
>>> I've googled it and found only this LKML discussion:
>>> https://lkml.org/lkml/2010/5/7/31
>>>
>>> I've tested the suggested code sample and here are the results:
>>> $ cat foo.c
>>> typedef _Bool bool;
>>> enum {
>>>      false = 0,
>>>      true = 1
>>> };
>>> static const bool foo[10] = {
>>>        true,
>>>        true,
>>>        false,
>>>        false,
>>> };
>>>
>>> $ sparse foo.c
>>> foo.c:7:8: warning: Initializer entry defined twice
>>> foo.c:8:8:   also defined here
>>>
>>> It this a sparse problem?
>
> Yes, I imagine you are using a sparse version of v0.5.0 or
> earlier right?
>
> This was fixed by commit b3e9d87c6 ("sparse: make bits_to_bytes
> round up instead of down", 16-07-2014), which describes to
> v0.5.0-17-gb3e9d87, which has not been included in a released
> version yet. (if you don't mind building from source, you could
> build the master branch using a clone the git repository at
> git://git.kernel.org/pub/scm/devel/sparse/sparse.git).
>
> I'm afraid that I don't know when the next release is due.
>
> HTH
>
> ATB,
> Ramsay Jones
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-10-20 21:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-19  9:46 Sparse warning: "initializer entry defined twice" - sparse can't handle bool? Mariusz Gorski
2014-10-19 17:21 ` Randy Dunlap
2014-10-19 21:40   ` Ramsay Jones
2014-10-20 21:00     ` Mariusz Gorski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).