Skip to contentSkip to conversation

Warnings on global symbols accessed only from assembly code

DISCUSSION Ahmed S. Darwish 2 participants 5 messages Feb 12, 2010 – Feb 14, 2010 Sparse checker

lore
Share & tools
lore
#0 lore raw

Hi,

Is there a way to let sparse avoid emitting warnings like:

symbol 'X' was not declared. Should it be static?

for global methods that are only accessed from assembly files?

The reason is that a declaration for such methods - which are usually bootstrap ones - can given the false impression of being used by some C code 'somewhere'.

Unfortunately the current `-Wno-decl' solution is a bit extreme: it turns off a very useful sparse feature (by design).

Thanks,

Signature · 2 lines
Darwish
http://darwish.07.googlepages.com
maintainer
#1 lore raw
Quoted 8 lines · Ahmed S. Darwish

Hi,

Is there a way to let sparse avoid emitting warnings like:

  symbol 'X' was not declared. Should it be static?

for global methods that are only accessed from assembly files?

You mean other than declare it as function prototype first? No that I know of.

The reason behind sparse is that, if this function is shared, it should shared by some header file and declared some where.

Quoted 3 lines

The reason is that a declaration for such methods - which are usually bootstrap ones - can given the false impression of being used by some C code 'somewhere'.

Sparse does not care about who call those function, C code or asm code. Sparse don't not actually link the program so it can't know this symbol is actually externally used or not.

Personally, I don't see why you can't declare those functions even if they are called from asm.

Quoted 2 lines

Unfortunately the current `-Wno-decl' solution is a bit extreme: it turns off a very useful sparse feature (by design).

Right, the problem is that sparse can't tell which functions are used in asm files and only skip warning on those.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 6 lines · Christopher Li

On Thu, Feb 11, 2010 at 4:00 PM, Ahmed S. Darwish <[email protected]> wrote:
[..]

Quoted 3 lines

The reason is that a declaration for such methods - which are usually bootstrap ones - can given the false impression of being used by some C code 'somewhere'.

Quoted 7 lines

Sparse does not care about who call those function, C code or asm code. Sparse don't not actually link the program so it can't know this symbol is actually externally used or not.

Personally, I don't see why you can't declare those functions even if they are called from asm.

Yes, the declarations are doable of course, but they'll be for-the-sake- -of-sparse thing.

The case I faced was kernel's main entrance C method which should only be jumped to from bootstrap asm code. I think a declaration in such case will only give bogus function usage impressions.

Quoted 6 lines
Quoted 2 lines

Unfortunately the current `-Wno-decl' solution is a bit extreme: it turns off a very useful sparse feature (by design).

Right, the problem is that sparse can't tell which functions are used in asm files and only skip warning on those.

Would proposing an __attribute__ for such case be accepted in concept?

Quoted 1 line

Chris

Thanks a lot

Signature · 2 lines
Darwish
http://darwish.07.googlepages.com
maintainer
#3 lore raw
Quoted 4 lines · Ahmed S. Darwish

The case I faced was kernel's main entrance C method which should only be jumped to from bootstrap asm code. I think a declaration in such case will only give bogus function usage impressions.

How about give it some prototype which clearly indicate the function should be only call from boot strap? e.g. BOOT_STRAP_ENTRY(function_name) which expand it to a function prototype.

Quoted 9 lines
Quoted 7 lines
Quoted 3 lines

Unfortunately the current `-Wno-decl' solution is a bit extreme: it turns off a very useful sparse feature (by design).

Right, the problem is that sparse can't tell which functions are used in asm files and only skip warning on those.

Would proposing an __attribute__ for such case be accepted in concept?

I don't thing it justify more non-stander attribute, which is for-the-sake-of-sparse
thing as well.

Chris

#4 lore raw
Quoted 10 lines · Christopher Li
Quoted 4 lines · Ahmed S. Darwish

The case I faced was kernel's main entrance C method which should only be jumped to from bootstrap asm code. I think a declaration in such case will only give bogus function usage impressions.

How about give it some prototype which clearly indicate the function should be only call from boot strap? e.g. BOOT_STRAP_ENTRY(function_name) which expand it to a function prototype.

mm, yes, I guess this can be a good-enough solution :)

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

Unfortunately the current `-Wno-decl' solution is a bit extreme: it turns off a very useful sparse feature (by design).

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Right, the problem is that sparse can't tell which functions are used in asm files and only skip warning on those.

Would proposing an __attribute__ for such case be accepted in concept?

I don't thing it justify more non-stander attribute, which is for-the-sake-of-sparse thing as well.

It seems those non-standard attributes have some associated costs that I'm not aware of; I can see the implicit trade-off then.

Quoted 1 line

Chris

Thanks for the sincere help.

Signature · 2 lines
Darwish
http://darwish.07.googlepages.com