From 327621938bfb23362032d9599e7b234b5afdbf5c Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Tue, 22 Jul 2025 14:16:31 +0200 Subject: [PATCH] Cut down on gotos --- gfx/video_shader_parse.c | 20 ++-- gfx/video_thread_wrapper.c | 6 +- input/input_driver.c | 86 +++++++++--------- libretro-common/file/archive_file.c | 55 +++++------ libretro-common/file/archive_file_zlib.c | 34 +++---- libretro-common/file/config_file.c | 15 +-- libretro-common/file/file_path.c | 10 +- libretro-common/file/nbio/nbio_stdio.c | 21 +++-- libretro-common/formats/image_texture.c | 85 +++++++++-------- libretro-common/lists/dir_list.c | 24 +++-- libretro-common/net/net_compat.c | 31 ++++--- libretro-common/net/net_http.c | 40 ++++---- libretro-common/rthreads/rthreads.c | 19 ++-- libretro-common/streams/file_stream.c | 10 +- libretro-common/streams/interface_stream.c | 101 +++++++-------------- libretro-common/streams/rzip_stream.c | 100 ++++++++++---------- libretro-db/query.c | 11 +-- libretro-db/rmsgpack_dom.c | 20 ++-- manual_content_scan.c | 55 ++++------- network/discord.c | 1 - 20 files changed, 342 insertions(+), 402 deletions(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 819b3a4a5b..8835ef4101 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -2237,8 +2237,7 @@ bool video_shader_load_preset_into_shader(const char *path, if (!root_conf) { RARCH_WARN("[Shaders] Could not read root preset: \"%s\".\n", path); - ret = false; - goto end; + return false; } /* Check if the root preset is a valid shader chain @@ -2345,7 +2344,6 @@ bool video_shader_load_preset_into_shader(const char *path, #endif end: - path_linked_list_free(override_paths_list); config_file_free(conf); config_file_free(root_conf); @@ -2842,7 +2840,7 @@ static bool video_shader_load_shader_preset_internal( * * Returns: false if there was an error or no action was performed. */ -static bool video_shader_load_auto_shader_preset( +static size_t video_shader_load_auto_shader_preset( const char *video_shader_directory, const char *menu_config_directory, const char *core_name, @@ -2897,7 +2895,7 @@ static bool video_shader_load_auto_shader_preset( sizeof(shader_path), dirs[i], core_name, game_name)) - goto success; + return strlcpy(s, shader_path, len); /* Folder-specific shader preset found? */ if (video_shader_load_shader_preset_internal( @@ -2905,7 +2903,7 @@ static bool video_shader_load_auto_shader_preset( sizeof(shader_path), dirs[i], core_name, content_dir_name)) - goto success; + return strlcpy(s, shader_path, len); } /* Core-specific shader preset found? */ @@ -2914,7 +2912,7 @@ static bool video_shader_load_auto_shader_preset( sizeof(shader_path), dirs[i], core_name, core_name)) - goto success; + return strlcpy(s, shader_path, len); /* Global shader preset found? */ if (video_shader_load_shader_preset_internal( @@ -2922,14 +2920,10 @@ static bool video_shader_load_auto_shader_preset( sizeof(shader_path), dirs[i], NULL, "global")) - goto success; + return strlcpy(s, shader_path, len); } - return false; -success: - /* Shader preset exists, load it. */ - strlcpy(s, shader_path, len); - return true; + return 0; } bool video_shader_combine_preset_and_apply( diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index e3d574ed2e..582a40cbbf 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -1139,7 +1139,10 @@ static void thread_set_texture_frame(void *data, const void *frame, void *tmp_frame = realloc(thr->texture.frame, required); if (!tmp_frame) - goto end; + { + slock_unlock(thr->frame.lock); + return; + } thr->texture.frame = tmp_frame; thr->texture.frame_cap = required; @@ -1153,7 +1156,6 @@ static void thread_set_texture_frame(void *data, const void *frame, thr->texture.alpha = alpha; thr->texture.frame_updated = true; -end: slock_unlock(thr->frame.lock); } diff --git a/input/input_driver.c b/input/input_driver.c index bcb159fda5..8943f4ce5d 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -1347,24 +1347,21 @@ static bool input_remote_init_network(input_remote_t *handle, RARCH_LOG("[Network] Bringing up remote interface on port %hu.\n", (unsigned short)port); - if ((fd = socket_init((void**)&res, port, NULL, SOCKET_TYPE_DATAGRAM, AF_INET)) < 0) - goto error; - - handle->net_fd[user] = fd; - - if (!socket_nonblock(handle->net_fd[user])) - goto error; - - if (!socket_bind(handle->net_fd[user], res)) + if ((fd = socket_init((void**)&res, port, NULL, SOCKET_TYPE_DATAGRAM, AF_INET)) >= 0) { - RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_BIND_SOCKET)); - goto error; + handle->net_fd[user] = fd; + + if (socket_nonblock(handle->net_fd[user])) + { + if (socket_bind(handle->net_fd[user], res)) + { + freeaddrinfo_retro(res); + return true; + } + RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_BIND_SOCKET)); + } } - freeaddrinfo_retro(res); - return true; - -error: if (res) freeaddrinfo_retro(res); return false; @@ -3442,11 +3439,14 @@ static void input_overlay_update_pointer_coords( /* Need multi-touch coordinates for pointer only */ if ( ptr_st->count && !(ptr_st->device_mask & (1 << RETRO_DEVICE_POINTER))) - goto finish; + { + ptr_st->count++; + return; + } /* Need viewport pointers for pointer and lightgun */ - if (ptr_st->device_mask & - ((1 << RETRO_DEVICE_LIGHTGUN) | (1 << RETRO_DEVICE_POINTER))) + if ( ptr_st->device_mask + & ((1 << RETRO_DEVICE_LIGHTGUN) | (1 << RETRO_DEVICE_POINTER))) { ptr_st->ptr[ptr_st->count].x = current_input->input_state( input_data, NULL, NULL, NULL, NULL, true, 0, @@ -3478,7 +3478,6 @@ static void input_overlay_update_pointer_coords( RETRO_DEVICE_ID_POINTER_Y); } -finish: ptr_st->count++; } @@ -6375,8 +6374,8 @@ void bsv_movie_read_next_events(bsv_movie_t *handle) else if (next_frame_type == REPLAY_TOKEN_CHECKPOINT2_FRAME) { uint8_t compression, encoding; - if (intfstream_read(handle->file, &(compression), sizeof(uint8_t)) != sizeof(uint8_t) || - intfstream_read(handle->file, &(encoding), sizeof(uint8_t)) != sizeof(uint8_t)) + if ( intfstream_read(handle->file, &(compression), sizeof(uint8_t)) != sizeof(uint8_t) + || intfstream_read(handle->file, &(encoding), sizeof(uint8_t)) != sizeof(uint8_t)) { /* Unexpected EOF */ RARCH_ERR("[Replay] Replay checkpoint truncated.\n"); @@ -6533,7 +6532,7 @@ bool replay_check_same_timeline(bsv_movie_t *movie, uint8_t *other_movie, int64_ { int64_t i; /* no choice but to memcmp the whole stream against the other */ - for (i = 0; ret && i < check_limit; i+=check_cap) + for (i = 0; ret && i < check_limit; i += check_cap) { int64_t read_end = MIN(check_limit - i, check_cap); int64_t read1 = intfstream_read(movie->file, buf1, read_end); @@ -6547,7 +6546,7 @@ bool replay_check_same_timeline(bsv_movie_t *movie, uint8_t *other_movie, int64_ } goto exit; } - while(intfstream_tell(movie->file) < check_limit && intfstream_tell(check_stream) < check_limit) + while (intfstream_tell(movie->file) < check_limit && intfstream_tell(check_stream) < check_limit) { if (intfstream_tell(movie->file) < 0 || intfstream_tell(check_stream) < 0) { @@ -6555,25 +6554,28 @@ bool replay_check_same_timeline(bsv_movie_t *movie, uint8_t *other_movie, int64_ ret = false; goto exit; } - if (intfstream_read(movie->file, &keycount1, 1) < 1 || - intfstream_read(check_stream, &keycount2, 1) < 1 || - keycount1 != keycount2) + if ( intfstream_read(movie->file, &keycount1, 1) < 1 + || intfstream_read(check_stream, &keycount2, 1) < 1 + || keycount1 != keycount2) { RARCH_ERR("[Replay] Replay checkpoints disagree on key count, %d vs %d\n", keycount1, keycount2); ret = false; goto exit; } - if ((uint64_t)intfstream_read(movie->file, buf1, keycount1*sizeof(bsv_key_data_t)) < keycount1*sizeof(bsv_key_data_t) || - (uint64_t)intfstream_read(check_stream, buf2, keycount2*sizeof(bsv_key_data_t)) < keycount2*sizeof(bsv_key_data_t) || - memcmp(buf1, buf2, keycount1*sizeof(bsv_key_data_t)) != 0) + if ( + (uint64_t)intfstream_read(movie->file, buf1, keycount1*sizeof(bsv_key_data_t)) + < keycount1*sizeof(bsv_key_data_t) + || (uint64_t)intfstream_read(check_stream, buf2, keycount2*sizeof(bsv_key_data_t)) + < keycount2*sizeof(bsv_key_data_t) + || memcmp(buf1, buf2, keycount1*sizeof(bsv_key_data_t)) != 0) { RARCH_ERR("[Replay] Replay checkpoints disagree on key data\n"); ret = false; goto exit; } - if (intfstream_read(movie->file, &btncount1, 2) < 2 || - intfstream_read(check_stream, &btncount2, 2) < 2 || - btncount1 != btncount2) + if ( intfstream_read(movie->file, &btncount1, 2) < 2 + || intfstream_read(check_stream, &btncount2, 2) < 2 + || btncount1 != btncount2) { RARCH_ERR("[Replay] Replay checkpoints disagree on input count\n"); ret = false; @@ -6581,17 +6583,19 @@ bool replay_check_same_timeline(bsv_movie_t *movie, uint8_t *other_movie, int64_ } btncount1 = swap_if_big16(btncount1); btncount2 = swap_if_big16(btncount2); - if ((uint64_t)intfstream_read(movie->file, buf1, btncount1*sizeof(bsv_input_data_t)) < btncount1*sizeof(bsv_input_data_t) || - (uint64_t)intfstream_read(check_stream, buf2, btncount2*sizeof(bsv_input_data_t)) < btncount2*sizeof(bsv_input_data_t) || - memcmp(buf1, buf2, btncount1*sizeof(bsv_input_data_t)) != 0) + if ( (uint64_t)intfstream_read(movie->file, buf1, btncount1*sizeof(bsv_input_data_t)) + < btncount1*sizeof(bsv_input_data_t) + || (uint64_t)intfstream_read(check_stream, buf2, btncount2*sizeof(bsv_input_data_t)) + < btncount2*sizeof(bsv_input_data_t) + || memcmp(buf1, buf2, btncount1*sizeof(bsv_input_data_t)) != 0) { RARCH_ERR("[Replay] Replay checkpoints disagree on input data\n"); ret = false; goto exit; } - if (intfstream_read(movie->file, &frametok1, 1) < 1 || - intfstream_read(check_stream, &frametok2, 1) < 1 || - frametok1 != frametok2) + if ( intfstream_read(movie->file, &frametok1, 1) < 1 + || intfstream_read(check_stream, &frametok2, 1) < 1 + || frametok1 != frametok2) { RARCH_ERR("[Replay] Replay checkpoints disagree on frame token\n"); ret = false; @@ -6606,9 +6610,9 @@ bool replay_check_same_timeline(bsv_movie_t *movie, uint8_t *other_movie, int64_ case REPLAY_TOKEN_REGULAR_FRAME: break; case REPLAY_TOKEN_CHECKPOINT_FRAME: - if ((uint64_t)intfstream_read(movie->file, &size1, sizeof(uint64_t)) < sizeof(uint64_t) || - (uint64_t)intfstream_read(check_stream, &size2, sizeof(uint64_t)) < sizeof(uint64_t) || - size1 != size2) + if ( (uint64_t)intfstream_read(movie->file, &size1, sizeof(uint64_t)) < sizeof(uint64_t) + || (uint64_t)intfstream_read(check_stream, &size2, sizeof(uint64_t)) < sizeof(uint64_t) + || size1 != size2) { RARCH_ERR("[Replay] Replay checkpoints disagree on size or scheme\n"); ret = false; diff --git a/libretro-common/file/archive_file.c b/libretro-common/file/archive_file.c index 820d791045..519bde6a9e 100644 --- a/libretro-common/file/archive_file.c +++ b/libretro-common/file/archive_file.c @@ -338,7 +338,6 @@ bool file_archive_extract_file( char *s, size_t len) { struct archive_extract_userdata userdata; - bool ret = true; struct string_list *list = string_split(valid_exts, "|"); userdata.archive_path[0] = '\0'; @@ -353,37 +352,22 @@ bool file_archive_extract_file( userdata.transfer = NULL; userdata.dec = NULL; - if (!list) + if ( list + && file_archive_walk(archive_path, valid_exts, + file_archive_extract_cb, &userdata) + && userdata.found_file + ) { - ret = false; - goto end; + if (!string_is_empty(userdata.first_extracted_file_path)) + strlcpy(s, userdata.first_extracted_file_path, len); + return true; } - if (!file_archive_walk(archive_path, valid_exts, - file_archive_extract_cb, &userdata)) - { - /* Parsing file archive failed. */ - ret = false; - goto end; - } - - if (!userdata.found_file) - { - /* Didn't find any file that matched valid extensions - * for libretro implementation. */ - ret = false; - goto end; - } - - if (!string_is_empty(userdata.first_extracted_file_path)) - strlcpy(s, userdata.first_extracted_file_path, len); - -end: if (userdata.first_extracted_file_path) free(userdata.first_extracted_file_path); if (list) string_list_free(list); - return ret; + return false; } /* Warning: 'list' must zero initialised before @@ -533,7 +517,10 @@ static struct string_list *file_archive_filename_split(const char *path) { /* add archive path to list first */ if (!string_list_append_n(list, path, (unsigned)(delim - path), attr)) - goto error; + { + string_list_free(list); + return NULL; + } /* now add the path within the archive */ delim++; @@ -541,18 +528,22 @@ static struct string_list *file_archive_filename_split(const char *path) if (*delim) { if (!string_list_append(list, delim, attr)) - goto error; + { + string_list_free(list); + return NULL; + } } } else + { if (!string_list_append(list, path, attr)) - goto error; + { + string_list_free(list); + return NULL; + } + } return list; - -error: - string_list_free(list); - return NULL; } /* Generic compressed file loader. diff --git a/libretro-common/file/archive_file_zlib.c b/libretro-common/file/archive_file_zlib.c index 29f6f3880f..86332655b2 100644 --- a/libretro-common/file/archive_file_zlib.c +++ b/libretro-common/file/archive_file_zlib.c @@ -99,12 +99,12 @@ static bool zlib_stream_decompress_data_to_file_init( void *context, file_archive_file_handle_t *handle, const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size) { - zip_context_t *zip_context = (zip_context_t *)context; - struct file_archive_transfer *state = zip_context->state; - uint8_t local_header_buf[4]; + int64_t offsetData; uint8_t *local_header; uint32_t offsetNL, offsetEL; - int64_t offsetData; + uint8_t local_header_buf[4]; + zip_context_t *zip_context = (zip_context_t *)context; + struct file_archive_transfer *state = zip_context->state; /* free previous data and stream if left unfinished */ zip_context_free_stream(zip_context, false); @@ -118,7 +118,10 @@ static bool zlib_stream_decompress_data_to_file_init( { filestream_seek(state->archive_file, (int64_t)(size_t)cdata + 26, RETRO_VFS_SEEK_POSITION_START); if (filestream_read(state->archive_file, local_header_buf, 4) != 4) - goto error; + { + zip_context_free_stream(zip_context, false); + return false; + } local_header = local_header_buf; } @@ -156,34 +159,31 @@ static bool zlib_stream_decompress_data_to_file_init( { free(zip_context->zstream); zip_context->zstream = NULL; - goto error; + zip_context_free_stream(zip_context, false); + return false; } } return true; - -error: - zip_context_free_stream(zip_context, false); - return false; } static int zlib_stream_decompress_data_to_file_iterate( void *context, file_archive_file_handle_t *handle) { + int64_t rd; zip_context_t *zip_context = (zip_context_t *)context; struct file_archive_transfer *state = zip_context->state; - int64_t rd; if (zip_context->cmode == ZIP_MODE_STORED) { - #ifdef HAVE_MMAP +#ifdef HAVE_MMAP /* Simply copy the data to the output buffer */ if (zip_context->state->archive_mmap_data) memcpy(zip_context->decompressed_data, - zip_context->state->archive_mmap_data + (size_t)zip_context->fdoffset, - zip_context->usize); + zip_context->state->archive_mmap_data + (size_t)zip_context->fdoffset, + zip_context->usize); else - #endif +#endif { /* Read the entire file to memory */ filestream_seek(state->archive_file, zip_context->fdoffset, RETRO_VFS_SEEK_POSITION_START); @@ -204,7 +204,7 @@ static int zlib_stream_decompress_data_to_file_iterate( if (!zip_context->zstream) return 1; - #ifdef HAVE_MMAP +#ifdef HAVE_MMAP if (state->archive_mmap_data) { /* Decompress from the mapped file */ @@ -212,7 +212,7 @@ static int zlib_stream_decompress_data_to_file_iterate( rd = to_read; } else - #endif +#endif { /* Read some compressed data from file to the temp buffer */ filestream_seek(state->archive_file, diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 8ccd0eb974..311f01612c 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -634,20 +634,21 @@ static bool config_file_parse_line(config_file_t *conf, if (*line != '=') { list->value = NULL; - goto error; + list->key = NULL; + free(key); + return false; } line++; if (!(list->value = config_file_extract_value(line))) - goto error; + { + list->key = NULL; + free(key); + return false; + } return true; - -error: - list->key = NULL; - free(key); - return false; } static int config_file_from_string_internal( diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 45fabd4115..d88b5fad87 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -805,7 +805,11 @@ char *path_resolve_realpath(char *s, size_t len, bool resolve_symlinks) tmp[t++] = '/'; if (string_is_empty(s)) - goto end; + { + tmp[t] = '\0'; + strlcpy(s, tmp, len); + return s; + } p = s; } @@ -851,10 +855,8 @@ char *path_resolve_realpath(char *s, size_t len, bool resolve_symlinks) while (p <= next) tmp[t++] = *p++; } - }while(next < buf_end); + } while(next < buf_end); - -end: tmp[t] = '\0'; strlcpy(s, tmp, len); return s; diff --git a/libretro-common/file/nbio/nbio_stdio.c b/libretro-common/file/nbio/nbio_stdio.c index e05968b6fa..038bb35345 100644 --- a/libretro-common/file/nbio/nbio_stdio.c +++ b/libretro-common/file/nbio/nbio_stdio.c @@ -113,12 +113,15 @@ static void *nbio_stdio_open(const char * filename, unsigned mode) if (!f) return NULL; - handle = (struct nbio_stdio_t*)malloc(sizeof(struct nbio_stdio_t)); + handle = (struct nbio_stdio_t*)malloc(sizeof(struct nbio_stdio_t)); if (!handle) - goto error; + { + fclose(f); + return NULL; + } - handle->f = f; + handle->f = f; switch (mode) { @@ -143,7 +146,11 @@ static void *nbio_stdio_open(const char * filename, unsigned mode) #endif if (len && !buf) - goto error; + { + free(handle); + fclose(f); + return NULL; + } handle->data = buf; handle->len = len; @@ -151,12 +158,6 @@ static void *nbio_stdio_open(const char * filename, unsigned mode) handle->op = -2; return handle; - -error: - if (handle) - free(handle); - fclose(f); - return NULL; } static void nbio_stdio_begin_read(void *data) diff --git a/libretro-common/formats/image_texture.c b/libretro-common/formats/image_texture.c index bfd7e78dd5..7296c8a490 100644 --- a/libretro-common/formats/image_texture.c +++ b/libretro-common/formats/image_texture.c @@ -199,21 +199,26 @@ static bool image_texture_load_internal( unsigned g_shift, unsigned b_shift) { int ret; - bool success = false; void *img = image_transfer_new(type); if (!img) - goto end; + return false; image_transfer_set_buffer_ptr(img, type, (uint8_t*)ptr, len); if (!image_transfer_start(img, type)) - goto end; + { + image_transfer_free(img, type); + return false; + } while (image_transfer_iterate(img, type)); if (!image_transfer_is_valid(img, type)) - goto end; + { + image_transfer_free(img, type); + return false; + } do { @@ -223,7 +228,10 @@ static bool image_texture_load_internal( } while (ret == IMAGE_PROCESS_NEXT); if (ret == IMAGE_PROCESS_ERROR || ret == IMAGE_PROCESS_ERROR_END) - goto end; + { + image_transfer_free(img, type); + return false; + } image_texture_color_convert(r_shift, g_shift, b_shift, a_shift, out_img); @@ -232,17 +240,13 @@ static bool image_texture_load_internal( if (!image_texture_internal_gx_convert_texture32(out_img)) { image_texture_free(out_img); - goto end; + image_transfer_free(img, type); + return false; } #endif - success = true; - -end: - if (img) - image_transfer_free(img, type); - - return success; + image_transfer_free(img, type); + return true; } void image_texture_free(struct texture_image *img) @@ -269,9 +273,7 @@ bool image_texture_load_buffer(struct texture_image *out_img, if (image_texture_load_internal( type, buffer, buffer_len, out_img, a_shift, r_shift, g_shift, b_shift)) - { return true; - } } out_img->supports_rgba = false; @@ -285,49 +287,44 @@ bool image_texture_load_buffer(struct texture_image *out_img, bool image_texture_load(struct texture_image *out_img, const char *path) { - unsigned r_shift, g_shift, b_shift, a_shift; - size_t file_len = 0; - struct nbio_t *handle = NULL; - void *ptr = NULL; enum image_type_enum type = image_texture_get_type(path); - image_texture_set_color_shifts(&r_shift, &g_shift, &b_shift, - &a_shift, out_img); - if (type != IMAGE_TYPE_NONE) { - handle = (struct nbio_t*)nbio_open(path, NBIO_READ); - if (!handle) - goto error; - nbio_begin_read(handle); + struct nbio_t *handle = (struct nbio_t*) + nbio_open(path, NBIO_READ); + if (handle) + { + void *ptr = NULL; + size_t file_len = 0; - while (!nbio_iterate(handle)); + nbio_begin_read(handle); - ptr = nbio_get_ptr(handle, &file_len); + while (!nbio_iterate(handle)); - if (!ptr) - goto error; + if ((ptr = nbio_get_ptr(handle, &file_len))) + { + unsigned r_shift, g_shift, b_shift, a_shift; + image_texture_set_color_shifts(&r_shift, + &g_shift, &b_shift, &a_shift, out_img); - if (image_texture_load_internal( - type, - ptr, file_len, out_img, - a_shift, r_shift, g_shift, b_shift)) - goto success; + if (image_texture_load_internal( + type, + ptr, file_len, out_img, + a_shift, r_shift, g_shift, b_shift)) + { + nbio_free(handle); + return true; + } + } + nbio_free(handle); + } } -error: out_img->supports_rgba = false; out_img->pixels = NULL; out_img->width = 0; out_img->height = 0; - if (handle) - nbio_free(handle); return false; - -success: - if (handle) - nbio_free(handle); - - return true; } diff --git a/libretro-common/lists/dir_list.c b/libretro-common/lists/dir_list.c index cc701a8bd2..49f4e846f4 100644 --- a/libretro-common/lists/dir_list.c +++ b/libretro-common/lists/dir_list.c @@ -155,8 +155,13 @@ static int dir_list_read(const char *dir, { struct RDIR *entry = retro_opendir_include_hidden(dir, include_hidden); - if (!entry || retro_dirent_error(entry)) - goto error; + if (!entry) + return -1; + if (retro_dirent_error(entry)) + { + retro_closedir(entry); + return -1; + } while (retro_readdir(entry)) { @@ -193,7 +198,10 @@ static int dir_list_read(const char *dir, { attr.i = RARCH_PLAIN_FILE; if (!string_list_append(list, file_path, attr)) - goto error; + { + retro_closedir(entry); + return -1; + } continue; } #endif @@ -234,17 +242,15 @@ static int dir_list_read(const char *dir, } if (!string_list_append(list, file_path, attr)) - goto error; + { + retro_closedir(entry); + return -1; + } } retro_closedir(entry); return 0; - -error: - if (entry) - retro_closedir(entry); - return -1; } /** diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 6f225664b4..7c9b09e3a6 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -128,28 +128,29 @@ struct hostent *gethostbyname(const char *name) XNetDnsLookup(name, event, &dns); if (!dns) - goto done; + { + WSACloseEvent(event); + return NULL; + } WaitForSingleObject((HANDLE)event, INFINITE); - if (dns->iStatus) - goto done; + if (!dns->iStatus) + { + memcpy(&addr, dns->aina, sizeof(addr)); - memcpy(&addr, dns->aina, sizeof(addr)); + he.h_name = NULL; + he.h_aliases = NULL; + he.h_addrtype = AF_INET; + he.h_length = sizeof(addr); + he.h_addr_list = &he.h_addr; + he.h_addr = (char*)&addr; - he.h_name = NULL; - he.h_aliases = NULL; - he.h_addrtype = AF_INET; - he.h_length = sizeof(addr); - he.h_addr_list = &he.h_addr; - he.h_addr = (char*)&addr; + ret = &he; + } - ret = &he; - -done: WSACloseEvent(event); - if (dns) - XNetDnsRelease(dns); + XNetDnsRelease(dns); return ret; } diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index 31f8be4105..c98be4d899 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -373,27 +373,31 @@ struct http_connection_t *net_http_connection_new(const char *url, conn->contentlength = strlen(data); } - if (!(conn->url = strdup(url))) - goto error; - - if (!strncmp(url, "http://", STRLEN_CONST("http://"))) - conn->scan = conn->url + STRLEN_CONST("http://"); - else if (!strncmp(url, "https://", STRLEN_CONST("https://"))) + if ((conn->url = strdup(url))) { - conn->scan = conn->url + STRLEN_CONST("https://"); - conn->ssl = true; + if (!strncmp(url, "http://", STRLEN_CONST("http://"))) + { + conn->scan = conn->url + STRLEN_CONST("http://"); + + if (!string_is_empty(conn->scan)) + { + conn->domain = conn->scan; + return conn; + } + } + else if (!strncmp(url, "https://", STRLEN_CONST("https://"))) + { + conn->scan = conn->url + STRLEN_CONST("https://"); + conn->ssl = true; + + if (!string_is_empty(conn->scan)) + { + conn->domain = conn->scan; + return conn; + } + } } - else - goto error; - if (string_is_empty(conn->scan)) - goto error; - - conn->domain = conn->scan; - - return conn; - -error: if (conn->url) free(conn->url); if (conn->method) diff --git a/libretro-common/rthreads/rthreads.c b/libretro-common/rthreads/rthreads.c index fd995187a0..224d30088c 100644 --- a/libretro-common/rthreads/rthreads.c +++ b/libretro-common/rthreads/rthreads.c @@ -364,25 +364,28 @@ scond_t *scond_new(void) * * Note: We might could simplify this using vista+ condition variables, * but we wanted an XP compatible solution. */ - if (!(cond->event = CreateEvent(NULL, FALSE, FALSE, NULL))) - goto error; + if (!(cond->event = CreateEvent(NULL, FALSE, FALSE, NULL))) + { + free(cond); + return NULL; + } if (!(cond->hot_potato = CreateEvent(NULL, FALSE, FALSE, NULL))) { CloseHandle(cond->event); - goto error; + free(cond); + return NULL; } InitializeCriticalSection(&cond->cs); #else if (pthread_cond_init(&cond->cond, NULL) != 0) - goto error; + { + free(cond); + return NULL; + } #endif return cond; - -error: - free(cond); - return NULL; } void scond_free(scond_t *cond) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 2e9aa10918..71f029c4fa 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -547,15 +547,13 @@ int filestream_putc(RFILE *stream, int c) int filestream_vprintf(RFILE *stream, const char* format, va_list args) { static char buffer[8 * 1024]; - int64_t num_chars = vsnprintf(buffer, sizeof(buffer), + int _len = vsnprintf(buffer, sizeof(buffer), format, args); - - if (num_chars < 0) + if (_len < 0) return -1; - else if (num_chars == 0) + else if (_len == 0) return 0; - - return (int)filestream_write(stream, buffer, num_chars); + return (int)filestream_write(stream, buffer, _len); } int filestream_printf(RFILE *stream, const char* format, ...) diff --git a/libretro-common/streams/interface_stream.c b/libretro-common/streams/interface_stream.c index 3f769fdf2b..031288cded 100644 --- a/libretro-common/streams/interface_stream.c +++ b/libretro-common/streams/interface_stream.c @@ -218,12 +218,10 @@ void *intfstream_init(intfstream_info_t *info) { intfstream_internal_t *intf = NULL; if (!info) - goto error; + return NULL; - intf = (intfstream_internal_t*)malloc(sizeof(*intf)); - - if (!intf) - goto error; + if (!(intf = (intfstream_internal_t*)malloc(sizeof(*intf)))) + return NULL; intf->type = info->type; intf->file.fp = NULL; @@ -246,25 +244,24 @@ void *intfstream_init(intfstream_info_t *info) case INTFSTREAM_MEMORY: intf->memory.writable = info->memory.writable; if (!intfstream_resize(intf, info)) - goto error; + { + free(intf); + return NULL; + } break; case INTFSTREAM_CHD: #ifdef HAVE_CHD intf->chd.track = info->chd.track; break; #else - goto error; + free(intf); + return NULL; #endif case INTFSTREAM_RZIP: break; } return intf; - -error: - if (intf) - free(intf); - return NULL; } int64_t intfstream_seek( @@ -699,17 +696,11 @@ intfstream_t* intfstream_open_file(const char *path, if (!fd) return NULL; - if (!intfstream_open(fd, path, mode, hints)) - goto error; + if (intfstream_open(fd, path, mode, hints)) + return fd; - return fd; - -error: - if (fd) - { - intfstream_close(fd); - free(fd); - } + intfstream_close(fd); + free(fd); return NULL; } @@ -724,21 +715,14 @@ intfstream_t *intfstream_open_memory(void *data, info.memory.buf.size = size; info.memory.writable = false; - fd = (intfstream_t*)intfstream_init(&info); - if (!fd) + if (!(fd = (intfstream_t*)intfstream_init(&info))) return NULL; - if (!intfstream_open(fd, NULL, mode, hints)) - goto error; + if (intfstream_open(fd, NULL, mode, hints)) + return fd; - return fd; - -error: - if (fd) - { - intfstream_close(fd); - free(fd); - } + intfstream_close(fd); + free(fd); return NULL; } @@ -753,21 +737,14 @@ intfstream_t *intfstream_open_writable_memory(void *data, info.memory.buf.size = size; info.memory.writable = true; - fd = (intfstream_t*)intfstream_init(&info); - if (!fd) + if (!(fd = (intfstream_t*)intfstream_init(&info))) return NULL; - if (!intfstream_open(fd, NULL, mode, hints)) - goto error; + if (intfstream_open(fd, NULL, mode, hints)) + return fd; - return fd; - -error: - if (fd) - { - intfstream_close(fd); - free(fd); - } + intfstream_close(fd); + free(fd); return NULL; } @@ -780,22 +757,14 @@ intfstream_t *intfstream_open_chd_track(const char *path, info.type = INTFSTREAM_CHD; info.chd.track = track; - fd = (intfstream_t*)intfstream_init(&info); - - if (!fd) + if (!(fd = (intfstream_t*)intfstream_init(&info))) return NULL; - if (!intfstream_open(fd, path, mode, hints)) - goto error; + if (intfstream_open(fd, path, mode, hints)) + return fd; - return fd; - -error: - if (fd) - { - intfstream_close(fd); - free(fd); - } + intfstream_close(fd); + free(fd); return NULL; } @@ -811,16 +780,10 @@ intfstream_t* intfstream_open_rzip_file(const char *path, if (!fd) return NULL; - if (!intfstream_open(fd, path, mode, RETRO_VFS_FILE_ACCESS_HINT_NONE)) - goto error; + if (intfstream_open(fd, path, mode, RETRO_VFS_FILE_ACCESS_HINT_NONE)) + return fd; - return fd; - -error: - if (fd) - { - intfstream_close(fd); - free(fd); - } + intfstream_close(fd); + free(fd); return NULL; } diff --git a/libretro-common/streams/rzip_stream.c b/libretro-common/streams/rzip_stream.c index 61dfe9bceb..ff878ed384 100644 --- a/libretro-common/streams/rzip_stream.c +++ b/libretro-common/streams/rzip_stream.c @@ -88,7 +88,8 @@ static bool rzipstream_read_file_header(rzipstream_t *stream) header_bytes[i] = 0; /* Attempt to read header bytes */ - if ((length = filestream_read(stream->file, header_bytes, sizeof(header_bytes))) <= 0) + if ((length = filestream_read(stream->file, + header_bytes, sizeof(header_bytes))) <= 0) return false; /* If file length is less than header size @@ -116,21 +117,23 @@ static bool rzipstream_read_file_header(rzipstream_t *stream) } /* Get uncompressed chunk size - next 4 bytes */ - if ((stream->chunk_size = ((uint32_t)header_bytes[11] << 24) | - ((uint32_t)header_bytes[10] << 16) | - ((uint32_t)header_bytes[9] << 8) | - (uint32_t)header_bytes[8]) == 0) + if ((stream->chunk_size = ( + (uint32_t)header_bytes[11] << 24) + | ((uint32_t)header_bytes[10] << 16) + | ((uint32_t)header_bytes[9] << 8) + | (uint32_t)header_bytes[8]) == 0) return false; /* Get total uncompressed data size - next 8 bytes */ - if ((stream->size = ((uint64_t)header_bytes[19] << 56) | - ((uint64_t)header_bytes[18] << 48) | - ((uint64_t)header_bytes[17] << 40) | - ((uint64_t)header_bytes[16] << 32) | - ((uint64_t)header_bytes[15] << 24) | - ((uint64_t)header_bytes[14] << 16) | - ((uint64_t)header_bytes[13] << 8) | - (uint64_t)header_bytes[12]) == 0) + if ((stream->size = ( + (uint64_t)header_bytes[19] << 56) + | ((uint64_t)header_bytes[18] << 48) + | ((uint64_t)header_bytes[17] << 40) + | ((uint64_t)header_bytes[16] << 32) + | ((uint64_t)header_bytes[15] << 24) + | ((uint64_t)header_bytes[14] << 16) + | ((uint64_t)header_bytes[13] << 8) + | (uint64_t)header_bytes[12]) == 0) return false; stream->is_compressed = true; @@ -391,8 +394,8 @@ rzipstream_t* rzipstream_open(const char *path, unsigned mode) return NULL; /* If opening in read mode, ensure file exists */ - if ((mode == RETRO_VFS_FILE_ACCESS_READ) && - !path_is_valid(path)) + if ( (mode == RETRO_VFS_FILE_ACCESS_READ) + && !path_is_valid(path)) return NULL; /* Allocate stream object */ @@ -454,10 +457,10 @@ static bool rzipstream_read_chunk(rzipstream_t *stream) return false; /* Get size of next compressed chunk */ - compressed_chunk_size = ((uint32_t)chunk_header_bytes[3] << 24) | - ((uint32_t)chunk_header_bytes[2] << 16) | - ((uint32_t)chunk_header_bytes[1] << 8) | - (uint32_t)chunk_header_bytes[0]; + compressed_chunk_size = ( (uint32_t)chunk_header_bytes[3] << 24) + | ((uint32_t)chunk_header_bytes[2] << 16) + | ((uint32_t)chunk_header_bytes[1] << 8) + | (uint32_t)chunk_header_bytes[0]; if (compressed_chunk_size == 0) return false; @@ -523,7 +526,7 @@ static bool rzipstream_read_chunk(rzipstream_t *stream) * the event of an error */ int64_t rzipstream_read(rzipstream_t *stream, void *data, int64_t len) { - int64_t data_len = len; + int64_t _len = len; uint8_t *data_ptr = (uint8_t *)data; int64_t data_read = 0; @@ -536,7 +539,7 @@ int64_t rzipstream_read(rzipstream_t *stream, void *data, int64_t len) return filestream_read(stream->file, data, len); /* Process input data */ - while (data_len > 0) + while (_len > 0) { int64_t read_size = 0; @@ -556,8 +559,8 @@ int64_t rzipstream_read(rzipstream_t *stream, void *data, int64_t len) * > i.e. minimum of remaining output buffer * occupancy and remaining 'read data' size */ if ((read_size = stream->out_buf_occupancy - stream->out_buf_ptr) > - data_len) - read_size = data_len; + _len) + read_size = _len; /* Copy as much cached data as possible into * the read buffer */ @@ -566,7 +569,7 @@ int64_t rzipstream_read(rzipstream_t *stream, void *data, int64_t len) /* Increment pointers and remaining length */ stream->out_buf_ptr += read_size; data_ptr += read_size; - data_len -= read_size; + _len -= read_size; stream->virtual_ptr += read_size; @@ -784,14 +787,14 @@ static bool rzipstream_write_chunk(rzipstream_t *stream) * in the event of an error */ int64_t rzipstream_write(rzipstream_t *stream, const void *data, int64_t len) { - int64_t data_len = len; + int64_t _len = len; const uint8_t *data_ptr = (const uint8_t *)data; if (!stream || !stream->is_writing || !data) return -1; /* Process input data */ - while (data_len > 0) + while (_len > 0) { int64_t cache_size = 0; @@ -803,8 +806,8 @@ int64_t rzipstream_write(rzipstream_t *stream, const void *data, int64_t len) /* Get amount of data to cache during this loop * > i.e. minimum of space remaining in input buffer * and remaining 'write data' size */ - if ((cache_size = stream->in_buf_size - stream->in_buf_ptr) > data_len) - cache_size = data_len; + if ((cache_size = stream->in_buf_size - stream->in_buf_ptr) > _len) + cache_size = _len; /* Copy as much data as possible into * the input buffer */ @@ -813,7 +816,7 @@ int64_t rzipstream_write(rzipstream_t *stream, const void *data, int64_t len) /* Increment pointers and remaining length */ stream->in_buf_ptr += cache_size; data_ptr += cache_size; - data_len -= cache_size; + _len -= cache_size; stream->size += cache_size; stream->virtual_ptr += cache_size; @@ -831,12 +834,10 @@ int64_t rzipstream_write(rzipstream_t *stream, const void *data, int64_t len) int rzipstream_putc(rzipstream_t *stream, int c) { char c_char = (char)c; - - if (!stream || !stream->is_writing) - return EOF; - - return (rzipstream_write(stream, &c_char, 1) == 1) ? - (int)(unsigned char)c : EOF; + if ( stream && stream->is_writing + && (rzipstream_write(stream, &c_char, 1) == 1)) + return (int)(unsigned char)c; + return EOF; } /* Writes a variable argument list to an RZIP file. @@ -847,15 +848,13 @@ int rzipstream_putc(rzipstream_t *stream, int c) int rzipstream_vprintf(rzipstream_t *stream, const char* format, va_list args) { static char buffer[8 * 1024] = {0}; - int64_t num_chars = vsnprintf(buffer, + int _len = vsnprintf(buffer, sizeof(buffer), format, args); - - if (num_chars < 0) + if (_len < 0) return -1; - else if (num_chars == 0) + else if (_len == 0) return 0; - - return (int)rzipstream_write(stream, buffer, num_chars); + return (int)rzipstream_write(stream, buffer, _len); } /* Writes formatted output to an RZIP file. @@ -1050,20 +1049,17 @@ int rzipstream_close(rzipstream_t *stream) * disk and update file header */ if (stream->is_writing) { - if (stream->in_buf_ptr > 0) - if (!rzipstream_write_chunk(stream)) - goto error; - - if (!rzipstream_write_file_header(stream)) - goto error; + if ( ((stream->in_buf_ptr > 0) + && !rzipstream_write_chunk(stream)) + || !rzipstream_write_file_header(stream)) + { + /* Stream must be free()'d regardless */ + rzipstream_free_stream(stream); + return -1; + } } /* Free stream * > This also closes the file */ return rzipstream_free_stream(stream); - -error: - /* Stream must be free()'d regardless */ - rzipstream_free_stream(stream); - return -1; } diff --git a/libretro-db/query.c b/libretro-db/query.c index b144c0495d..c74f73f4a9 100644 --- a/libretro-db/query.c +++ b/libretro-db/query.c @@ -681,7 +681,7 @@ static struct buffer query_parse_table( buff = query_expect_char(s, len, buff, '{', error); if (*error) - goto clean; + return buff; buff = query_chomp(buff); @@ -798,13 +798,12 @@ static struct buffer query_parse_method_call( invocation->func = NULL; - buff = query_get_ident(s, len, - buff, &func_name, &_len, error); + buff = query_get_ident(s, len, buff, &func_name, &_len, error); if (*error) - goto clean; + return buff; - buff = query_chomp(buff); - buff = query_expect_char(s, len, buff, '(', error); + buff = query_chomp(buff); + buff = query_expect_char(s, len, buff, '(', error); if (*error) goto clean; diff --git a/libretro-db/rmsgpack_dom.c b/libretro-db/rmsgpack_dom.c index 7f67554455..88ad6c2784 100644 --- a/libretro-db/rmsgpack_dom.c +++ b/libretro-db/rmsgpack_dom.c @@ -422,12 +422,6 @@ int rmsgpack_dom_read_into(intfstream_t *fd, ...) int rv; va_list ap; struct rmsgpack_dom_value map; - struct rmsgpack_dom_value key; - int64_t *int_value; - uint64_t *uint_value; - int *bool_value; - char *buff_value; - uint64_t min_len; va_start(ap, fd); @@ -439,13 +433,20 @@ int rmsgpack_dom_read_into(intfstream_t *fd, ...) if (map.type == RDT_MAP) { + int *bool_value; + char *buff_value; + uint64_t min_len; + int64_t *int_value; + uint64_t *uint_value; + struct rmsgpack_dom_value key; + for (;;) { struct rmsgpack_dom_value *value; const char *key_name = va_arg(ap, const char *); if (!key_name) - goto clean; + break; key.type = RDT_STRING; key.val.string.len = (uint32_t)strlen(key_name); @@ -486,12 +487,13 @@ int rmsgpack_dom_read_into(intfstream_t *fd, ...) memcpy(buff_value, value->val.string.buff, (size_t)min_len); break; default: - goto clean; + va_end(ap); + rmsgpack_dom_value_free(&map); + return 0; } } } -clean: va_end(ap); rmsgpack_dom_value_free(&map); return 0; diff --git a/manual_content_scan.c b/manual_content_scan.c index 3cc649b1b7..636c0d7182 100644 --- a/manual_content_scan.c +++ b/manual_content_scan.c @@ -519,15 +519,10 @@ enum manual_content_scan_playlist_refresh_status system_name_type = MANUAL_CONTENT_SCAN_SYSTEM_NAME_CONTENT_DIR; enum manual_content_scan_core_type core_type = MANUAL_CONTENT_SCAN_CORE_DETECT; - enum manual_content_scan_playlist_refresh_status - playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_OK; char system_name[NAME_MAX_LENGTH]; if (!playlist_scan_refresh_enabled(playlist)) - { - playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_MISSING_CONFIG; - goto end; - } + return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_MISSING_CONFIG; /* Read scan parameters from playlist */ playlist_path = playlist_get_conf_path(playlist); @@ -543,31 +538,22 @@ enum manual_content_scan_playlist_refresh_status /* Determine system name (playlist basename * without extension) */ + /* Cannot happen, but would constitute a + * 'system name' error */ if (string_is_empty(playlist_path)) - { - /* Cannot happen, but would constitute a - * 'system name' error */ - playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_SYSTEM_NAME; - goto end; - } + return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_SYSTEM_NAME; fill_pathname(system_name, path_basename(playlist_path), "", sizeof(system_name)); + /* Cannot happen, but would constitute a + * 'system name' error */ if (string_is_empty(system_name)) - { - /* Cannot happen, but would constitute a - * 'system name' error */ - playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_SYSTEM_NAME; - goto end; - } + return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_SYSTEM_NAME; /* Set content directory */ if (!manual_content_scan_set_menu_content_dir(content_dir)) - { - playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_CONTENT_DIR; - goto end; - } + return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_CONTENT_DIR; /* Set system name */ #ifdef HAVE_LIBRETRODB @@ -630,10 +616,7 @@ enum manual_content_scan_playlist_refresh_status if (!manual_content_scan_set_menu_system_name( system_name_type, system_name)) - { - playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_SYSTEM_NAME; - goto end; - } + return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_SYSTEM_NAME; /* Set core path/name */ if ( !string_is_empty(core_name) @@ -642,10 +625,7 @@ enum manual_content_scan_playlist_refresh_status if (!manual_content_scan_set_menu_core_name( core_type, core_name)) - { - playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_CORE; - goto end; - } + return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_CORE; /* Set custom file extensions */ if (string_is_empty(file_exts)) @@ -679,11 +659,9 @@ enum manual_content_scan_playlist_refresh_status switch (manual_content_scan_validate_dat_file_path()) { case MANUAL_CONTENT_SCAN_DAT_FILE_INVALID: - playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_DAT_FILE; - goto end; + return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_INVALID_DAT_FILE; case MANUAL_CONTENT_SCAN_DAT_FILE_TOO_LARGE: - playlist_status = MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_DAT_FILE_TOO_LARGE; - goto end; + return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_DAT_FILE_TOO_LARGE; default: /* No action required */ break; @@ -700,8 +678,7 @@ enum manual_content_scan_playlist_refresh_status * existing file */ scan_settings.validate_entries = true; -end: - return playlist_status; + return MANUAL_CONTENT_SCAN_PLAYLIST_REFRESH_OK; } /* Menu getters */ @@ -1096,9 +1073,9 @@ struct string_list *manual_content_scan_get_content_list( /* Sanity check */ if (!task_config) - goto error; + return NULL; if (string_is_empty(task_config->content_dir)) - goto error; + return NULL; /* Check whether files should be filtered by * extension */ @@ -1187,7 +1164,7 @@ static bool manual_content_scan_get_playlist_content_path( /* Get archive file contents */ if (!(archive_list = file_archive_get_file_list( content_path, filter_exts ? task_config->file_exts : NULL))) - goto error; + return false; if (archive_list->size < 1) goto error; diff --git a/network/discord.c b/network/discord.c index 4ca38ba41d..dfbb8a9163 100644 --- a/network/discord.c +++ b/network/discord.c @@ -164,7 +164,6 @@ static void handle_discord_join_cb(retro_task_t *task, void *task_data, goto done; if (data->status != 200) goto done; - if (!(room_data = (char*)malloc(data->len + 1))) goto done; memcpy(room_data, data->data, data->len);