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>&, 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 <kchai@redhat.com>
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";