Check result for field data 83/188383/1
authormk5004.lee <mk5004.lee@samsung.com>
Tue, 4 Sep 2018 10:05:59 +0000 (19:05 +0900)
committermk5004.lee <mk5004.lee@samsung.com>
Tue, 4 Sep 2018 10:15:34 +0000 (19:15 +0900)
- If the result is Fail, do not execute the condition statement

Change-Id: I26a0fb199585ac44c87822bc8187a780fb7dae4f
Signed-off-by: mk5004.lee <mk5004.lee@samsung.com>
src/badge_setting_service.c

index 587f80e..ee3a382 100755 (executable)
@@ -112,7 +112,7 @@ EXPORT_API int badge_db_get_setting_by_appid(const char *appid, badge_setting_h
        char **query_result = NULL;
        badge_setting_h result_setting;
        sqlite3 *db = NULL;
-       int atd = 0;
+       int atd;
 
        if (appid == NULL)
                return BADGE_ERROR_INVALID_PARAMETER;
@@ -168,14 +168,16 @@ EXPORT_API int badge_db_get_setting_by_appid(const char *appid, badge_setting_h
 
        _get_table_field_data_string(query_result, &(result_setting[0].pkgname), 1, col_index++);
        _get_table_field_data_string(query_result, &(result_setting[0].appid), 1, col_index++);
-       _get_table_field_data_int(query_result, &atd, col_index++);
-
-       if (atd & BAGDE_APP_DISABLE_BIT)
-               result_setting[0].allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY;
-       else if (atd & BAGDE_ALLOW_TO_DISPLAY_BIT)
-               result_setting[0].allow_to_display = BAGDE_ALLOW_TO_DISPLAY;
-       else
+       if (_get_table_field_data_int(query_result, &atd, col_index++)) {
+               if (atd & BAGDE_APP_DISABLE_BIT)
+                       result_setting[0].allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY;
+               else if (atd & BAGDE_ALLOW_TO_DISPLAY_BIT)
+                       result_setting[0].allow_to_display = BAGDE_ALLOW_TO_DISPLAY;
+               else
+                       result_setting[0].allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY;
+       } else {
                result_setting[0].allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY;
+       }
 
        *setting = result_setting;
 
@@ -254,7 +256,7 @@ EXPORT_API int badge_db_get_allow_to_display_by_appid(char *appid, int *allow_to
        char *sql_query = NULL;
        char **query_result = NULL;
        sqlite3 *db = NULL;
-       int atd = 0;
+       int atd;
 
        if (appid == NULL)
                return BADGE_ERROR_INVALID_PARAMETER;
@@ -299,14 +301,16 @@ EXPORT_API int badge_db_get_allow_to_display_by_appid(char *appid, int *allow_to
 
        col_index = col_count;
 
-       _get_table_field_data_int(query_result, &atd, col_index++);
-
-       if (atd & BAGDE_APP_DISABLE_BIT)
-               *allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY;
-       else if (atd & BAGDE_ALLOW_TO_DISPLAY_BIT)
-               *allow_to_display = BAGDE_ALLOW_TO_DISPLAY;
-       else
+       if (_get_table_field_data_int(query_result, &atd, col_index++)) {
+               if (atd & BAGDE_APP_DISABLE_BIT)
+                       *allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY;
+               else if (atd & BAGDE_ALLOW_TO_DISPLAY_BIT)
+                       *allow_to_display = BAGDE_ALLOW_TO_DISPLAY;
+               else
+                       *allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY;
+       } else {
                *allow_to_display = BAGDE_NOT_ALLOW_TO_DISPLAY;
+       }
 
 out:
        if (query_result)