Reputation: 168
I'm using the checkpatch.pl script from the linux kernel for my own firmware since I use the same coding style (which I like).
There is just an error that I don't quite understand about global variables:
do not initialise globals to 0
For sure I want to avoid using globals as much as possible, but don't know why this is a style error?
Is it because some compilers don't put such globals in .BSS? (Usually they are smart enough)
Upvotes: 3
Views: 2307
Reputation: 54505
First, it is redundant, and increases the size of the kernel (not what is finally loaded, but by having explicit instructions to the linker which are unnecessary).
It is part of a larger problem: Supposing that you had two different object files to link together, with different ideas of how to initialize them. Then the linker has to detect that and produce a symbol conflict error. The script is concerned with that as well.
Further reading:
Upvotes: 2