From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Fabio Estevam <festevam@gmail.com>,
linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
linux@arm.linux.org.uk, sam@ravnborg.org,
Fabio Estevam <fabio.estevam@freescale.com>,
kernel@pengutronix.de
Subject: Re: [PATCH v2] compiler.h: Include <linux/bug.h> to avoid build breakage with ARRAY_SIZE()
Date: Thu, 5 Apr 2012 20:52:07 +0200 [thread overview]
Message-ID: <20120405185207.GE27274@pengutronix.de> (raw)
In-Reply-To: <4F7DE60B.5000904@windriver.com>
On Thu, Apr 05, 2012 at 02:35:55PM -0400, Paul Gortmaker wrote:
> On 12-04-04 10:29 AM, Uwe Kleine-König wrote:
> > Hello,
> >
> > On Fri, Mar 02, 2012 at 09:22:02AM -0500, Paul Gortmaker wrote:
> >> On 12-03-01 10:13 PM, Fabio Estevam wrote:
> >>> On Thu, Mar 1, 2012 at 11:49 PM, Paul Gortmaker
> >>> <paul.gortmaker@windriver.com> wrote:
> >>>
> >>>> Thanks, but no.
> >>>>
> >>>> You missed the whole point of my previous comments -- that being
> >>>> that we don't want to just jam headers into always-used headers.
> >>>
> >>> Yes, it is not clear for me how to fix this build error. I got
> >>> different feedbacks from you, Russell and Sam.
> >>
> >> Understood, there was some discussion there. Anyways it is already
> >> dealt with in yesterday's linux-next tree, so you won't have the
> >> build failure anymore.
> > I hit that same problem in an not yet mainlined source file. A simple
> > file containing only:
>
> A quick check shows about 15000 instances in mainline. Even if 1% of
> those were blowing up, I'd expect a full mailbox.
>
> >
> > #include <linux/kernel.h>
> >
> > int array[3];
> >
> > int func(void)
> > {
> > return ARRAY_SIZE(array);
>
> Well, ARRAY_SIZE is just a convenient macro that uses BUG content.
> Hiding it behind a name doesn't change the fact that you've
> implicitly decided to use bug.h content. Maybe you really don't
> want to be using it. Maybe we should have:
>
> --------------------------------------
> --- a/include/linux/kernel.h
> +++ b/include/linux/kernel.h
> @@ -43,6 +43,7 @@
> #define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a)))
> #define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0)
>
> +#define __ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
> #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
>
> /*
> ------------------------------------
>
> and give people a choice?
>
> Don't get me wrong. I'm not all extremist about this. If it turns
> out that it seems to cause way too much grief, and someone like Andrew
> says "Yeah, lets put #include <linux/bug.h> back in kernel.h" then I
> won't hesitate to do that. But given that code currently in mainline
> isn't blowing up all over, I wasn't yet convinced we needed to do that.
I didn't intend to readd bug.h to kernel.h. Just wanted to know if
adding #include <linux/bug.h> to my source file is the right thing to
do after your change.
Another alternative is to put ARRAY_SIZE into it's own header and let
that include <linux/bug.h>. Not sure this is a sane approach though.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
prev parent reply other threads:[~2012-04-05 18:52 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 ` [PATCH v2] compiler.h: " Fabio Estevam
2012-03-02 2:49 ` 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 [this message]
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=20120405185207.GE27274@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=akpm@linux-foundation.org \
--cc=fabio.estevam@freescale.com \
--cc=festevam@gmail.com \
--cc=kernel@pengutronix.de \
--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).