]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/filestore: version will be uninitialized varible if store_version doesn't exist
authorliuchang0812 <liuchang0812@gmail.com>
Tue, 20 Dec 2016 08:53:58 +0000 (16:53 +0800)
committerliuchang0812 <liuchang0812@gmail.com>
Tue, 20 Dec 2016 08:53:58 +0000 (16:53 +0800)
http://people.redhat.com/bhubbard/scan-build/report-95c661.html#EndPath

Signed-off-by: liuchang0812 <liuchang0812@gmail.com>
src/os/filestore/FileStore.cc

index df0c63b89f98745980ba36745fe2c016e7b02c7c..25221bd84d21dd968f736ecc3fb10abf4d2c4bcf 100644 (file)
@@ -1255,8 +1255,6 @@ int FileStore::version_stamp_is_valid(uint32_t *version)
   int ret = safe_read_file(basedir.c_str(), "store_version",
       bp.c_str(), bp.length());
   if (ret < 0) {
-    if (ret == -ENOENT)
-      return 0;
     return ret;
   }
   bufferlist bl;
@@ -1286,6 +1284,11 @@ int FileStore::upgrade()
   dout(1) << "upgrade" << dendl;
   uint32_t version;
   int r = version_stamp_is_valid(&version);
+
+  if (r == -ENOENT) {
+      derr << "The store_version file doesn't exist." << dendl;
+      return -EINVAL;
+  }
   if (r < 0)
     return r;
   if (r == 1)