Current-Users archive

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

alignment and packed structs

I just tried to compile if_iwn as a module. It failed with

dev/pci/if_iwn.c:2685:6: error: converting a packed 'struct iwn_fw_dump' pointer (alignment 1) to a 'uint32_t' {aka 'unsigned int'} pointer (alignment 4) may result in an unaligned pointer value [-Werror=address-of-packed-member]

I got around it with

diff -u -r1.17 if_iwnreg.h
--- if_iwnreg.h 19 Jul 2017 16:55:12 -0000      1.17
+++ if_iwnreg.h 6 Jan 2021 17:24:01 -0000
@@ -1447,7 +1447,7 @@
        uint32_t        src_line;
        uint32_t        tsf;
        uint32_t        time[2];
-} __packed;
+} __attribute__((aligned(4),packed));
 /* TLV firmware header. */
 struct iwn_fw_tlv_hdr {

Why isn't this necessary when building if_iwn.c as part of a kernel?
Is the above the right solution?



Home | Main Index | Thread Index | Old Index