Init 'rbd' in open_rbd_image() with NULL and add a check for
'rbd' before dereference it to fix:
rbd_fuse/rbd-fuse.c:182:29: warning: variable 'rbd' may be uninitialized
when used here [-Wconditional-uninitialized]
int ret = rbd_open(ioctx, rbd->image_name, &(rbd->image), NULL);
^~~
rbd_fuse/rbd-fuse.c:151:27: note: initialize the variable 'rbd' to silence
this warning
struct rbd_openimage *rbd;
^
= NULL
Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
open_rbd_image(const char *image_name)
{
struct rbd_image *im;
- struct rbd_openimage *rbd;
+ struct rbd_openimage *rbd = NULL;
int fd;
if (image_name == (char *)NULL)
break;
}
}
- if (i == MAX_RBD_IMAGES)
+ if (i == MAX_RBD_IMAGES || !rbd)
return -1;
int ret = rbd_open(ioctx, rbd->image_name, &(rbd->image), NULL);
if (ret < 0) {