Page MenuHomeFreeBSD

libalias: Fix -Wcast-align compiler warnings
ClosedPublic

Authored by arichardson on Jan 1 2021, 4:21 PM.
Tags
None
Referenced Files
F82062840: D27882.id81477.diff
Thu, Apr 25, 4:23 AM
Unknown Object (File)
Tue, Apr 23, 2:11 PM
Unknown Object (File)
Feb 24 2024, 10:49 AM
Unknown Object (File)
Feb 24 2024, 10:49 AM
Unknown Object (File)
Feb 24 2024, 10:48 AM
Unknown Object (File)
Feb 24 2024, 10:48 AM
Unknown Object (File)
Feb 24 2024, 10:28 AM
Unknown Object (File)
Dec 30 2023, 12:44 AM
Subscribers

Details

Summary

This fixes -Wcast-align warnings caused by the underaligned struct ip.
This also silences them in the public functions by changing the function
signature from char * to void *. This is source and binary compatible and
avoids the -Wcast-align warning.

Diff Detail

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

Event Timeline

gbe added a subscriber: gbe.

LGTM for the manpage bits.

sys/netinet/libalias/alias.c
1215

The problem here is that struct ip is declared as packed, so taking a pointer to one of the uint32 members can break on architectures that don't allow unaligned stores.

This was introduced in 8018ac153f7671699ca008f31c0fad9caef2f531 and causes architectures such as RISC-V to always use two 16-bit loads+shifts to read struct in_addr.

If you tested the change and it works for you, I have no objection.

sys/netinet/libalias/alias.c
1260

I think we usually don't use such syntax with tabs.

This revision is now accepted and ready to land.Jan 19 2021, 10:07 AM
sys/netinet/libalias/alias.c
1260

Good point. I'm touching the line anyway so I might as well fix style issues at the same time.