Page MenuHomeFreeBSD

ifconfig: Pacify a sign comparison warning in regdomain_sort.
ClosedPublic

Authored by jhb on Jun 19 2023, 5:06 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Mar 23, 6:33 PM
Unknown Object (File)
Mon, Mar 23, 10:56 AM
Unknown Object (File)
Wed, Mar 18, 9:00 AM
Unknown Object (File)
Sat, Mar 7, 5:10 PM
Unknown Object (File)
Sat, Feb 28, 2:56 PM
Unknown Object (File)
Sat, Feb 28, 4:37 AM
Unknown Object (File)
Thu, Feb 26, 9:37 PM
Unknown Object (File)
Feb 8 2026, 5:26 AM
Subscribers

Details

Summary

Both ic_flags values are unsigned (uint32_t), so cast them to a signed
int to generate a signed result. Both ic_req values are also
unsigned, but since they are uint16_t, they are implicitly promited to
int before the subtraction.

Reported by: GCC -Wsign-compare

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 52140
Build 49031: arc lint + arc unit

Event Timeline

I think this is fine and suspect that the actual order is not that important, but I wonder if it would be more clear to make it explicit?

something like

if (ca->ic_freq > cb->ic_freq)
        return 1;
else if (ca->ic_freq < cb->ic_freq)
        return -1;
else if (ca->ic_flags & CHAN_ALL > cb->ic_flags & CHAN_ALL)
...

(signs might be backwards)

This revision is now accepted and ready to land.Jun 19 2023, 5:17 PM

I almost did a broken out version like that, but it is a fair bit more verbose.