Page MenuHomeFreeBSD

libalias: Fix -Wcast-align compiler warnings
ClosedPublic

Authored by arichardson on Jan 1 2021, 4:21 PM.

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
R10 FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; 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
1259

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
1259

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