From de7c6b508b996fd2fcae0c11f964ba2f3b76b2d3 Mon Sep 17 00:00:00 2001 From: Seonah Moon Date: Tue, 20 Mar 2018 14:32:00 +0900 Subject: [PATCH] Fix svace issue WGID-328327 Change-Id: I797fad91a019e1ea666c57e55be5073f65ba9040 --- packaging/download-provider.spec | 2 +- provider/download-provider-db.c | 22 ++++++++++------------ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/packaging/download-provider.spec b/packaging/download-provider.spec index 18146b3..590b880 100755 --- a/packaging/download-provider.spec +++ b/packaging/download-provider.spec @@ -1,6 +1,6 @@ Name: download-provider Summary: Download the contents in background -Version: 2.1.92 +Version: 2.1.93 Release: 0 Group: Development/Libraries License: Apache-2.0 diff --git a/provider/download-provider-db.c b/provider/download-provider-db.c index 0cf3cc9..ccc05e1 100755 --- a/provider/download-provider-db.c +++ b/provider/download-provider-db.c @@ -50,6 +50,7 @@ static void __dp_finalize(sqlite3_stmt *stmt) static int __check_integrity(sqlite3 *handle) { sqlite3_stmt *stmt = NULL; + int ret = 0; if (handle == 0) { TRACE_ERROR("failed to check handle"); @@ -57,26 +58,23 @@ static int __check_integrity(sqlite3 *handle) } TRACE_INFO(""); - int ret = sqlite3_prepare_v2(handle, "PRAGMA integrity_check", -1, &stmt, NULL); - if (ret != SQLITE_OK && ret != SQLITE_BUSY) { + int errorcode = sqlite3_prepare_v2(handle, "PRAGMA integrity_check", -1, &stmt, NULL); + if (errorcode != SQLITE_OK && errorcode != SQLITE_BUSY) { TRACE_ERROR("failed to check integrity:%s", sqlite3_errmsg(handle)); - return -1; + ret = -1; } else { - ret = sqlite3_step(stmt); - if (ret == SQLITE_ROW) { + errorcode = sqlite3_step(stmt); + if (errorcode == SQLITE_ROW) { const char *ret_val = (const char *)sqlite3_column_text(stmt, 0); TRACE_INFO("ret_val: %s", ret_val); - if (ret_val && strcmp(ret_val, "ok") == 0) { - return 0; - } else { + if (!ret_val || strcmp(ret_val, "ok") != 0) { TRACE_ERROR("failed to check integrity"); - return -1; + ret = -1; } - } else { - return 0; } } - return 0; + __dp_finalize(stmt); + return ret; } static int __check_table(sqlite3 *handle, char *table) -- 2.7.4