Page MenuHomeFreeBSD

Fix type errors.
ClosedPublic

Authored by kib on Jan 23 2021, 10:51 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 5 2024, 12:04 PM
Unknown Object (File)
Jan 5 2024, 8:59 PM
Unknown Object (File)
Jan 5 2024, 8:59 PM
Unknown Object (File)
Jan 5 2024, 8:59 PM
Unknown Object (File)
Jan 5 2024, 8:59 PM
Unknown Object (File)
Jan 5 2024, 8:59 PM
Unknown Object (File)
Jan 5 2024, 8:46 PM
Unknown Object (File)
Jan 1 2024, 8:42 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
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

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.