From: Josh Triplett <josh@joshtriplett.org>
To: David Howells <dhowells@redhat.com>
Cc: ksummit-discuss@lists.linuxfoundation.org
Subject: Re: [Ksummit-discuss] Should we force include <linux/err.h> when compiling all .c files?
Date: Fri, 25 Jul 2014 16:24:29 -0700 [thread overview]
Message-ID: <20140725232429.GD19618@jtriplet-mobl1> (raw)
In-Reply-To: <22709.1406291979@warthog.procyon.org.uk>
On Fri, Jul 25, 2014 at 01:39:39PM +0100, David Howells wrote:
> Should we forcibly include <linux/err.h> from the gcc command line when
> compiling all .c files? Note:
>
> warthog>git grep -l '#.*include.*<linux/err[.]h>' -- \*.c | wc -l
> 1797
>
> vs:
>
> warthog>git grep -l 'IS_ERR\|ERR_PTR\|PTR_ERR\|ERR_CAST' -- \*.c | wc -l
> 4472
>
> So a lot fewer .c files include it than use it, but according to:
>
> 1: If you use a facility then #include the file that defines/declares
> that facility. Don't depend on other header files pulling in ones
> that you use.
>
> as pointed out to me by Stephen, it shouldn't be assumed that it's available.
>
>
> However, passing errors in pointers is so very common within the kernel, it
> might worth be adding linux/err.h to the automatically included stuff.
~/src/linux$ git grep -l 'IS_ERR\|ERR_PTR\|PTR_ERR\|ERR_CAST' -- '*.c' | wc -l
4467
~/src/linux$ find -name '*.c' | wc -l
20430
Functionality used by less than a quarter of the source files in the
kernel doesn't make sense to automatically include. You have a clear
test that shows whether a file uses this functionality, which would
allow an automated patch adding the necessary #include lines.
That does raise an interesting general issue, though: when a change to
the kernel would involve patching several thousand files, and would
potentially produce a huge number of conflicts (and a huge number of
patches if broken out by subsystem) if fed through the normal process,
but can be described by a very short script that requires no manual
intervention, might it make sense to have a clear procedure for saying
"Hey Linus, can you please run this script on top-of-tree and commit the
result?"?
- Josh Triplett
next prev parent reply other threads:[~2014-07-25 23:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-25 12:39 David Howells
2014-07-25 23:24 ` Josh Triplett [this message]
2014-07-28 18:52 ` H. Peter Anvin
2014-07-28 20:16 ` Julia Lawall
2014-07-28 22:53 ` H. Peter Anvin
2014-07-29 14:35 ` Josh Triplett
2014-07-29 15:17 ` Luck, Tony
2014-07-29 16:50 ` Hugh Dickins
2014-07-29 19:06 ` Hugh Dickins
2014-07-29 14:24 ` Josh Triplett
2014-07-30 14:30 ` H. Peter Anvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140725232429.GD19618@jtriplet-mobl1 \
--to=josh@joshtriplett.org \
--cc=dhowells@redhat.com \
--cc=ksummit-discuss@lists.linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox