Page MenuHomeFreeBSD

libalias: Fix -Wcast-align compiler warnings
ClosedPublic

Authored by arichardson on Jan 1 2021, 4:21 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 7, 3:58 AM
Unknown Object (File)
Oct 4 2024, 11:41 AM
Unknown Object (File)
Oct 4 2024, 6:50 AM
Unknown Object (File)
Oct 4 2024, 4:01 AM
Unknown Object (File)
Oct 1 2024, 7:36 PM
Unknown Object (File)
Oct 1 2024, 5:34 PM
Unknown Object (File)
Oct 1 2024, 2:52 PM
Unknown Object (File)
Sep 29 2024, 1:24 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
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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.