Coverity error handling 86/175086/1
authorsurya.kumar7 <surya.kumar7@samsung.com>
Fri, 6 Apr 2018 14:27:38 +0000 (19:57 +0530)
committersurya.kumar7 <surya.kumar7@samsung.com>
Fri, 6 Apr 2018 14:28:54 +0000 (19:58 +0530)
This patch handles return value from sqlite3 function

Coverity: 108596

Signed-off-by: surya.kumar7 <surya.kumar7@samsung.com>
Change-Id: I94b669d856bc0213274fc1d86857fd395bb846d6

common/app_db.cc

index fa6a3c6..386b8da 100644 (file)
@@ -218,7 +218,7 @@ void SqliteDB::Initialize() {
     sqldb_ = NULL;
     return;
   }
-  sqlite3_busy_handler(sqldb_, [](void *, int count) {
+  ret = sqlite3_busy_handler(sqldb_, [](void *, int count) {
     if (count < 5) {
       LOGGER(ERROR) << "App db was busy, Wait the lock count(" << count << ")";
       usleep(100000*(count+1));
@@ -228,6 +228,9 @@ void SqliteDB::Initialize() {
       return 0;
     }
   }, NULL);
+  if (ret != SQLITE_OK) {
+    LOGGER(ERROR) << "Failed to register busy handler: " << sqlite3_errmsg(sqldb_);
+  }
 
   char *errmsg = NULL;
   ret = sqlite3_exec(sqldb_, kCreateDbQuery, NULL, NULL, &errmsg);