Re: Packed struct size issue
Dan Carpenter <[email protected]>
| Newsgroups | org.kernel.vger.smatch |
|---|---|
| Message-ID | <20190718093322.GD3111@kadam> |
On Wed, Jul 17, 2019 at 02:42:34PM +0100, John Levon wrote:
>
> Andy Fiddaman discovered:
>
> $ cat ./test.c
> #include <stdio.h>
> #include <stdint.h>
>
> struct t1 {
> uint8_t critical_warning;
> uint16_t temperature;
> uint8_t available_spare;
> } __packed;
>
> _Static_assert(sizeof(struct t1) == 4, "bad size for t1");
>
I've added Sparse mailing list to the CC.
It looks like the packed attribute is broken on upstream Sparse (from
April) as well and I would prefer if they fixed it and I pulled in their
fix. It's probably better to use __attribute__((packed)) instead of the
__packed macro in the test code.
regards,
dan carpenter