[vlc-devel] [PATCH] Use appropriate printf format specifier macro
Marc Gonzalez
marc.w.gonzalez at free.fr
Thu Dec 19 10:41:38 CET 2019
From: Marc Gonzalez <marc.w.gonzalez at free.fr>
Date: Thu, 19 Dec 2019 10:00:42 +0100
On some platforms, uint64_t and unsigned long long are not equivalent.
src/processor/stackwalk_fmt_json.cc: In function 'std::__cxx11::string google_breakpad::{anonymous}::ToHex(uint64_t)':
src/processor/stackwalk_fmt_json.cc:74:34: error: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t {aka long unsigned int}' [-Werror=format=]
sprintf(buffer, "0x%llx", value);
^
src/processor/stackwalk_fmt_json.cc: In function 'std::__cxx11::string google_breakpad::{anonymous}::ToInt(uint64_t)':
src/processor/stackwalk_fmt_json.cc:80:32: error: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t {aka long unsigned int}' [-Werror=format=]
sprintf(buffer, "%llu", value);
^
src/processor/stackwalk_fmt_json.cc: In function 'void google_breakpad::{anonymous}::AddRegister(Json::Value&, const char*, uint64_t)':
src/processor/stackwalk_fmt_json.cc:164:48: error: format '%llx' expects argument of type 'long long unsigned int', but argument 4 has type 'uint64_t {aka long unsigned int}' [-Werror=format=]
snprintf(buf, sizeof(buf), "0x%016llx", value);
^
Fix the above warnings by using PRIu64 and PRIx64.
Signed-off-by: Marc Gonzalez <marc.w.gonzalez at free.fr>
---
src/processor/stackwalk_fmt_json.cc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/processor/stackwalk_fmt_json.cc b/src/processor/stackwalk_fmt_json.cc
index 82ad0e06..d8b48f2f 100644
--- a/src/processor/stackwalk_fmt_json.cc
+++ b/src/processor/stackwalk_fmt_json.cc
@@ -71,13 +71,13 @@ const unsigned kTailFramesWhenTruncating = 10;
static string ToHex(uint64_t value) {
char buffer[32];
- sprintf(buffer, "0x%llx", value);
+ sprintf(buffer, "0x%" PRIx64, value);
return buffer;
}
static string ToInt(uint64_t value) {
char buffer[32];
- sprintf(buffer, "%llu", value);
+ sprintf(buffer, "%" PRIu64, value);
return buffer;
}
@@ -161,7 +161,7 @@ void AddRegister(Json::Value& registers, const char* reg,
void AddRegister(Json::Value& registers, const char* reg,
uint64_t value) {
char buf[19];
- snprintf(buf, sizeof(buf), "0x%016llx", value);
+ snprintf(buf, sizeof(buf), "0x%016" PRIx64, value);
registers[reg] = buf;
}
--
2.17.1
More information about the vlc-devel
mailing list