[coreboot] What is the best way to treat warnings reported by checkpatch.pl
Stefan Reinauer
stefan.reinauer at coreboot.org
Thu Jul 28 21:58:19 CEST 2016
* Julius Werner <jwerner at chromium.org> [160727 23:41]:
> > typedef struct dmar_atsr_entry {
> > u16 type;
> > u16 length;
> > u8 flags;
> > u8 reserved;
> > u16 segment;
> > } __attribute__ ((packed)) dmar_atsr_entry_t;
>
> Looking at the original example here, I would still recommend not to
> use the packed attribute. It forces the compiler to use accesses that
> would work on unaligned data... for x86 that doesn't matter (and
> granted, this sounds x86-specific, but it's worth applying the same
> principles to all code), but for other architectures it may generate
> very inefficient code (even on ARM where unaligned accesses are okay
> after you turn on caching, GCC keeps doing this for all packed
> structures and there's no way to convince it otherwise). In this case,
> the members are all correctly aligned so there's no need to insert
> padding, so you can (and therefore should) leave out the packed
> attribute.
The point is, that without ((packed)) there is no guarantee that gcc
won't choose a different alignment over what you and I think would make
sense.
Stefan
More information about the coreboot
mailing list