Fix some svace issues for unchecking return value 94/197894/2 accepted/tizen/unified/20190130.151736 submit/tizen/20190130.071201
authorhyunuktak <hyunuk.tak@samsung.com>
Thu, 17 Jan 2019 04:15:48 +0000 (13:15 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Wed, 30 Jan 2019 07:01:13 +0000 (07:01 +0000)
Change-Id: I87e056e9f8538f199a27f2bba7a204c5db21e7a5
Signed-off-by: hyunuktak <hyunuk.tak@samsung.com>
packaging/stc-manager.spec
src/database/tables/table-counters.c
src/database/tables/table-firewall.c
src/database/tables/table-restrictions.c
src/database/tables/table-statistics.c

index f83c3f0..6c7bbcf 100644 (file)
@@ -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
index 78b7723..fa22cc5 100755 (executable)
@@ -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;
 }
 
index c80161c..5e179e3 100755 (executable)
@@ -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;
 }
 
index debb04d..71167ee 100755 (executable)
@@ -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;
 }
 
index 7670e28..719b9a2 100755 (executable)
@@ -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;
 }