From 75c2d63c3159e8987b0e1979362915f63c445aaa Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 20 Dec 2018 11:24:28 +0800 Subject: [PATCH] cls/rbd: init local var with known value MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit DirectoryState does not have an "invalid" enum so far, since it's defined using `enum class`, init a value of this type with a known value could be a better choice even it is always initialized before being read. this silences the GCC warning of: src/cls/rbd/cls_rbd.cc:3147:3: warning: ‘on_disk_directory_state’ may be used uninitialized in this function [-Wmaybe-uninitialized] if (directory_state != on_disk_directory_state) { ^~ Signed-off-by: Kefu Chai --- src/cls/rbd/cls_rbd.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cls/rbd/cls_rbd.cc b/src/cls/rbd/cls_rbd.cc index 40bb1a05196..58f7001a988 100644 --- a/src/cls/rbd/cls_rbd.cc +++ b/src/cls/rbd/cls_rbd.cc @@ -3130,7 +3130,7 @@ int dir_remove_image(cls_method_context_t hctx, bufferlist *in, bufferlist *out) */ int dir_state_assert(cls_method_context_t hctx, bufferlist *in, bufferlist *out) { - cls::rbd::DirectoryState directory_state; + cls::rbd::DirectoryState directory_state = cls::rbd::DIRECTORY_STATE_READY; try { auto iter = in->cbegin(); decode(directory_state, iter); -- 2.47.3