From de79adc302cf944c56d8c11f7bbd9e859f61c741 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Fri, 30 Jul 2021 17:31:46 +0800 Subject: [PATCH] os/bluestore: always initialize variable MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit actually, target_size is always initialized as `id` should be `BlueFS::BDEV_NEWWAL` or `BlueFS::BDEV_NEWDB`. and it is ensured by ceph_assert(id == BlueFS::BDEV_NEWWAL || id == BlueFS::BDEV_NEWDB) at the beginning of `BlueStore::migrate_to_new_bluefs_device()`. but apparently, GCC is not able to figure this out: ../src/os/bluestore/BlueStore.cc: In member function ‘int BlueStore::migrate_to_new_bluefs_device(const std::set&, int, const string&)’: ../src/os/bluestore/BlueStore.cc:6876:35: warning: ‘target_size’ may be used uninitialized in this function [-Wmaybe-uninitialized] 6876 | r = _setup_block_symlink_or_file( | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ 6877 | target_name, | ~~~~~~~~~~~~ 6878 | dev_path, | ~~~~~~~~~ 6879 | target_size, | ~~~~~~~~~~~~ 6880 | true); | ~~~~~ in this change, target_size is always initialized to a known value to silence the warning. Signed-off-by: Kefu Chai --- src/os/bluestore/BlueStore.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index cd3d33329ff7d..28db74787fcfc 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -6814,7 +6814,7 @@ int BlueStore::migrate_to_new_bluefs_device(const set& devs_source, bluefs_layout.dedicated_wal = false; } - size_t target_size; + size_t target_size = 0; string target_name; if (id == BlueFS::BDEV_NEWWAL) { target_name = "block.wal"; -- 2.39.5