policy on externs

Greg KH greg at kroah.com
Sat Jun 2 13:33:46 EDT 2018


On Sat, Jun 02, 2018 at 05:23:20PM +0100, Justin Skists wrote:
> Hi,
> 
> What is the kernel policy on using "extern" to share variables between
> source files in a module?
> 
> I've been looking at one subsystem in staging [that shares variables quite a
> bit] to becoming familar with it, and seeing if I can help do some work on it
> in my free time.
> 
> Personally I prefer to see them eradicated (they polute the namespace), and
> store such variables in a context structure that is passed around. But I don't
> see any reference about it in the coding style, and I am not one to
> code-churn just because it's not my personal style! :)

context structures are almost always best, as they can be tied to the
hardware device, not the module itself.  So yes, if they can be
eradicated, please do so.

What driver are you looking at?

thanks,

greg k-h



More information about the Kernelnewbies mailing list