Re: __packed vs. __attribute__((packed)) in kernel headers

From: Markus Trippelsdorf
Date: Thu Jun 23 2011 - 13:46:34 EST


On 2011.06.23 at 19:04 +0200, richard -rw- weinberger wrote:
> On Wed, Jun 22, 2011 at 8:34 AM, Markus Trippelsdorf
> <markus@xxxxxxxxxxxxxxx> wrote:
> > A recent commit 3627924acf70a changed __attribute__ ((packed)) to
> > __packed in some UBI headers. This breaks the build of busybox:
> >
> > Â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
> > /usr/include/mtd/ubi-user.h:372:3: error: conflicting types for â__packedâ
> > /usr/include/mtd/ubi-user.h:314:3: note: previous declaration of â__packedâ was here
> > ...
> >
> > But this kind of change is suggested by checkpatch.pl:
> > ÂWARN("__packed is preferred over __attribute__((packed))\n
> >
> > 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
> > index efb3be1..e0dc065 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/\s__packed/__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;
> >
> > Any thoughts?
> >
>
> Hmm, this introduces a new error source.
> Whenever we change the definition of __packed we have to
> adjust headers_install.pl too.

That definition will never change as long as we use gcc.

The __packed shortcut was introduced 2007 (commit 82ddcb04057).
It's use in the exported header files could cause problems, because the
outside world doesn't necessarily know about that shortcut.

--
Markus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/