From: Kefu Chai Date: Fri, 30 Jul 2021 09:31:46 +0000 (+0800) Subject: os/bluestore: always initialize variable X-Git-Tag: v17.1.0~1231^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=de79adc302cf944c56d8c11f7bbd9e859f61c741;p=ceph.git os/bluestore: always initialize variable 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 --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index cd3d33329ff7..28db74787fcf 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";