]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
os/bluestore: always initialize variable
authorKefu Chai <kchai@redhat.com>
Fri, 30 Jul 2021 09:31:46 +0000 (17:31 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 30 Jul 2021 10:53:09 +0000 (18:53 +0800)
commitde79adc302cf944c56d8c11f7bbd9e859f61c741
tree9c7a9727563dda8c0e7ed1acc0f7d55301f4b5e7
parent59144a3fd0f590924185eb3c6644a4cb0c0db54a
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>&, 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>
src/os/bluestore/BlueStore.cc