From acb3d10832c92c9f93c3a4d50b00774274bac8c7 Mon Sep 17 00:00:00 2001 From: Quipyowert2 <38995150+Quipyowert2@users.noreply.github.com> Date: Wed, 12 Feb 2020 21:04:53 -0800 Subject: [PATCH] Codechange: Format unsigned integers with %u instead of %i or %d. --- src/fios.cpp | 2 +- src/newgrf_profiling.cpp | 2 +- src/pathfinder/npf/queue.cpp | 10 +++++----- src/strgen/strgen.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/fios.cpp b/src/fios.cpp index 24487174b8..61f08d93a9 100644 --- a/src/fios.cpp +++ b/src/fios.cpp @@ -697,7 +697,7 @@ public: if (f == nullptr) return false; ScenarioIdentifier id; - int fret = fscanf(f, "%i", &id.scenid); + int fret = fscanf(f, "%u", &id.scenid); FioFCloseFile(f); if (fret != 1) return false; strecpy(id.filename, filename, lastof(id.filename)); diff --git a/src/newgrf_profiling.cpp b/src/newgrf_profiling.cpp index e9a0dd92d2..17f32384d7 100644 --- a/src/newgrf_profiling.cpp +++ b/src/newgrf_profiling.cpp @@ -109,7 +109,7 @@ uint32 NewGRFProfiler::Finish() fputs("Tick,Sprite,Feature,Item,CallbackID,Microseconds,Depth,Result\n", f); for (const Call &c : this->calls) { - fprintf(f, "%u,%u,0x%X,%d,0x%X,%u,%u,%u\n", c.tick, c.root_sprite, c.feat, c.item, (uint)c.cb, c.time, c.subs, c.result); + fprintf(f, "%u,%u,0x%X,%u,0x%X,%u,%u,%u\n", c.tick, c.root_sprite, c.feat, c.item, (uint)c.cb, c.time, c.subs, c.result); total_microseconds += c.time; } diff --git a/src/pathfinder/npf/queue.cpp b/src/pathfinder/npf/queue.cpp index 64ea3bfcae..960cda8e5c 100644 --- a/src/pathfinder/npf/queue.cpp +++ b/src/pathfinder/npf/queue.cpp @@ -305,16 +305,16 @@ void Hash::PrintStatistics() const } printf( "---\n" - "Hash size: %d\n" - "Nodes used: %d\n" - "Non empty buckets: %d\n" - "Max collision: %d\n", + "Hash size: %u\n" + "Nodes used: %u\n" + "Non empty buckets: %u\n" + "Max collision: %u\n", this->num_buckets, this->size, used_buckets, max_collision ); printf("{ "); for (i = 0; i <= max_collision; i++) { if (usage[i] > 0) { - printf("%d:%d ", i, usage[i]); + printf("%u:%u ", i, usage[i]); #if 0 if (i > 0) { uint j; diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index c59be0021d..87bac5ab63 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -310,7 +310,7 @@ struct HeaderFileWriter : HeaderWriter, FileWriter { fprintf(this->fh, "\n" "static const uint LANGUAGE_PACK_VERSION = 0x%X;\n" - "static const uint LANGUAGE_MAX_PLURAL = %d;\n" + "static const uint LANGUAGE_MAX_PLURAL = %u;\n" "static const uint LANGUAGE_MAX_PLURAL_FORMS = %d;\n\n", (uint)data.Version(), (uint)lengthof(_plural_forms), max_plural_forms );