mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Trippelsdorf <markus@trippelsdorf.de>
To: Michal Marek <mmarek@suse.cz>
Cc: Joe Perches <joe@perches.com>,
	Nick Bowler <nbowler@elliptictech.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Mike Frysinger <vapier@gentoo.org>,
	Sam Ravnborg <sam@ravnborg.org>,
	Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Subject: {PATCH] fix __packed in exported kernel headers
Date: Fri, 24 Jun 2011 15:51:00 +0200	[thread overview]
Message-ID: <20110624135100.GB1708@x4.trippels.de> (raw)
In-Reply-To: <4E048C0D.7020403@suse.cz>

On 2011.06.24 at 15:07 +0200, Michal Marek wrote:
> On 23.6.2011 18:57, Joe Perches wrote:
> > On Thu, 2011-06-23 at 17:02 +0200, Markus Trippelsdorf wrote:
> >> On 2011.06.23 at 09:42 -0400, Nick Bowler wrote:
> >>> On 2011-06-22 08:34 +0200, Markus Trippelsdorf wrote:
> >>>> One possible solution would be to let the "scripts/headers_install.pl"
> >>>> script automatically substitute __packed with __attribute__((packed)):
> >>>>
> >>>> diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
> > []
> >> I'm not an expert of Perl regular expressions, but maybe this:
> >>   $line =~ s/\s__packed;$/ __attribute__((packed));/g
> >> is a little bit closer to the intention?
> >
> > Maybe:
> >
> > s/\b__packed\b/__attribute__((packed))/g
> 
> Markus, will you post a patch with this fix?
> 

checkpatch.pl warns about using __attribute__((packed)) in kernel
headers: "__packed is preferred over __attribute__((packed))". If one
follows that advice it could cause problems in the exported header
files, because the outside world doesn't know about this shortcut.

For example busybox will fail to compile:
 CC      miscutils/ubi_attach_detach.o
 In file included from miscutils/ubi_attach_detach.c:27:0:
 /usr/include/mtd/ubi-user.h:330:3: error: conflicting types for ‘__packed’
 /usr/include/mtd/ubi-user.h:314:3: note: previous declaration of ‘__packed’ was here
...

Fix the problem by substituting __packed with __attribute__((packed)) in
the header_install.pl script.

Cc: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
CC: Joe Perches <joe@perches.com>
Signed-off-by: Markus Trippelsdorf <markus@trippelsdorf.de>
---
 scripts/headers_install.pl |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
index efb3be1..48462be 100644
--- a/scripts/headers_install.pl
+++ b/scripts/headers_install.pl
@@ -35,6 +35,7 @@ foreach my $file (@files) {
 		$line =~ s/([\s(])__iomem\s/$1/g;
 		$line =~ s/\s__attribute_const__\s/ /g;
 		$line =~ s/\s__attribute_const__$//g;
+		$line =~ s/\b__packed\b/__attribute__((packed))/g;
 		$line =~ s/^#include <linux\/compiler.h>//;
 		$line =~ s/(^|\s)(inline)\b/$1__$2__/g;
 		$line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g;
-- 
Markus

  reply	other threads:[~2011-06-24 13:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-22  6:34 __packed vs. __attribute__((packed)) in " Markus Trippelsdorf
2011-06-23 13:42 ` Nick Bowler
2011-06-23 15:02   ` Markus Trippelsdorf
2011-06-23 16:57     ` Joe Perches
2011-06-24 13:07       ` Michal Marek
2011-06-24 13:51         ` Markus Trippelsdorf [this message]
2011-06-24 15:17           ` {PATCH] fix __packed in exported " Michal Marek
2011-06-24 16:33           ` Arnd Bergmann
2011-06-24 17:00             ` Mike Frysinger
2011-06-30 18:26               ` H. Peter Anvin
2011-06-30 18:48                 ` Mike Frysinger
2011-06-30 18:52                   ` H. Peter Anvin
2011-06-30 18:58                     ` Mike Frysinger
2011-06-30 19:01                       ` H. Peter Anvin
2011-06-30 19:13                         ` Mike Frysinger
2011-06-30 20:02                           ` H. Peter Anvin
2011-06-30 21:56                             ` Mike Frysinger
2011-06-24 17:01             ` Markus Trippelsdorf
2011-06-23 17:04 ` __packed vs. __attribute__((packed)) in " richard -rw- weinberger
2011-06-23 17:46   ` Markus Trippelsdorf
2011-06-23 17:54 ` Mike Frysinger

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=20110624135100.GB1708@x4.trippels.de \
    --to=markus@trippelsdorf.de \
    --cc=Artem.Bityutskiy@nokia.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.cz \
    --cc=nbowler@elliptictech.com \
    --cc=sam@ravnborg.org \
    --cc=vapier@gentoo.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

all inboxes | Powered by JetHome®