From 55853de661ce476281170ec90306b944df2234d9 Mon Sep 17 00:00:00 2001 From: Jay Zhuang Date: Fri, 21 May 2021 19:05:54 -0700 Subject: [PATCH] Fix clang-analyze: use uninitiated variable (#8325) Summary: Error: ``` db/db_compaction_test.cc:5211:47: warning: The left operand of '*' is a garbage value uint64_t total = (l1_avg_size + l2_avg_size * 10) * 10; ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/8325 Test Plan: `$ make analyze` Reviewed By: pdillinger Differential Revision: D28620916 Pulled By: jay-zhuang fbshipit-source-id: f6d58ab84eefbcc905cda45afb9522b0c6d230f8 --- db/db_compaction_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/db_compaction_test.cc b/db/db_compaction_test.cc index 696dd4cb5..37bea4ab1 100644 --- a/db/db_compaction_test.cc +++ b/db/db_compaction_test.cc @@ -5154,7 +5154,7 @@ TEST_F(DBCompactionTest, ManualCompactionBottomLevelOptimized) { } TEST_F(DBCompactionTest, ManualCompactionMax) { - uint64_t l1_avg_size, l2_avg_size; + uint64_t l1_avg_size = 0, l2_avg_size = 0; auto generate_sst_func = [&]() { Random rnd(301); for (auto i = 0; i < 100; i++) { @@ -5208,7 +5208,7 @@ TEST_F(DBCompactionTest, ManualCompactionMax) { ASSERT_TRUE(num_compactions.load() == 1); // split the compaction to 5 - uint64_t total = (l1_avg_size + l2_avg_size * 10) * 10; + uint64_t total = (l1_avg_size * 10) + (l2_avg_size * 100); int num_split = 5; opts.max_compaction_bytes = total / num_split; DestroyAndReopen(opts);