[Ksummit-discuss] Should we force include <linux/err.h> when compiling all .c files?

Hugh Dickins hughd at google.com
Tue Jul 29 16:50:34 UTC 2014

On Tue, 29 Jul 2014, Luck, Tony wrote:

> > Perhaps, though see above about the handling of new source files.
> Sounds like a job for checkpatch.pl to make sure that <linux/err.h>
> is included if a new file uses any of  'IS_ERR\|ERR_PTR\|PTR_ERR\|ERR_CAST'
> to help stop this spreading to new files.
> It might be harder, but presumably still possible, to have it also check if
> any use of those macros is added to a file ... but it couldn't tell just by
> looking at the patch ... it would have to peek at the original file to see
> if there was already a #include <linux/err.h>
> Without a check, or some regular scan, this problem is going to recur.

I keep wondering, what _is_ the problem being discussed here?

If someone uses IS_ERR etc without linux/err.h being included,
does the kernel behave in a dangerously unpredictable way?
Or does the build just fail?

So, there's a rule that everybody should include every header
file that's used directly by a particular source file.

Good rule, but somehow I doubt that omitting linux/err.h
is the sole example of that rule being broken.

And our response to that is to get the kbuild system to include
automatically any header files frequently forgotten?


More information about the Ksummit-discuss mailing list