Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmds] Fix compiler warnings based on added -Wextra flag #2111

Merged
merged 2 commits into from
Nov 20, 2024
Merged

Conversation

ghaerr
Copy link
Owner

@ghaerr ghaerr commented Nov 20, 2024

Generally straightforward changes based on the easier-to-fix issues illuminated by adding -Wextra and -Wtype-limits to the kernel, elkscmd/ and libc/ compilations. There'll be a few more warnings showing up compiling the applications in elkscmds/ until more time is available to figure out or test exactly might be incorrect.

Initially, -Wsign-compare was turned on, but signed vs unsigned comparisons can be quite tricky so only a few instances were obviously correctable. The rest will have to wait, and the warning turned off since there are a bit too many of them.

Overall, some of the warnings flagged some pretty bad, mostly error, handling in some applications. A big red flag is comparing any unsigned integer (or typedef'd type) to < 0, which is always false. Many of the kernel read/write functions return size_t, which is unsigned, so comparing their success with < 0 doesn't work. I suspect this is because of the K&R old days, when those same functions returned int and people were able to use < 0 for error checking.

The math library has a couple problems with overflow/underflow comparing to +50000/-50000 which overflows 'int'. Since I can't yet figure a way to test, those warnings have been turned off for the time being.

@ghaerr ghaerr merged commit 6af601c into master Nov 20, 2024
2 checks passed
@ghaerr ghaerr deleted the extra branch November 20, 2024 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant