Organize log for print tree
[platform/core/connectivity/stc-manager.git] / src / database / tables / table-statistics.c
index c14fdb6..436c55d 100755 (executable)
@@ -223,8 +223,8 @@ static int __prepare_delete(sqlite3 *db)
        static int initialized;
 
        if (initialized) {
-               __STC_LOG_FUNC_EXIT__;
-               return SQLITE_OK;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return SQLITE_OK; //LCOV_EXCL_LINE
        }
 
        PREPARE_DELETE(delete_query[0], DELETE_ALL);
@@ -256,8 +256,8 @@ static int __prepare_select(sqlite3 *db)
        static int initialized;
 
        if (initialized) {
-               __STC_LOG_FUNC_EXIT__;
-               return SQLITE_OK;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return SQLITE_OK; //LCOV_EXCL_LINE
        }
 
        PREPARE_SELECT(select_for_period, SELECT_FOR_PERIOD);
@@ -305,8 +305,8 @@ static int __prepare_insert(sqlite3 *db)
        static int initialized;
 
        if (initialized) {
-               __STC_LOG_FUNC_EXIT__;
-               return SQLITE_OK;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return SQLITE_OK; //LCOV_EXCL_LINE
        }
 
        PREPARE_INSERT(update_statistics_query, INSERT_VALUES);
@@ -360,6 +360,7 @@ static sqlite3_stmt *__select_statement(const char *app_id,
        return *details_stms[stm_index];
 }
 
+//LCOV_EXCL_START
 stc_error_e table_statistics_reset_first_n_entries(int num)
 {
        __STC_LOG_FUNC_ENTER__;
@@ -381,18 +382,19 @@ handle_error:
        sqlite3_reset(delete_query[4]);
        return error_code;
 }
+//LCOV_EXCL_STOP
 
 stc_error_e table_statistics_reset(const table_statistics_reset_rule *rule)
 {
        __STC_LOG_FUNC_ENTER__;
        sqlite3_stmt *stmt;
        stc_error_e error_code = STC_ERROR_NONE;
-       int pos = 1;/* running through positions where to
+       int pos = 1; /* running through positions where to
                       bind parameters in the query */
 
        if (!rule || !rule->interval) {
-               __STC_LOG_FUNC_EXIT__;
-               return STC_ERROR_INVALID_PARAMETER;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
        /* pick a statement depending on parameters.
@@ -413,10 +415,10 @@ stc_error_e table_statistics_reset(const table_statistics_reset_rule *rule)
        DB_ACTION(sqlite3_bind_int64(stmt, pos++, rule->interval->to));
 
        if (sqlite3_step(stmt) != SQLITE_DONE) {
-               STC_LOGE("Failed to drop collected statistics.");
-               error_code = STC_ERROR_DB_FAILED;
-               __STC_LOG_FUNC_EXIT__;
-               goto handle_error;
+               STC_LOGE("Failed to drop collected statistics."); //LCOV_EXCL_LINE
+               error_code = STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto handle_error; //LCOV_EXCL_LINE
        }
 
        STC_LOGD("Entry deleted successfully.");
@@ -441,8 +443,8 @@ stc_error_e table_statistics_foreach_app(const table_statistics_select_rule *rul
        memset(&data, 0, sizeof(data));
 
        if (!rule || !info_cb) {
-               __STC_LOG_FUNC_EXIT__;
-               return STC_ERROR_INVALID_PARAMETER;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
        /* pick a statement depending on parameters */
@@ -485,7 +487,7 @@ stc_error_e table_statistics_foreach_app(const table_statistics_select_rule *rul
                        }
 
                        if (info_cb(&data, user_data) == STC_CANCEL)
-                               rc = SQLITE_DONE;/* emulate end of data */
+                               rc = SQLITE_DONE; //LCOV_EXCL_LINE
                        __STC_LOG_FUNC_EXIT__;
                        break;
                case SQLITE_DONE:
@@ -493,9 +495,9 @@ stc_error_e table_statistics_foreach_app(const table_statistics_select_rule *rul
                        break;
                case SQLITE_ERROR:
                default:
-                       error_code = STC_ERROR_DB_FAILED;
-                       __STC_LOG_FUNC_EXIT__;
-                       break;
+                       error_code = STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
+                       __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+                       break; //LCOV_EXCL_LINE
                }
        } while (rc == SQLITE_ROW);
 
@@ -515,15 +517,15 @@ stc_error_e table_statistics_per_app(const char *app_id,
        sqlite3_stmt *stmt;
        stc_error_e error_code = STC_ERROR_NONE;
        int rc;
-       int pos = 1;/* running through positions
+       int pos = 1; /* running through positions
                       where to bind parameters in the query */
        stc_db_tm_interval_s interval;
 
        memset(&data, 0, sizeof(data));
 
        if (!rule || !info_cb) {
-               __STC_LOG_FUNC_EXIT__;
-               return STC_ERROR_INVALID_PARAMETER;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return STC_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE
        }
 
        /* pick a statement depending on parameters.
@@ -566,7 +568,7 @@ stc_error_e table_statistics_per_app(const char *app_id,
                        }
 
                        if (info_cb(&data, user_data) == STC_CANCEL)
-                               rc = SQLITE_DONE; /* emulate end of data */
+                               rc = SQLITE_DONE; //LCOV_EXCL_LINE
                        __STC_LOG_FUNC_EXIT__;
                        break;
                case SQLITE_DONE:
@@ -574,9 +576,9 @@ stc_error_e table_statistics_per_app(const char *app_id,
                        break;
                case SQLITE_ERROR:
                default:
-                       error_code = STC_ERROR_DB_FAILED;
-                       __STC_LOG_FUNC_EXIT__;
-                       break;
+                       error_code = STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
+                       __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+                       break; //LCOV_EXCL_LINE
                }
        } while (rc == SQLITE_ROW);
 
@@ -592,7 +594,7 @@ stc_error_e table_statistics_insert(stc_db_classid_iftype_key *stat_key,
 {
        stc_error_e error_code = STC_ERROR_NONE;
        sqlite3_stmt *stmt = update_statistics_query;
-       stc_hw_net_protocol_type_e hw_net_protocol_type = STC_PROTOCOL_NONE;
+       stc_hw_net_protocol_type_e hw_net_protocol_type = STC_PROTOCOL_UNKNOWN;
 
        if (!stat->rcv_count && !stat->snd_count) {
                error_code = STC_ERROR_INVALID_PARAMETER;
@@ -619,14 +621,15 @@ stc_error_e table_statistics_insert(stc_db_classid_iftype_key *stat_key,
        stat->rcv_count = 0;
        stat->snd_count = 0;
        if (sqlite3_step(stmt) != SQLITE_DONE) {
-               STC_LOGE("Failed to record appstat. %s",
+               STC_LOGE("Failed to record appstat. %s", //LCOV_EXCL_LINE
                         sqlite3_errmsg(stc_db_get_database()));
-               error_code = STC_ERROR_DB_FAILED;
-               __STC_LOG_FUNC_EXIT__;
-               goto handle_error;
+               error_code = STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               goto handle_error; //LCOV_EXCL_LINE
        }
 
-       STC_LOGD("App stat recorded [%s]", stat->app_id);
+       if (STC_DEBUG_LOG)
+               STC_LOGD("App stat recorded [%s]", stat->app_id);
 
 handle_error:
        sqlite3_reset(stmt);
@@ -669,8 +672,8 @@ stc_error_e table_statistics_prepare(sqlite3 *db)
        stc_error_e error_code = STC_ERROR_NONE;
 
        if (db == NULL) {
-               __STC_LOG_FUNC_EXIT__;
-               return STC_ERROR_DB_FAILED;
+               __STC_LOG_FUNC_EXIT__; //LCOV_EXCL_LINE
+               return STC_ERROR_DB_FAILED; //LCOV_EXCL_LINE
        }
 
        DB_ACTION(__prepare_delete(db));