rbd: silence bogus uninitialized warning in rbd_object_map_update_finish()
authorIlya Dryomov <idryomov@gmail.com>
Wed, 13 Nov 2019 11:07:15 +0000 (12:07 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 14 Nov 2019 18:00:53 +0000 (19:00 +0100)
Some versions of gcc (so far 6.3 and 7.4) throw a warning:

  drivers/block/rbd.c: In function 'rbd_object_map_callback':
  drivers/block/rbd.c:2124:21: warning: 'current_state' may be used uninitialized in this function [-Wmaybe-uninitialized]
        (current_state == OBJECT_EXISTS && state == OBJECT_EXISTS_CLEAN))
  drivers/block/rbd.c:2092:23: note: 'current_state' was declared here
    u8 state, new_state, current_state;
                          ^~~~~~~~~~~~~

It's bogus because all current_state accesses are guarded by
has_current_state.

Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
drivers/block/rbd.c

index 39136675dae5b381241a3ae2acce1cd93e2cfa39..13527a0b4e44896c42a516e4bf3ebe376c632be1 100644 (file)
@@ -2087,7 +2087,7 @@ static int rbd_object_map_update_finish(struct rbd_obj_request *obj_req,
        struct rbd_device *rbd_dev = obj_req->img_request->rbd_dev;
        struct ceph_osd_data *osd_data;
        u64 objno;
-       u8 state, new_state, current_state;
+       u8 state, new_state, uninitialized_var(current_state);
        bool has_current_state;
        void *p;