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

@Quipyowert2 Quipyowert2 commented Feb 13, 2020

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

Looks sensible to me.

@michicc michicc merged commit acb3d10 into OpenTTD:master Feb 13, 2020
8 checks passed
@Quipyowert2 Quipyowert2 deleted the format-strings branch Feb 13, 2020
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