summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-03-13 21:55:44 +0100
committerGitHub <noreply@github.com>2019-03-13 21:55:44 +0100
commit9efc07f582bc4a5f3aba2aa10c48a24a508b172a (patch)
tree1f625e96bc3b17fb542e47f137a4fd5cafae4418 /vespalib
parent0fa91e324d9779e3681a13fe471bcba329506a8b (diff)
parent7e5c6b9fa64e2a1cb6f294dff0c9d7f5f3f67901 (diff)
Merge pull request #8781 from vespa-engine/toregge/fix-format-strings-6
Fix format strings in searchcorespi, fastlib, storageframework, vespalib and streamingvisitors module.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/tests/zcurve/zcurve_ranges_test.cpp5
-rw-r--r--vespalib/src/vespa/vespalib/data/slime/json_format.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/io/fileutil.cpp28
-rw-r--r--vespalib/src/vespa/vespalib/trace/trace.cpp2
-rw-r--r--vespalib/src/vespa/vespalib/util/compress.cpp8
-rw-r--r--vespalib/src/vespa/vespalib/util/compressor.cpp2
6 files changed, 24 insertions, 23 deletions
diff --git a/vespalib/src/tests/zcurve/zcurve_ranges_test.cpp b/vespalib/src/tests/zcurve/zcurve_ranges_test.cpp
index d4acbf3bd30..b0af41667c1 100644
--- a/vespalib/src/tests/zcurve/zcurve_ranges_test.cpp
+++ b/vespalib/src/tests/zcurve/zcurve_ranges_test.cpp
@@ -2,6 +2,7 @@
#include <vespa/vespalib/testkit/test_kit.h>
#include <vespa/vespalib/geo/zcurve.h>
#include <vector>
+#include <cinttypes>
typedef vespalib::geo::ZCurve Z;
@@ -12,9 +13,9 @@ bool inside(int x, int y, const Z::RangeVector &ranges) {
return true;
}
}
- fprintf(stderr, "FAILED: (%d, %d) -> (%ld) not in:\n", x, y, z);
+ fprintf(stderr, "FAILED: (%d, %d) -> (%" PRId64 ") not in:\n", x, y, z);
for (auto range: ranges) {
- fprintf(stderr, " [%ld, %ld]\n", range.min(), range.max());
+ fprintf(stderr, " [%" PRId64 ", %" PRId64 "]\n", range.min(), range.max());
}
return false;
}
diff --git a/vespalib/src/vespa/vespalib/data/slime/json_format.cpp b/vespalib/src/vespa/vespalib/data/slime/json_format.cpp
index 3e06529cd5b..637be8db999 100644
--- a/vespalib/src/vespa/vespalib/data/slime/json_format.cpp
+++ b/vespalib/src/vespa/vespalib/data/slime/json_format.cpp
@@ -61,7 +61,7 @@ struct JsonEncoder : public ArrayTraverser,
}
}
void encodeLONG(int64_t value) {
- out.printf("%ld", value);
+ out.printf("%" PRId64, value);
}
void encodeDOUBLE(double value) {
if (std::isnan(value) || std::isinf(value)) {
diff --git a/vespalib/src/vespa/vespalib/io/fileutil.cpp b/vespalib/src/vespa/vespalib/io/fileutil.cpp
index 5c3cd04cbb4..3f54b83bee6 100644
--- a/vespalib/src/vespa/vespalib/io/fileutil.cpp
+++ b/vespalib/src/vespa/vespalib/io/fileutil.cpp
@@ -257,23 +257,23 @@ File::verifyDirectIO(uint64_t buf, size_t bufsize, off_t offset) const
{
if (offset % 512 != 0) {
LOG(error,
- "Access to file %s failed because offset %zd wasn't 512-byte "
- "aligned. Buffer memory address was %zx, length %zu",
- _filename.c_str(), offset, buf, bufsize);
+ "Access to file %s failed because offset %" PRIu64 " wasn't 512-byte "
+ "aligned. Buffer memory address was %" PRIx64 ", length %zu",
+ _filename.c_str(), static_cast<uint64_t>(offset), buf, bufsize);
assert(false);
}
if (buf % 512 != 0) {
LOG(error,
- "Access to file %s failed because buffer memory address %zx "
- "wasn't 512-byte aligned. Offset was %zd, length %zu",
- _filename.c_str(), buf, offset, bufsize);
+ "Access to file %s failed because buffer memory address %" PRIx64 " "
+ "wasn't 512-byte aligned. Offset was %" PRIu64 ", length %zu",
+ _filename.c_str(), buf, static_cast<uint64_t>(offset), bufsize);
assert(false);
}
if (bufsize % 512 != 0) {
LOG(error,
"Access to file %s failed because buffer size %zu wasn't 512-byte "
- "aligned. Buffer memory address was %zx, offset %zd",
- _filename.c_str(), bufsize, buf, offset);
+ "aligned. Buffer memory address was %" PRIx64 ", offset %" PRIu64,
+ _filename.c_str(), bufsize, buf, static_cast<uint64_t>(offset));
assert(false);
}
}
@@ -283,7 +283,7 @@ File::write(const void *buf, size_t bufsize, off_t offset)
{
++_fileWrites;
size_t left = bufsize;
- LOG(debug, "write(%s): Writing %" PRIu64 " bytes at offset %" PRIu64 ".",
+ LOG(debug, "write(%s): Writing %zu bytes at offset %" PRIu64 ".",
_filename.c_str(), bufsize, offset);
if (_flags & DIRECTIO) {
@@ -293,13 +293,13 @@ File::write(const void *buf, size_t bufsize, off_t offset)
while (left > 0) {
ssize_t written = ::pwrite(_fd, buf, left, offset);
if (written > 0) {
- LOG(spam, "write(%s): Wrote %" PRIu64 " bytes at offset %" PRIu64 ".",
+ LOG(spam, "write(%s): Wrote %zd bytes at offset %" PRIu64 ".",
_filename.c_str(), written, offset);
left -= written;
buf = ((const char*) buf) + written;
offset += written;
} else if (written == 0) {
- LOG(spam, "write(%s): Wrote %" PRIu64 " bytes at offset %" PRIu64 ".",
+ LOG(spam, "write(%s): Wrote %zd bytes at offset %" PRIu64 ".",
_filename.c_str(), written, offset);
assert(false); // Can this happen?
} else if (errno != EINTR && errno != EAGAIN) {
@@ -319,7 +319,7 @@ File::read(void *buf, size_t bufsize, off_t offset) const
{
++_fileReads;
size_t remaining = bufsize;
- LOG(debug, "read(%s): Reading %" PRIu64 " bytes from offset %" PRIu64 ".",
+ LOG(debug, "read(%s): Reading %zu bytes from offset %" PRIu64 ".",
_filename.c_str(), bufsize, offset);
if (_flags & DIRECTIO) {
@@ -329,7 +329,7 @@ File::read(void *buf, size_t bufsize, off_t offset) const
while (remaining > 0) {
ssize_t bytesread = ::pread(_fd, buf, remaining, offset);
if (bytesread > 0) {
- LOG(spam, "read(%s): Read %" PRIu64 " bytes from offset %" PRIu64 ".",
+ LOG(spam, "read(%s): Read %zd bytes from offset %" PRIu64 ".",
_filename.c_str(), bytesread, offset);
remaining -= bytesread;
buf = ((char*) buf) + bytesread;
@@ -720,7 +720,7 @@ copy(const string & frompath, const string & topath,
size_t sourceSize = source.getFileSize();
if (useDirectIO && sourceSize % diskAlignmentSize != 0) {
LOG(warning, "copy(%s, %s): Cannot use direct IO to write new file, "
- "as source file has size %" PRIu64 ", which is not "
+ "as source file has size %zu, which is not "
"dividable by the disk alignment size of %u.",
frompath.c_str(), topath.c_str(), sourceSize, diskAlignmentSize);
useDirectIO = false;
diff --git a/vespalib/src/vespa/vespalib/trace/trace.cpp b/vespalib/src/vespa/vespalib/trace/trace.cpp
index 4d0ecc0e9df..8ca2ef6561c 100644
--- a/vespalib/src/vespa/vespalib/trace/trace.cpp
+++ b/vespalib/src/vespa/vespalib/trace/trace.cpp
@@ -54,7 +54,7 @@ Trace::trace(uint32_t level, const string &note, bool addTime)
if (addTime) {
struct timeval tv;
gettimeofday(&tv, NULL);
- _root.addChild(make_string("[%ld.%06ld] %s", tv.tv_sec, tv.tv_usec, note.c_str()));
+ _root.addChild(make_string("[%ld.%06ld] %s", tv.tv_sec, static_cast<long>(tv.tv_usec), note.c_str()));
} else {
_root.addChild(note);
}
diff --git a/vespalib/src/vespa/vespalib/util/compress.cpp b/vespalib/src/vespa/vespalib/util/compress.cpp
index 617b632e0bf..12f511f9062 100644
--- a/vespalib/src/vespa/vespalib/util/compress.cpp
+++ b/vespalib/src/vespa/vespalib/util/compress.cpp
@@ -15,7 +15,7 @@ size_t Integer::compressedPositiveLength(uint64_t n)
} else if ( n < (0x1 << 30)) {
return 4;
} else {
- throw IllegalArgumentException(make_string("Number '%lu' too big, must extend encoding", n));
+ throw IllegalArgumentException(make_string("Number '%" PRIu64 "' too big, must extend encoding", n));
}
}
@@ -37,7 +37,7 @@ size_t Integer::compressPositive(uint64_t n, void *destination)
d[3] = n & 0xff;
return 4;
} else {
- throw IllegalArgumentException(make_string("Number '%lu' too big, must extend encoding", n));
+ throw IllegalArgumentException(make_string("Number '%" PRIu64 "' too big, must extend encoding", n));
}
}
@@ -53,7 +53,7 @@ size_t Integer::compressedLength(int64_t n)
} else if ( n < (0x1 << 29)) {
return 4;
} else {
- throw IllegalArgumentException(make_string("Number '%ld' too big, must extend encoding", n));
+ throw IllegalArgumentException(make_string("Number '%" PRId64 "' too big, must extend encoding", n));
}
}
@@ -78,7 +78,7 @@ size_t Integer::compress(int64_t n, void *destination)
d[3] = n & 0xff;
return 4;
} else {
- throw IllegalArgumentException(make_string("Number '%ld' too big, must extend encoding", negative ? -n : n));
+ throw IllegalArgumentException(make_string("Number '%" PRId64 "' too big, must extend encoding", negative ? -n : n));
}
}
diff --git a/vespalib/src/vespa/vespalib/util/compressor.cpp b/vespalib/src/vespa/vespalib/util/compressor.cpp
index 6853c8375fd..efa61197739 100644
--- a/vespalib/src/vespa/vespalib/util/compressor.cpp
+++ b/vespalib/src/vespa/vespalib/util/compressor.cpp
@@ -84,7 +84,7 @@ decompress(ICompressor & decompressor, size_t uncompressedLen, const ConstBuffer
dest.writeBytes(org.c_str(), org.size());
}
} else {
- throw std::runtime_error(make_string("unprocess failed had %" PRIu64 ", wanted %" PRId64 ", got %" PRIu64,
+ throw std::runtime_error(make_string("unprocess failed had %zu, wanted %zu, got %zu",
org.size(), uncompressedLen, realUncompressedLen));
}
} else {