Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1386732 > unrolled thread

[RFC] Add missing #include <linux/bug.h>

Started byEric Engestrom <eric.engestrom@imgtec.com>
First post2016-04-25 20:20 +0200
Last post2016-04-25 20:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [RFC] Add missing #include <linux/bug.h> Eric Engestrom <eric.engestrom@imgtec.com> - 2016-04-25 20:20 +0200
    Re: [RFC] Add missing #include <linux/bug.h> Andrew Morton <akpm@linux-foundation.org> - 2016-04-25 20:40 +0200

#1386732 — [RFC] Add missing #include <linux/bug.h>

FromEric Engestrom <eric.engestrom@imgtec.com>
Date2016-04-25 20:20 +0200
Subject[RFC] Add missing #include <linux/bug.h>
Message-ID<rrTh0-1RH-17@gated-at.bofh.it>
ARRAY_SIZE uses BUILD_BUG_ON_ZERO, which is undefined is you don't
include linux/bug.h first, which just happened to me.

Is there any reason this include isn't here? A quick grep found 595
other files using a define from bug.h without ever including it.

If this is a simple mistake and was forgotten, I can send an actual
patchset to fix this, but it feels like it was left out on purpose.

Cheers,
  Eric Engestrom

PS: If this is a cleanup that needs to be done, I might to it for other
headers as well.

---
 include/linux/compiler-gcc.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index eeae401..01e6869 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -2,6 +2,8 @@
 #error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
 #endif
 
+#include <linux/bug.h>
+
 /*
  * Common definitions for all gcc versions go here.
  */
-- 
2.8.1

[toc] | [next] | [standalone]


#1386738

FromAndrew Morton <akpm@linux-foundation.org>
Date2016-04-25 20:40 +0200
Message-ID<rrTAl-22j-7@gated-at.bofh.it>
In reply to#1386732
On Mon, 25 Apr 2016 19:10:55 +0100 Eric Engestrom <eric.engestrom@imgtec.com> wrote:

> ARRAY_SIZE uses BUILD_BUG_ON_ZERO, which is undefined is you don't
> include linux/bug.h first, which just happened to me.
> 
> Is there any reason this include isn't here? A quick grep found 595
> other files using a define from bug.h without ever including it.

yeah.  A lot of the kernel compiles by accident ;) We just fix stuff
when it blows up - it ain't pretty but this process works acceptably
well.

> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -2,6 +2,8 @@
>  #error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
>  #endif
>  
> +#include <linux/bug.h>
> +
>  /*
>   * Common definitions for all gcc versions go here.
>   */

hm, it Seems Wrong to include bug.h into compiler.h - the latter is
such a low-level infrastructury thing.  As evidenced by the fact that
bug.h explicitly includes compiler.h!

The bottom line is that our headers are just too large and complex and
try to do too much stuff.  Going finer-grained is always a good fix,
but I don't think you want to be adding a new array_size.h!

I guess we could move __must_be_array() into kernel.h and use #ifdef
__GNUC__ (or whatever).  But that adds to kernel.h (another) dependency
on bug.h, which kernel.h doesn't (and probably shouldn't and possibly
can't) include.  Sucks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web