Re: [PATCH] include/linux/unaligned: Pack the whole struct ratherthan just the field.

From: Harvey Harrison
Date: Tue Dec 21 2010 - 18:36:14 EST


On Tue, Dec 21, 2010 at 2:43 AM, Will Newton <will.newton@xxxxxxxxx> wrote:
> On Tue, Dec 21, 2010 at 5:44 AM, Andrew Morton
>>> Â#include <linux/kernel.h>

>>>
>>> -struct __una_u16 { u16 x __attribute__((packed)); };
>>> -struct __una_u32 { u32 x __attribute__((packed)); };
>>> -struct __una_u64 { u64 x __attribute__((packed)); };
>>> +struct __una_u16 { u16 x; } __attribute__((packed));
>>> +struct __una_u32 { u32 x; } __attribute__((packed));
>>> +struct __una_u64 { u64 x; } __attribute__((packed));
>>>
>>
>> Yes, that was wrong.
>>
>> Do you think this bug affects 2.6.36 or earlier?

Interesting, I thought about this when modifying this awhile ago, and
was relying on this from the gcc manual:

packed
<snip>

Specifying this attribute for struct and union types is equivalent
to specifying the packed attribute on each of the


^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
structure or union members. Specifying the -fshort-enums flag on the
line is equivalent to specifying the packed
attribute on all enum definitions.

What version of gcc was this?

So, no objection to specifying packed on the struct definition rather
than the member, it was only done that way
as that was what was there when I made some of the code common.

Harvey
--
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/