If the variable is used after the target, it will be uninitialized.
A goto jumps past the initialization of a variable.
Change-Id: I41ecefd76dc71a6b194abd514c4231ac5597d986
Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
package_info_h package_info = NULL;
char *app_path = NULL;
char *file_path = NULL;
+ int path_len = 0;
ret = app_get_id(&app_id);
if (ret != APP_ERROR_NONE) {
goto cleanup;
}
- int path_len = strlen(app_path) + strlen(relative_path) + 2;
+ path_len = strlen(app_path) + strlen(relative_path) + 2;
file_path = (char *)calloc(path_len, sizeof(char));
if (!file_path) {
LOGE("failed to alloc memory"); //LCOV_EXCL_LINE
GError* err_msg = NULL;
GVariant *body = NULL;
char *cmd = "send_insert_result";
+ JsonArray *sticker_arr = NULL;
+ JsonArray *keyword_arr = NULL;
+ int arr_len = 0;
+ int keyword_arr_len = 0;
*reply_body = g_variant_new("()");
if (*reply_body == NULL) {
goto cleanup;
}
- JsonArray *sticker_arr = json_object_get_array_member(root_obj, "sticker");
+ sticker_arr = json_object_get_array_member(root_obj, "sticker");
if (sticker_arr == NULL) {
LOGE("failed to get array member");
ret = STICKERD_SERVER_ERROR_OPERATION_FAILED;
goto cleanup;
}
- int arr_len = json_array_get_length(sticker_arr);
+ arr_len = json_array_get_length(sticker_arr);
for (int i = 0; i < arr_len; i++) {
JsonObject *info_object = json_array_get_object_element(sticker_arr, i);
if (info_object != NULL) {
sticker_info->display_type = _get_int_from_object(info_object, "display_type");
- JsonArray *keyword_arr = json_object_get_array_member(info_object, "keyword");
- int keyword_arr_len = json_array_get_length(keyword_arr);
+ keyword_arr = json_object_get_array_member(info_object, "keyword");
+ keyword_arr_len = json_array_get_length(keyword_arr);
if (keyword_arr_len < 1)
goto free_memory;
int ret;
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
+ int result = 0;
db = _db_open();
if (!db)
goto cleanup;
}
- int result = sqlite3_column_int(stmt, 0);
+ result = sqlite3_column_int(stmt, 0);
sqlite3_finalize(stmt);
stmt = NULL;
char *description = NULL;
char *thumbnail_path = NULL;
char *uri_path = NULL;
+ char *rel_thumbnail = NULL;
+ JsonArray *keyword_arr = NULL;
+ int disp_type = 0;
+ int keyword_arr_len = 0;
parser = json_parser_new();
json_parser_load_from_file(parser, file_path, &err_msg);
if (!group)
goto free_memory;
- char *rel_thumbnail = __get_string_from_object(info_object, "thumbnail");
+ rel_thumbnail = __get_string_from_object(info_object, "thumbnail");
if (rel_thumbnail) {
if (rel_thumbnail[0] != '\0') {
if (access(rel_thumbnail, F_OK) == 0) {
}
description = __get_string_from_object(info_object, "description");
- int disp_type = __get_int_from_object(info_object, "display_type");
+ disp_type = __get_int_from_object(info_object, "display_type");
- JsonArray *keyword_arr = json_object_get_array_member(info_object, "keyword");
- int keyword_arr_len = json_array_get_length(keyword_arr);
+ keyword_arr = json_object_get_array_member(info_object, "keyword");
+ keyword_arr_len = json_array_get_length(keyword_arr);
if (keyword_arr_len < 1)
goto free_memory;
char *app_path = NULL;
char *file_path = NULL;
int ret = 0;
+ int path_len = 0;
__db_init();
goto cleanup;
}
- int path_len = strlen(app_path) + strlen((char *)md->value) + 2;
+ path_len = strlen(app_path) + strlen((char *)md->value) + 2;
file_path = (char *)calloc(path_len, sizeof(char));
if (!file_path) {
LOGE("failed to alloc memory");