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

Codechange: Format unsigned integers with %u instead of %i or %d. #7997

Merged
merged 1 commit into from Feb 13, 2020

Conversation

Quipyowert2
Copy link
Contributor

This pull request fixes some of the following Cppcheck warnings about %i and %d with unsigned int. I didn't fix the warnings about using %x with signed int *, because I wasn't sure how to fix them.
Cppcheck output:

[src\fios.cpp:700]: (warning) %i in format string (no. 1) requires 'int *' but the argument type is 'unsigned int *'.
[src\newgrf_profiling.cpp:112]: (warning) %d in format string (no. 4) requires 'int' but the argument type is 'unsigned int'.
[src\network\network.cpp:920]: (warning) %x in format string (no. 1) requires 'unsigned int *' but the argument type is 'signed int *'.
[src\network\network.cpp:920]: (warning) %x in format string (no. 3) requires 'unsigned int *' but the argument type is 'signed int *'.
[src\network\network.cpp:928]: (warning) %x in format string (no. 1) requires 'unsigned int *' but the argument type is 'signed int *'.
[src\network\network.cpp:938]: (warning) %x in format string (no. 1) requires 'unsigned int *' but the argument type is 'signed int *'.
[src\pathfinder\npf\queue.cpp:306]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.
[src\pathfinder\npf\queue.cpp:306]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'.
[src\pathfinder\npf\queue.cpp:306]: (warning) %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'.
[src\pathfinder\npf\queue.cpp:306]: (warning) %d in format string (no. 4) requires 'int' but the argument type is 'unsigned int'.
[src\pathfinder\npf\queue.cpp:317]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'.
[src\pathfinder\npf\queue.cpp:317]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'.
[src\strgen\strgen.cpp:310]: (warning) %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'.

Copy link
Contributor

@nielsmh nielsmh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sensible to me.

@michicc michicc merged commit acb3d10 into OpenTTD:master Feb 13, 2020
@Quipyowert2 Quipyowert2 deleted the format-strings branch February 13, 2020 23:32
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.

None yet

3 participants