From: hyunuktak Date: Thu, 17 Jan 2019 04:15:48 +0000 (+0900) Subject: Fix some svace issues for unchecking return value X-Git-Tag: accepted/tizen/unified/20190130.151736^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fconnectivity%2Fstc-manager.git;a=commitdiff_plain;h=310dd4f2b2c1be903aad780c092f1ed11cd5e549 Fix some svace issues for unchecking return value Change-Id: I87e056e9f8538f199a27f2bba7a204c5db21e7a5 Signed-off-by: hyunuktak --- diff --git a/packaging/stc-manager.spec b/packaging/stc-manager.spec index f83c3f0..6c7bbcf 100644 --- a/packaging/stc-manager.spec +++ b/packaging/stc-manager.spec @@ -1,6 +1,6 @@ Name: stc-manager Summary: STC(Smart Traffic Control) manager -Version: 0.0.88 +Version: 0.0.89 Release: 0 Group: Network & Connectivity/Other License: Apache-2.0 diff --git a/src/database/tables/table-counters.c b/src/database/tables/table-counters.c index 78b7723..fa22cc5 100755 --- a/src/database/tables/table-counters.c +++ b/src/database/tables/table-counters.c @@ -246,7 +246,6 @@ static bool __table_counters_is_entry_present(long long int restriction_id) if (sqlite3_bind_int(stmt, 1, restriction_id) != SQLITE_OK) { ret = FALSE; - __STC_LOG_FUNC_EXIT__; goto handle_error; } @@ -267,7 +266,10 @@ static bool __table_counters_is_entry_present(long long int restriction_id) } handle_error: - sqlite3_reset(stmt); + rc = sqlite3_reset(stmt); + if (rc != SQLITE_OK) + ret = FALSE; + return ret; } @@ -317,7 +319,10 @@ API stc_error_e table_counters_get(long long int restriction_id, } while (rc == SQLITE_ROW); handle_error: - sqlite3_reset(stmt); + rc = sqlite3_reset(stmt); + if (rc != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } @@ -354,7 +359,9 @@ API stc_error_e table_counters_update_counters(const table_counters_info *info) info->restriction_id); handle_error: - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } //LCOV_EXCL_STOP @@ -406,7 +413,10 @@ API stc_error_e table_counters_get_timestamps(long long int restriction_id, } while (rc == SQLITE_ROW); handle_error: - sqlite3_reset(stmt); + rc = sqlite3_reset(stmt); + if (rc != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } @@ -437,7 +447,9 @@ API stc_error_e table_counters_update_timestamps(const table_counters_info *info info->restriction_id); handle_error: - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } //LCOV_EXCL_STOP @@ -460,7 +472,9 @@ API stc_error_e table_counters_delete(long long int restriction_id) STC_LOGD("Counter deleted for restriction_id [%llu]", restriction_id); handle_error: - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } diff --git a/src/database/tables/table-firewall.c b/src/database/tables/table-firewall.c index c80161c..5e179e3 100755 --- a/src/database/tables/table-firewall.c +++ b/src/database/tables/table-firewall.c @@ -324,7 +324,9 @@ API stc_error_e table_firewall_insert_lock(char *name, int state) STC_LOGD("Firewall lock state inserted [%d]", state); handle_error: - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } @@ -348,7 +350,9 @@ API stc_error_e table_firewall_update_lock(char *name, int state) STC_LOGD("Firewall lock state updated [%d]", state); handle_error: - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } @@ -386,7 +390,9 @@ API stc_error_e table_firewall_get_lock(char *name, int *state) STC_LOGD("Firewall lock state [%d]", *state); handle_error: - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } @@ -415,7 +421,9 @@ API stc_error_e table_firewall_insert_chain(firewall_chain_s *info) STC_LOGD("Firewall chain inserted [%s]", info->chain); handle_error: - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } @@ -442,8 +450,9 @@ API stc_error_e table_firewall_delete_chain(firewall_chain_s *info) STC_LOGD("Firewall chain deleted [%s]", info->chain); handle_error: + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; - sqlite3_reset(stmt); return error_code; } @@ -470,8 +479,9 @@ API stc_error_e table_firewall_flush_chain(firewall_chain_s *info) STC_LOGD("Firewall chain flushed [%s]", info->chain); handle_error: + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; - sqlite3_reset(stmt); return error_code; } @@ -500,7 +510,9 @@ API stc_error_e table_firewall_update_chain(firewall_chain_s *info) STC_LOGD("Firewall chain updated [%s]", info->chain); handle_error: - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } @@ -537,7 +549,9 @@ API stc_error_e table_firewall_foreach_chain(firewall_chain_cb info_cb, } } while (rc == SQLITE_ROW); - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } @@ -636,7 +650,9 @@ API stc_error_e table_firewall_insert_rule(firewall_rule_s *info) STC_LOGD("Firewall rule inserted [%s]", info->chain); handle_error: - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } @@ -662,8 +678,9 @@ API stc_error_e table_firewall_delete_rule(firewall_rule_s *info) STC_LOGD("Firewall rule deleted [%s]", info->chain); handle_error: + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; - sqlite3_reset(stmt); return error_code; } @@ -763,8 +780,9 @@ API stc_error_e table_firewall_update_rule(firewall_rule_s *info, guint key) STC_LOGD("Firewall rule updated [%s]", info->chain); handle_error: + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; - sqlite3_reset(stmt); return error_code; } @@ -843,7 +861,9 @@ API stc_error_e table_firewall_foreach_rule(firewall_rule_cb info_cb, } } while (rc == SQLITE_ROW); - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } diff --git a/src/database/tables/table-restrictions.c b/src/database/tables/table-restrictions.c index debb04d..71167ee 100755 --- a/src/database/tables/table-restrictions.c +++ b/src/database/tables/table-restrictions.c @@ -315,7 +315,10 @@ stc_error_e table_restrictions_per_app(const gchar* app_id, } while (rc == SQLITE_ROW); handle_error: - sqlite3_reset(stmt); + rc = sqlite3_reset(stmt); + if (rc != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + __STC_LOG_FUNC_EXIT__; return error_code; } @@ -366,7 +369,10 @@ API stc_error_e table_restrictions_foreach(const table_restrictions_info_cb rest } } while (rc == SQLITE_ROW); - sqlite3_reset(stmt); + rc = sqlite3_reset(stmt); + if (rc != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + __STC_LOG_FUNC_EXIT__; return error_code; } @@ -388,8 +394,17 @@ stc_error_e table_restrictions_get_restriction_type_subscriber_id(const char *ap } *type = STC_RSTN_TYPE_UNKNOWN; - sqlite3_reset(select_restriction_type_subscriber_id); - sqlite3_reset(select_restriction_type); + ret = sqlite3_reset(select_restriction_type_subscriber_id); + if (ret != SQLITE_OK) { + __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE + } + + ret = sqlite3_reset(select_restriction_type); + if (ret != SQLITE_OK) { + __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE + return STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE + } if (subscriber_id == NULL) { state_subscriber_id = 0; @@ -428,8 +443,14 @@ stc_error_e table_restrictions_get_restriction_type_subscriber_id(const char *ap } handle_error: - sqlite3_reset(select_restriction_type); - sqlite3_reset(select_restriction_type_subscriber_id); + ret = sqlite3_reset(select_restriction_type); + if (ret != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + + ret = sqlite3_reset(select_restriction_type_subscriber_id); + if (ret != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } @@ -475,7 +496,9 @@ stc_error_e table_restrictions_delete(const char *app_id, handle_error: - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } @@ -508,10 +531,14 @@ stc_error_e __get_restriction_id(table_restrictions_info *info) default: STC_LOGE("Failed to get restriction id: %s\n", //LCOV_EXCL_LINE sqlite3_errmsg(stc_db_get_database())); + error_code = STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE } handle_error: - sqlite3_reset(stmt); + rc = sqlite3_reset(stmt); + if (rc != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + __STC_LOG_FUNC_EXIT__; return error_code; } @@ -526,7 +553,11 @@ stc_error_e table_restrictions_update(table_restrictions_info *info) goto handle_error; //LCOV_EXCL_LINE } - __get_restriction_id(info); + if (__get_restriction_id(info) != STC_ERROR_NONE) { + error_code = STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE + goto handle_error; //LCOV_EXCL_LINE + } + if (info->restriction_id) stmt = update_net_restrictions; @@ -561,11 +592,14 @@ stc_error_e table_restrictions_update(table_restrictions_info *info) STC_LOGD("Restriction updated app_id [%s]", info->app_id); } else { STC_LOGD("Restriction inserted app_id [%s]", info->app_id); - __get_restriction_id(info); + if (__get_restriction_id(info) != STC_ERROR_NONE) + error_code = STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE } handle_error: - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } diff --git a/src/database/tables/table-statistics.c b/src/database/tables/table-statistics.c index 7670e28..719b9a2 100755 --- a/src/database/tables/table-statistics.c +++ b/src/database/tables/table-statistics.c @@ -375,7 +375,9 @@ stc_error_e table_statistics_reset_first_n_entries(int num) __STC_LOG_FUNC_EXIT__; } handle_error: - sqlite3_reset(delete_query[4]); + if (sqlite3_reset(delete_query[4]) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } //LCOV_EXCL_STOP @@ -419,7 +421,9 @@ stc_error_e table_statistics_reset(const table_statistics_reset_rule *rule) STC_LOGD("Entry deleted successfully."); handle_error: - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; } @@ -495,7 +499,10 @@ stc_error_e table_statistics_foreach_app(const table_statistics_select_rule *rul } while (rc == SQLITE_ROW); handle_error: - sqlite3_reset(stmt); + rc = sqlite3_reset(stmt); + if (rc != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + __STC_LOG_FUNC_EXIT__; return error_code; } @@ -573,7 +580,10 @@ API stc_error_e table_statistics_per_app(const char *app_id, } while (rc == SQLITE_ROW); handle_error: - sqlite3_reset(stmt); + rc = sqlite3_reset(stmt); + if (rc != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + __STC_LOG_FUNC_EXIT__; return error_code; } @@ -626,7 +636,9 @@ API stc_error_e table_statistics_insert(stc_db_classid_iftype_key *stat_key, "rcv[%lld] snd[%lld]", stat->app_id, rcv, snd); handle_error: - sqlite3_reset(stmt); + if (sqlite3_reset(stmt) != SQLITE_OK) + error_code = STC_ERROR_DB_FAILED; + return error_code; }