From fcd99d27c9b048f4a1b3bc3b8e8ac2c411bf1575 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 11 Jul 2017 10:28:18 -0700 Subject: [PATCH] db_bench_tool: fix buffer size Summary: Found by gcc warning: x86_64-pc-linux-gnu-g++ --version x86_64-pc-linux-gnu-g++ (GCC) 7.1.1 20170710 tools/db_bench_tool.cc: In member function 'void rocksdb::Benchmark::RandomWithVerify(rocksdb::ThreadState*)': tools/db_bench_tool.cc:4430:8: error: '%lu' directive output may be truncated writing between 1 and 19 bytes into a region of size between 0 and 66 [-Werror=format-truncation=] void RandomWithVerify(ThreadState* thread) { ^~~~~~~~~~~~~~~~ tools/db_bench_tool.cc:4430:8: note: directive argument in the range [0, 9223372036854775807] tools/db_bench_tool.cc:4492:13: note: 'snprintf' output between 37 and 128 bytes into a destination of size 100 snprintf(msg, sizeof(msg), ~~~~~~~~^~~~~~~~~~~~~~~~~~ "( get:%" PRIu64 " put:%" PRIu64 " del:%" PRIu64 " total:%" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PRIu64 " found:%" PRIu64 ")", ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gets_done, puts_done, deletes_done, readwrites_, found); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors Makefile:1707: recipe for target 'tools/db_bench_tool.o' failed Closes https://github.com/facebook/rocksdb/pull/2558 Differential Revision: D5398703 Pulled By: siying fbshipit-source-id: 6ffa552bbd8b59cfc2c36289f86ff9b9acca8ca6 --- tools/db_bench_tool.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index 5724a39ca..efa0ee10b 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -4488,7 +4488,7 @@ void VerifyDBFromDB(std::string& truth_db_name) { thread->stats.FinishedOps(&db_, db_.db, 1, kDelete); } } - char msg[100]; + char msg[128]; snprintf(msg, sizeof(msg), "( get:%" PRIu64 " put:%" PRIu64 " del:%" PRIu64 " total:%" \ PRIu64 " found:%" PRIu64 ")",