summaryrefslogtreecommitdiff
path: root/options
diff options
context:
space:
mode:
authorAdam Simpkins <simpkins@fb.com>2019-04-04 12:05:42 -0700
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2019-04-04 12:12:11 -0700
commitc06c4c01c5891220ec212c497678477a7d55f89c (patch)
treecfabb4a378703a3023c39fe294e47213bdd35323 /options
parentf0edf9d57554c7726c58cc2c08aa8193f88f3240 (diff)
Fix many bugs in log statement arguments (#5089)
Summary: Annotate all of the logging functions to inform the compiler that these use printf-style formatting arguments. This allows the compiler to emit warnings if the format arguments are incorrect. This also fixes many problems reported now that format string checking is enabled. Many of these are simply mix-ups in the argument type (e.g, int vs uint64_t), but in several cases the wrong number of arguments were being passed in which can cause the code to crash. The primary motivation for this was to fix the log message in `DBImpl::SwitchMemtable()` which caused a segfault due to an extra %s format parameter with no argument supplied. Pull Request resolved: https://github.com/facebook/rocksdb/pull/5089 Differential Revision: D14574795 Pulled By: simpkins fbshipit-source-id: 0921b03f0743652bf4ae21e414ff54b3bb65422a
Diffstat (limited to 'options')
-rw-r--r--options/db_options.cc11
-rw-r--r--options/options.cc11
2 files changed, 13 insertions, 9 deletions
diff --git a/options/db_options.cc b/options/db_options.cc
index b9950e09e..f24705cb7 100644
--- a/options/db_options.cc
+++ b/options/db_options.cc
@@ -180,7 +180,7 @@ void ImmutableDBOptions::Dump(Logger* log) const {
log, " Options.sst_file_manager.rate_bytes_per_sec: %" PRIi64,
sst_file_manager ? sst_file_manager->GetDeleteRateBytesPerSecond() : 0);
ROCKS_LOG_HEADER(log, " Options.wal_recovery_mode: %d",
- wal_recovery_mode);
+ static_cast<int>(wal_recovery_mode));
ROCKS_LOG_HEADER(log, " Options.enable_thread_tracking: %d",
enable_thread_tracking);
ROCKS_LOG_HEADER(log, " Options.enable_pipelined_write: %d",
@@ -197,7 +197,8 @@ void ImmutableDBOptions::Dump(Logger* log) const {
write_thread_slow_yield_usec);
if (row_cache) {
ROCKS_LOG_HEADER(
- log, " Options.row_cache: %" PRIu64,
+ log,
+ " Options.row_cache: %" ROCKSDB_PRIszt,
row_cache->GetCapacity());
} else {
ROCKS_LOG_HEADER(log,
@@ -280,8 +281,10 @@ void MutableDBOptions::Dump(Logger* log) const {
stats_dump_period_sec);
ROCKS_LOG_HEADER(log, " Options.stats_persist_period_sec: %d",
stats_persist_period_sec);
- ROCKS_LOG_HEADER(log, " Options.stats_history_buffer_size: %d",
- stats_history_buffer_size);
+ ROCKS_LOG_HEADER(
+ log,
+ " Options.stats_history_buffer_size: %" ROCKSDB_PRIszt,
+ stats_history_buffer_size);
ROCKS_LOG_HEADER(log, " Options.max_open_files: %d",
max_open_files);
ROCKS_LOG_HEADER(log,
diff --git a/options/options.cc b/options/options.cc
index 3076590cf..2c9954581 100644
--- a/options/options.cc
+++ b/options/options.cc
@@ -173,12 +173,12 @@ void ColumnFamilyOptions::Dump(Logger* log) const {
ROCKS_LOG_HEADER(
log,
" Options.bottommost_compression_opts.max_dict_bytes: "
- "%" ROCKSDB_PRIszt,
+ "%" PRIu32,
bottommost_compression_opts.max_dict_bytes);
ROCKS_LOG_HEADER(
log,
" Options.bottommost_compression_opts.zstd_max_train_bytes: "
- "%" ROCKSDB_PRIszt,
+ "%" PRIu32,
bottommost_compression_opts.zstd_max_train_bytes);
ROCKS_LOG_HEADER(
log, " Options.bottommost_compression_opts.enabled: %s",
@@ -191,11 +191,11 @@ void ColumnFamilyOptions::Dump(Logger* log) const {
compression_opts.strategy);
ROCKS_LOG_HEADER(
log,
- " Options.compression_opts.max_dict_bytes: %" ROCKSDB_PRIszt,
+ " Options.compression_opts.max_dict_bytes: %" PRIu32,
compression_opts.max_dict_bytes);
ROCKS_LOG_HEADER(log,
" Options.compression_opts.zstd_max_train_bytes: "
- "%" ROCKSDB_PRIszt,
+ "%" PRIu32,
compression_opts.zstd_max_train_bytes);
ROCKS_LOG_HEADER(log,
" Options.compression_opts.enabled: %s",
@@ -350,7 +350,8 @@ void ColumnFamilyOptions::Dump(Logger* log) const {
force_consistency_checks);
ROCKS_LOG_HEADER(log, " Options.report_bg_io_stats: %d",
report_bg_io_stats);
- ROCKS_LOG_HEADER(log, " Options.ttl: %d", ttl);
+ ROCKS_LOG_HEADER(log, " Options.ttl: %" PRIu64,
+ ttl);
} // ColumnFamilyOptions::Dump
void Options::Dump(Logger* log) const {