From e7d544b1d26b1bd1bc2675b1e959b427cea2b7b5 Mon Sep 17 00:00:00 2001 From: liuchang0812 Date: Tue, 20 Dec 2016 16:53:58 +0800 Subject: [PATCH] os/filestore: version will be uninitialized varible if store_version doesn't exist http://people.redhat.com/bhubbard/scan-build/report-95c661.html#EndPath Signed-off-by: liuchang0812 --- src/os/filestore/FileStore.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/os/filestore/FileStore.cc b/src/os/filestore/FileStore.cc index df0c63b89f98..25221bd84d21 100644 --- a/src/os/filestore/FileStore.cc +++ b/src/os/filestore/FileStore.cc @@ -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) -- 2.47.3