When building with clang, we see warnings such as:
error: field max_size within 'struct smbios_type7' is less aligned than
'union cache_size_word' and is usually due to 'struct smbios_type7'
being packed, which can lead to unaligned accesses
[-Werror,-Wunaligned-access]
when building drivers/sysinfo/smbios.c. Resolve this error by packing
the unions as well after verifying they are complete (16 or 32 bits).
Reviewed-by: Raymond Mao <raymondmaoca@gmail.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
char eos[SMBIOS_STRUCT_EOS_BYTES];
};
-union cache_config {
+union __packed cache_config {
struct {
u16 level:3;
u16 bsocketed:1;
u16 data;
};
-union cache_size_word {
+union __packed cache_size_word {
struct {
u16 size:15;
u16 granu:1;
u16 data;
};
-union cache_size_dword {
+union __packed cache_size_dword {
struct {
u32 size:31;
u32 granu:1;
u32 data;
};
-union cache_sram_type {
+union __packed cache_sram_type {
struct {
u16 other:1;
u16 unknown:1;