Page MenuHomeFreeBSD

bwi: Fix clang 14 warning about possible unaligned access
ClosedPublic

Authored by dim on Feb 7 2022, 9:01 PM.
Tags
None
Referenced Files
F106535667: D34196.id102712.diff
Wed, Jan 1, 10:26 AM
Unknown Object (File)
Tue, Dec 31, 11:49 PM
Unknown Object (File)
Mon, Dec 9, 10:10 PM
Unknown Object (File)
Fri, Dec 6, 6:13 PM
Unknown Object (File)
Nov 27 2024, 12:41 AM
Unknown Object (File)
Nov 23 2024, 9:46 AM
Unknown Object (File)
Nov 13 2024, 6:07 AM
Unknown Object (File)
Nov 8 2024, 3:28 AM
Subscribers
None

Details

Summary

On architectures with strict alignment requirements (e.g. arm), clang 14
warns about a packed struct which encloses a non-packed union:

In file included from sys/dev/bwi/bwimac.c:79:
sys/dev/bwi/if_bwivar.h:308:7: error: field iv_val within 'struct bwi_fw_iv' is less aligned than 'union (unnamed union at sys/dev/bwi/if_bwivar.h:305:2)' and is usually due to 'struct bwi_fw_iv' being packed, which can lead to unaligned accesses [-Werror,-Wunaligned-access]
        }                       iv_val;
                                ^

It appears to help if you also add __packed to the inner union (i.e.
iv_val). No change to the layout is intended.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 44326
Build 41214: arc lint + arc unit