linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fabio Estevam <festevam@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, paul.gortmaker@windriver.com,
	linux@arm.linux.org.uk, sam@ravnborg.org,
	Fabio Estevam <fabio.estevam@freescale.com>
Subject: [PATCH v2] compiler.h: Include <linux/bug.h> to avoid build breakage with ARRAY_SIZE()
Date: Thu,  1 Mar 2012 22:15:22 -0300	[thread overview]
Message-ID: <1330650922-24143-1-git-send-email-festevam@gmail.com> (raw)
In-Reply-To: <1330436499-17190-1-git-send-email-fabio.estevam@freescale.com>

Building imx_v6_v7_defconfig generated the following build error:

arch/arm/mach-imx/cpu_op-mx51.c: In function 'mx51_get_cpu_op':
arch/arm/mach-imx/cpu_op-mx51.c:27: error: implicit declaration of function 'BUILD_BUG_ON_ZERO'

commit 6f863554 (kernel.h: doesn't explicitly use bug.h, so don't include it.)
has removed asm/debug.h from linux/kernel.h.

Quoting Russell King (http://www.spinics.net/lists/arm-kernel/msg161916.html)

"linux/kernel.h _does_ use bug stuff - in ARRAY_SIZE().

ARRAY_SIZE() uses __must_be_array(), which is defined in linux/compiler-gcc.h,
which is obtained via linux/compiler.h and linux/linkage.h.

linux/compiler-gcc.h defines __must_be_array() to be:
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))

and BUILD_BUG_ON_ZERO used to be in linux/kernel.h but got moved to
linux/bug.h.

Hence why people are seeing build breakage with ARRAY_SIZE()."

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
Changes since v1:
- Move linux/bug.h to linux/compiler.h

 include/linux/compiler.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 4a24354..0300fb7 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -46,6 +46,7 @@ extern void __chk_io_ptr(const volatile void __iomem *);
 
 #ifdef __GNUC__
 #include <linux/compiler-gcc.h>
+#include <linux/bug.h>
 #endif
 
 #define notrace __attribute__((no_instrument_function))
-- 
1.7.1


  parent reply	other threads:[~2012-03-02  1:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-28 13:41 [PATCH] kernel.h: Include <linux/bug.h> to avoid build breakage with ARRAY_SIZE() Fabio Estevam
2012-02-28 15:51 ` Sam Ravnborg
2012-02-28 16:43   ` Paul Gortmaker
2012-02-28 20:06     ` Sam Ravnborg
2012-03-02  1:15 ` Fabio Estevam [this message]
2012-03-02  2:49   ` [PATCH v2] compiler.h: " Paul Gortmaker
2012-03-02  3:13     ` Fabio Estevam
2012-03-02 14:22       ` Paul Gortmaker
2012-04-04 14:29         ` Uwe Kleine-König
2012-04-05 18:35           ` Paul Gortmaker
2012-04-05 18:52             ` Uwe Kleine-König

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=1330650922-24143-1-git-send-email-festevam@gmail.com \
    --to=festevam@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=fabio.estevam@freescale.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=paul.gortmaker@windriver.com \
    --cc=sam@ravnborg.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;
as well as URLs for NNTP newsgroup(s).