]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/filestore: do not set never read variable
authorKefu Chai <kchai@redhat.com>
Thu, 28 Sep 2017 07:42:12 +0000 (15:42 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 29 Sep 2017 03:01:53 +0000 (11:01 +0800)
do not set "omap_fsid_fd" to -1 after ::close() it.

also move it's definition to where it is use for the first time for
better readability.

this silences the clang analyzer warning of:

Value stored to 'omap_fsid_fd' is never read

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/os/filestore/FileStore.cc

index cbbce6b01ebc9e325d39af403494b4ebe548688b..ed76406f810f631a0bffb95b63c8f20237d0e54d 100644 (file)
@@ -1656,7 +1656,6 @@ int FileStore::mount()
 
   // check fsid with omap
   // get omap fsid
-  int omap_fsid_fd;
   char omap_fsid_buf[PATH_MAX];
   struct ::stat omap_fsid_stat;
   snprintf(omap_fsid_buf, sizeof(omap_fsid_buf), "%s/osd_uuid", omap_dir.c_str());
@@ -1665,7 +1664,8 @@ int FileStore::mount()
     dout(10) << __FUNC__ << ": osd_uuid not found under omap, "
              << "assume as matched."
              << dendl;
-  }else{
+  } else {
+    int omap_fsid_fd;
     // if osd_uuid exists, compares osd_uuid with fsid
     omap_fsid_fd = ::open(omap_fsid_buf, O_RDONLY, 0644);
     if (omap_fsid_fd < 0) {
@@ -1677,7 +1677,6 @@ int FileStore::mount()
     }
     ret = read_fsid(omap_fsid_fd, &omap_fsid);
     VOID_TEMP_FAILURE_RETRY(::close(omap_fsid_fd));
-    omap_fsid_fd = -1; // defensive 
     if (ret < 0) {
       derr << __FUNC__ << ": error reading omap_fsid_fd"
            << ", omap_fsid = " << omap_fsid