Fix svace defects 12/76512/3
authorKyungwook Tak <k.tak@samsung.com>
Fri, 24 Jun 2016 06:41:47 +0000 (15:41 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Fri, 24 Jun 2016 07:32:22 +0000 (16:32 +0900)
dead code on db manager
dereferencing nullable pointer on cs logic

Change-Id: Iec1b9f9f9fb329566a4b6d96e4cd129e87c70087
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
src/framework/db/manager.cpp
src/framework/service/cs-logic.cpp

index ad80dfb..932f690 100644 (file)
@@ -95,26 +95,30 @@ Manager::Manager(const std::string &dbfile, const std::string &scriptsDir) :
        // run migration if old database is present
        auto sv = this->getSchemaVersion();
 
-       if (sv < SchemaVersion::NOT_EXIST || sv > SchemaVersion::LATEST) {
-               ERROR("Database corrupted! invalid db version returned! : " << sv);
-               this->resetDatabase();
-               return;
-       } else if (sv == SchemaVersion::LATEST) {
+       switch (sv) {
+       case SchemaVersion::LATEST:
                DEBUG("Database version is latest");
-               return;
-       }
+               break;
 
-       if (sv == SchemaVersion::NOT_EXIST) {
+       case SchemaVersion::NOT_EXIST:
                INFO("Database initializing!");
                this->resetDatabase();
-       } else if (sv < SchemaVersion::LATEST) {
-               INFO("Database migration! from[" << sv <<
-                        "] to[" << SchemaVersion::LATEST << "]");
+               break;
 
-               for (int vi = sv; vi < SchemaVersion::LATEST; ++vi)
-                       this->m_conn.exec(this->getMigrationScript(vi).c_str());
+       default:
+               if (sv < SchemaVersion::NOT_EXIST || sv > SchemaVersion::LATEST) {
+                       ERROR("Database corrupted! invalid db version returned! : " << sv);
+                       this->resetDatabase();
+               } else {
+                       INFO("Database migration! from[" << sv <<
+                                "] to[" << SchemaVersion::LATEST << "]");
 
-               this->setSchemaVersion(SchemaVersion::LATEST);
+                       for (int vi = sv; vi < SchemaVersion::LATEST; ++vi)
+                               this->m_conn.exec(this->getMigrationScript(vi).c_str());
+
+                       this->setSchemaVersion(SchemaVersion::LATEST);
+               }
+               break;
        }
 
        this->m_conn.exec("VACUUM;");
index 57b9a0b..7b926e3 100644 (file)
@@ -246,18 +246,10 @@ CsDetectedPtr CsLogic::scanAppDelta(const std::string &pkgPath, const std::strin
 
 RawBuffer CsLogic::scanApp(const CsContext &context, const std::string &pkgPath)
 {
-       FilePtr fileptr;
-       try {
-               fileptr = File::create(pkgPath);
-       } catch (const Exception &e) {
-               if (e.error() == CSR_ERROR_FILE_DO_NOT_EXIST)
-                       WARN("Package path of file[" << pkgPath << "] doesn't exist or perm denied.");
-               else if (e.error() == CSR_ERROR_FILE_SYSTEM)
-                       WARN("Package path of file[" << pkgPath << "] type isn't regular file or dir.");
-               else
-                       throw;
-       }
+       auto fileptr = File::create(pkgPath);
 
+       if (!fileptr)
+               ThrowExc(CSR_ERROR_SERVER, "fileptr shouldn't be empty because didn't check modified");
        if (!fileptr->isInApp())
                ThrowExc(CSR_ERROR_SERVER, "fileptr should be in app.");