From c68db611880bc2f4c91a79f5ed49b01a4c9cfdbe Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 Oct 2017 22:49:13 +0200 Subject: [PATCH] Silence more Clang warnings --- input/input_driver.c | 3 ++- libretro-db/query.c | 4 ++-- paths.c | 4 ++-- playlist.c | 43 +++++++++++++++++++++++-------------------- tasks/task_content.c | 7 ++++--- tasks/task_save.c | 3 +++ 6 files changed, 36 insertions(+), 28 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index 1a1fc3662d..c28b4d42da 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -748,6 +748,7 @@ void state_tracker_update_input(uint16_t *input1, uint16_t *input2) binds, 0, RETRO_DEVICE_JOYPAD, 0, id) ? 1 : 0) << i; } + if (binds[1][id].valid) { joypad_info.joy_idx = settings->uints.input_joypad_map[1]; @@ -2316,7 +2317,7 @@ void input_config_parse_joy_button(void *data, const char *prefix, } } - if (config_get_string(conf, key_label, &tmp_a)) + if (bind && config_get_string(conf, key_label, &tmp_a)) { if (!string_is_empty(bind->joykey_label)) free(bind->joykey_label); diff --git a/libretro-db/query.c b/libretro-db/query.c index 646b36d5dd..339a62d192 100644 --- a/libretro-db/query.c +++ b/libretro-db/query.c @@ -716,8 +716,8 @@ static struct buffer query_parse_method_call(struct buffer buff, goto clean; invocation->argc = argi; - invocation->argv = (struct argument*) - malloc(sizeof(struct argument) * argi); + invocation->argv = (argi > 0) ? (struct argument*) + malloc(sizeof(struct argument) * argi) : NULL; if (!invocation->argv) { diff --git a/paths.c b/paths.c index 934eb46264..1b831ca598 100644 --- a/paths.c +++ b/paths.c @@ -175,7 +175,7 @@ void path_set_redirect(void) { fill_pathname_dir(global->name.savefile, !string_is_empty(path_main_basename) ? path_main_basename : - info->info.library_name, + info ? info->info.library_name : NULL, file_path_str(FILE_PATH_SRM_EXTENSION), sizeof(global->name.savefile)); RARCH_LOG("%s \"%s\".\n", @@ -187,7 +187,7 @@ void path_set_redirect(void) { fill_pathname_dir(global->name.savestate, !string_is_empty(path_main_basename) ? path_main_basename : - info->info.library_name, + info ? info->info.library_name : NULL, file_path_str(FILE_PATH_STATE_EXTENSION), sizeof(global->name.savestate)); RARCH_LOG("%s \"%s\".\n", diff --git a/playlist.c b/playlist.c index 7632ad24bf..a44bb08ab3 100644 --- a/playlist.c +++ b/playlist.c @@ -344,27 +344,30 @@ bool playlist_push(playlist_t *playlist, playlist->size--; } - memmove(playlist->entries + 1, playlist->entries, - (playlist->cap - 1) * sizeof(struct playlist_entry)); + if (playlist->entries) + { + memmove(playlist->entries + 1, playlist->entries, + (playlist->cap - 1) * sizeof(struct playlist_entry)); - playlist->entries[0].path = NULL; - playlist->entries[0].label = NULL; - playlist->entries[0].core_path = NULL; - playlist->entries[0].core_name = NULL; - playlist->entries[0].db_name = NULL; - playlist->entries[0].crc32 = NULL; - if (!string_is_empty(path)) - playlist->entries[0].path = strdup(path); - if (!string_is_empty(label)) - playlist->entries[0].label = strdup(label); - if (!string_is_empty(core_path)) - playlist->entries[0].core_path = strdup(core_path); - if (!string_is_empty(core_name)) - playlist->entries[0].core_name = strdup(core_name); - if (!string_is_empty(db_name)) - playlist->entries[0].db_name = strdup(db_name); - if (!string_is_empty(crc32)) - playlist->entries[0].crc32 = strdup(crc32); + playlist->entries[0].path = NULL; + playlist->entries[0].label = NULL; + playlist->entries[0].core_path = NULL; + playlist->entries[0].core_name = NULL; + playlist->entries[0].db_name = NULL; + playlist->entries[0].crc32 = NULL; + if (!string_is_empty(path)) + playlist->entries[0].path = strdup(path); + if (!string_is_empty(label)) + playlist->entries[0].label = strdup(label); + if (!string_is_empty(core_path)) + playlist->entries[0].core_path = strdup(core_path); + if (!string_is_empty(core_name)) + playlist->entries[0].core_name = strdup(core_name); + if (!string_is_empty(db_name)) + playlist->entries[0].db_name = strdup(db_name); + if (!string_is_empty(crc32)) + playlist->entries[0].crc32 = strdup(crc32); + } playlist->size++; diff --git a/tasks/task_content.c b/tasks/task_content.c index bb2e5d798c..8208f8b4ed 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -1304,7 +1304,7 @@ bool task_push_start_current_core(content_ctx_info_t *content_info) /* Load content */ if (firmware_update_status(&content_ctx)) - return true; + goto end; if (!task_load_content(content_info, &content_ctx, true, false, &error_string)) @@ -1433,7 +1433,7 @@ bool task_push_load_content_with_new_core_from_menu( content_info->environ_get = menu_content_environment_get; if (firmware_update_status(&content_ctx)) - return true; + goto end; if (!task_load_content(content_info, &content_ctx, true, false, &error_string)) @@ -1528,10 +1528,11 @@ static bool task_load_content_callback(content_ctx_info_t *content_info, #endif if (firmware_update_status(&content_ctx)) - return true; + goto end; ret = task_load_content(content_info, &content_ctx, true, loading_from_cli, &error_string); +end: if (content_ctx.name_ips) free(content_ctx.name_ips); if (content_ctx.name_bps) diff --git a/tasks/task_save.c b/tasks/task_save.c index febb7b9143..ad5ebc58fb 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -627,6 +627,9 @@ static void task_save_handler(retro_task_t *task) task_save_handler_finished(task, state); + if (!string_is_empty(msg)) + free(msg); + return; } }