flow: fix some print/scan format warnings

Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
Austin Seipp 2019-05-03 19:01:43 -05:00 committed by Alex Miller
parent 41ae9cd0d8
commit 7a10199a35
3 changed files with 9 additions and 6 deletions

View File

@ -24,6 +24,7 @@
#include "flow/IndexedSet.h"
#include "flow/IRandom.h"
#include "flow/ThreadPrimitives.h"
#include <cinttypes>
#include <algorithm>
#include <set>
#include <string>
@ -401,7 +402,7 @@ TEST_CASE("/flow/IndexedSet/all numbers") {
int ib = ii != is.end() ? *ii : 1000000;
ASSERT(ib == b);
if (ib != b)
printf("%s %lld %d %d %lld\n", ib == b ? "OK" : "ERROR", n, b, ib, is.sumTo(ii));
printf("%s %" PRId64 " %d %d %" PRId64 "\n", ib == b ? "OK" : "ERROR", n, b, ib, is.sumTo(ii));
}
for (int i = 0; i<100000; i++) {
@ -414,7 +415,7 @@ TEST_CASE("/flow/IndexedSet/all numbers") {
int64_t ntotal = int64_t(b - a)*(a + b - 1) / 2;
ASSERT(itotal == ntotal);
if (itotal != ntotal)
printf("%s %lld %lld\n", itotal == ntotal ? "OK" : "ERROR", ntotal, itotal);
printf("%s %" PRId64 " %" PRId64 "\n", itotal == ntotal ? "OK" : "ERROR", ntotal, itotal);
}
//double a = timer();

View File

@ -21,6 +21,7 @@
#include "flow/Knobs.h"
#include "flow/flow.h"
#include <cmath>
#include <cinttypes>
FlowKnobs const* FLOW_KNOBS = new FlowKnobs();
@ -172,10 +173,10 @@ bool Knobs::setKnob( std::string const& knob, std::string const& value ) {
int64_t v;
int n=0;
if (StringRef(value).startsWith(LiteralStringRef("0x"))) {
if (sscanf(value.c_str(), "0x%llx%n", &v, &n) != 1 || n != value.size())
if (sscanf(value.c_str(), "0x%" SCNx64 "%n", &v, &n) != 1 || n != value.size())
throw invalid_option_value();
} else {
if (sscanf(value.c_str(), "%lld%n", &v, &n) != 1 || n != value.size())
if (sscanf(value.c_str(), "%" SCNd64 "%n", &v, &n) != 1 || n != value.size())
throw invalid_option_value();
}
if (int64_knobs.count(knob))

View File

@ -20,6 +20,7 @@
#include "flow/flow.h"
#include <stdarg.h>
#include <cinttypes>
INetwork *g_network = 0;
IRandom *g_random = 0;
@ -36,7 +37,7 @@ std::string UID::toString() const {
UID UID::fromString( std::string const& s ) {
ASSERT( s.size() == 32 );
uint64_t a=0, b=0;
int r = sscanf( s.c_str(), "%16llx%16llx", &a, &b );
int r = sscanf( s.c_str(), "%16" SCNx64 "%16" SCNx64, &a, &b );
ASSERT( r == 2 );
return UID(a, b);
}
@ -212,4 +213,4 @@ bool validationIsEnabled() {
void enableBuggify( bool enabled ) {
buggifyActivated = enabled;
}
}