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 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 left a comment

Looks sensible to me.

@michicc michicc merged commit acb3d10 into OpenTTD:master Feb 13, 2020
8 checks passed
8 checks passed
Commit checker
Details
OpenTTD CI Build #20200213.1 succeeded
Details
OpenTTD CI (Linux linux-amd64-clang-3.9) Linux linux-amd64-clang-3.9 succeeded
Details
OpenTTD CI (Linux linux-amd64-gcc-6) Linux linux-amd64-gcc-6 succeeded
Details
OpenTTD CI (Linux linux-i386-gcc-6) Linux linux-i386-gcc-6 succeeded
Details
OpenTTD CI (MacOS) MacOS succeeded
Details
OpenTTD CI (Windows Win32) Windows Win32 succeeded
Details
OpenTTD CI (Windows Win64) Windows Win64 succeeded
Details
@Quipyowert2 Quipyowert2 deleted the Quipyowert2:format-strings branch Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.