Re: Packed struct size issue

Dan Carpenter <[email protected]>
Newsgroups org.kernel.vger.smatch
Message-ID <20190718105035.GE3111@kadam>
[ resending to the correct Sparse email address ].

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.