linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* sparse: __pure declaration only
@ 2019-10-18 11:15 Ben Dooks
  2019-10-18 15:31 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Dooks @ 2019-10-18 11:15 UTC (permalink / raw)
  To: linux-sparse, linux-kernel

I'm seeing the following sparse warnings where the declaration
has __pure but the implementation does not.

> lib/bitmap.c:62:6: error: symbol '__bitmap_or_equal' redeclared with different type (originally declared at ./include/linux/bitmap.h:123) - different modifiers

is this a valid warning? if not, should sparse be ignoring these.

Note:
> include/linux/bitmap.h:extern bool __pure __bitmap_or_equal(const unsigned long *src1,
> lib/bitmap.c:bool __bitmap_or_equal(const unsigned long *bitmap1,


-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

https://www.codethink.co.uk/privacy.html

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

* Re: sparse: __pure declaration only
  2019-10-18 11:15 sparse: __pure declaration only Ben Dooks
@ 2019-10-18 15:31 ` Linus Torvalds
  2019-10-20  5:52   ` Luc Van Oostenryck
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2019-10-18 15:31 UTC (permalink / raw)
  To: Ben Dooks; +Cc: Sparse Mailing-list, linux-kernel

On Fri, Oct 18, 2019 at 4:15 AM Ben Dooks <ben.dooks@codethink.co.uk> wrote:
>
> is this a valid warning? if not, should sparse be ignoring these.

It's technically valid, but maybe it's not useful.

If we make sure that any pure bits from a declaration always make it
into the definition, then I suspect that the "was not declared"
warning (if the definition is non-static and seen without a
declaration) is sufficient.

Of course, sparse doesn't actually _care_ about "pure" in the
definition, only in the use, so right now it doesn't even make any
difference to sparse whether the definition has the "pure" or not.
It's only when the function is used that the "pure" matters (it makes
the call instruction be CSE'd like any other random instruction).

               Linus

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

* Re: sparse: __pure declaration only
  2019-10-18 15:31 ` Linus Torvalds
@ 2019-10-20  5:52   ` Luc Van Oostenryck
  0 siblings, 0 replies; 3+ messages in thread
From: Luc Van Oostenryck @ 2019-10-20  5:52 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Ben Dooks, Sparse Mailing-list, linux-kernel

On Fri, Oct 18, 2019 at 08:31:48AM -0700, Linus Torvalds wrote:
> On Fri, Oct 18, 2019 at 4:15 AM Ben Dooks <ben.dooks@codethink.co.uk> wrote:
> >
> > is this a valid warning? if not, should sparse be ignoring these.
> 
> It's technically valid, but maybe it's not useful.
> 
> If we make sure that any pure bits from a declaration always make it
> into the definition, then I suspect that the "was not declared"
> warning (if the definition is non-static and seen without a
> declaration) is sufficient.
> 
> Of course, sparse doesn't actually _care_ about "pure" in the
> definition, only in the use, so right now it doesn't even make any
> difference to sparse whether the definition has the "pure" or not.
> It's only when the function is used that the "pure" matters (it makes
> the call instruction be CSE'd like any other random instruction).

Yes, for 'pure' it doesn't matter much but it's a problem anyway.
For example with 'static':

$ cat file.c
static void foo(void);
void foo(void) { }

$ sparse file.c
file.c:2:6: warning: symbol 'foo' was not declared. Should it be static?

Which is kinda absurd: foo() was declared and was even declared static.
But the definition is a different symbol than its declaration (OK) which
doesn't 'inherit' the declaration's specifier/modifier/attributes.
It's on my to-be-fixed list for a long time but ..

-- Luc

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

end of thread, other threads:[~2019-10-20  5:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-18 11:15 sparse: __pure declaration only Ben Dooks
2019-10-18 15:31 ` Linus Torvalds
2019-10-20  5:52   ` Luc Van Oostenryck

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).