Page MenuHomeFreeBSD

Fix type errors.
ClosedPublic

Authored by kib on Jan 23 2021, 10:51 AM.

Details

Summary

Target value for val has uint32_t type, not uint, adjust used constant.
Cast val to unsigned so that left and right sides of comparision operator do not expose different signed types of same range.

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

kib requested review of this revision.Jan 23 2021, 10:51 AM
kib created this revision.

Will this give an is always false warning? Should we use strtoll instead

Add header for UINT32_MAX.

This still breaks buildworld on several archs:

/usr/src/usr.bin/elfctl/elfctl.c:258:35: error: use of undeclared identifier 'UINT32_MAX'

else if ((unsigned long)val > UINT32_MAX)

adding stdint.h fixes it

huh, bad timing

Will this give an is always false warning? Should we use strtoll instead

For me, the build worked. Are you worried about gcc?

For me, the build worked. Are you worried about gcc?

Ah, yes I see it builds fine with this change, but e.g. 0xffffffff doesn't work on 32-bit with long.

Switch to unsigned long long/strtoll

This revision is now accepted and ready to land.Jan 23 2021, 3:21 PM
This revision was automatically updated to reflect the committed changes.