Re: smatch/sparse complaints on static assertion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/11/20 4:36 PM, Linus Torvalds wrote:
On Tue, Feb 11, 2020 at 9:41 AM Shannon Nelson <snelson@xxxxxxxxxxx> wrote:
drivers/net/ethernet/pensando/ionic/ionic_dev.h:56:1: error: static
assertion failed: "sizeof(struct ionic_dev_getattr_comp) == 16"
As Luc says, this is because those structures are mis-declared.

See this, for example:

   struct ionic_dev_getattr_comp {
         u8     status;
         u8     rsvd[3];
         union {
                 __le64  features;
                 u8      rsvd2[11];
         };
         u8     color;
   };

and notice how "__le64  features" is a 64-bit entity but it's in a
union with a "u8 rsvd2[11];".

That makes the whole union align to the same as the __le64 (on x86-32,
that's 32-bit, for bad legacy reasons, on everything else it's
64-bit).

Mark the associated types properly packed individually, rather than
use the disgusting "pragma pack()" that should never be used.

This is not a recent sparse change, it must never have worked.

             Linus

Thanks, I'll try to work that into this next net-next cycle.

sln




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux