From efc1f7f8e1d567f1a9656580a8cc93c953368e3f Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 17 Jul 2025 06:10:48 +0200 Subject: [PATCH] Variable naming cleanups --- gfx/drivers_shader/glslang_util.c | 9 ++++----- libretro-common/formats/png/rpng_encode.c | 18 +++++++----------- libretro-common/net/net_http.c | 16 ++++++++-------- libretro-common/queues/generic_queue.c | 8 ++------ runtime_file.c | 6 +++--- 5 files changed, 24 insertions(+), 33 deletions(-) diff --git a/gfx/drivers_shader/glslang_util.c b/gfx/drivers_shader/glslang_util.c index 8d19f9f7c7..80d657da60 100644 --- a/gfx/drivers_shader/glslang_util.c +++ b/gfx/drivers_shader/glslang_util.c @@ -59,8 +59,7 @@ bool slang_texture_semantic_is_array(enum slang_texture_semantic sem) } enum slang_texture_semantic slang_name_to_texture_semantic_array( - const char *name, const char **names, - unsigned *index) + const char *name, const char **names, unsigned *index) { unsigned i = 0; while (*names) @@ -70,12 +69,12 @@ enum slang_texture_semantic slang_name_to_texture_semantic_array( if (slang_texture_semantic_is_array(semantic)) { - size_t baselen = strlen(n); - int cmp = strncmp(n, name, baselen); + size_t _len = strlen(n); + int cmp = strncmp(n, name, _len); if (cmp == 0) { - *index = (unsigned)strtoul(name + baselen, NULL, 0); + *index = (unsigned)strtoul(name + _len, NULL, 0); return semantic; } } diff --git a/libretro-common/formats/png/rpng_encode.c b/libretro-common/formats/png/rpng_encode.c index 392537d8fc..15ccc69f95 100644 --- a/libretro-common/formats/png/rpng_encode.c +++ b/libretro-common/formats/png/rpng_encode.c @@ -402,25 +402,21 @@ bool rpng_save_image_bgr24(const char *path, const uint8_t *data, uint8_t* rpng_save_image_bgr24_string(const uint8_t *data, unsigned width, unsigned height, signed pitch, uint64_t* bytes) { - bool ret = false; - uint8_t* buf = NULL; - uint8_t* output = NULL; - int buf_length = 0; - intfstream_t* intf_s = NULL; - - buf_length = (int)(width*height*3*DEFLATE_PADDING)+PNG_ROUGH_HEADER; - buf = (uint8_t*)malloc(buf_length*sizeof(uint8_t)); + bool ret = false; + uint8_t *output = NULL; + intfstream_t *intf_s = NULL; + size_t _len = (width * height * 3 * DEFLATE_PADDING) + PNG_ROUGH_HEADER; + uint8_t *buf = (uint8_t*)malloc(_len * sizeof(uint8_t)); if (!buf) GOTO_END_ERROR(); intf_s = intfstream_open_writable_memory(buf, RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE, - buf_length); + _len); - ret = rpng_save_image_stream((const uint8_t*)data, + ret = rpng_save_image_stream((const uint8_t*)data, intf_s, width, height, pitch, 3); - *bytes = intfstream_get_ptr(intf_s); intfstream_rewind(intf_s); output = (uint8_t*)malloc((size_t)((*bytes)*sizeof(uint8_t))); diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index 22603c1381..2e082fe949 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -544,7 +544,7 @@ void net_http_connection_set_content( if (conn->postdata) free(conn->postdata); - conn->contenttype = content_type ? strdup(content_type) : NULL; + conn->contenttype = content_type ? strdup(content_type) : NULL; conn->contentlength = content_length; if (content_length) { @@ -1078,8 +1078,8 @@ static bool net_http_send_request(struct http_t *state) if (request->method && (string_is_equal(request->method, "POST") || string_is_equal(request->method, "PUT"))) { - size_t post_len, len; - char *len_str = NULL; + size_t _len, len; + char *len_str = NULL; if (!request->postdata && !string_is_equal(request->method, "PUT")) { @@ -1094,15 +1094,15 @@ static bool net_http_send_request(struct http_t *state) net_http_send_str(state, "Content-Length: ", STRLEN_CONST("Content-Length: ")); - post_len = request->contentlength; + _len = request->contentlength; #ifdef _WIN32 - len = snprintf(NULL, 0, "%" PRIuPTR, post_len); + len = snprintf(NULL, 0, "%" PRIuPTR, _len); len_str = (char*)malloc(len + 1); - snprintf(len_str, len + 1, "%" PRIuPTR, post_len); + snprintf(len_str, len + 1, "%" PRIuPTR, _len); #else - len = snprintf(NULL, 0, "%llu", (long long unsigned)post_len); + len = snprintf(NULL, 0, "%llu", (long long unsigned)_len); len_str = (char*)malloc(len + 1); - snprintf(len_str, len + 1, "%llu", (long long unsigned)post_len); + snprintf(len_str, len + 1, "%llu", (long long unsigned)_len); #endif len_str[len] = '\0'; diff --git a/libretro-common/queues/generic_queue.c b/libretro-common/queues/generic_queue.c index f8e5c3d39f..1cc4c798d4 100644 --- a/libretro-common/queues/generic_queue.c +++ b/libretro-common/queues/generic_queue.c @@ -281,13 +281,9 @@ generic_queue_iterator_t *generic_queue_iterator_remove(generic_queue_iterator_t iterator->item = iterator->forward ? item->next : item->previous; free(item); if (iterator->item) - { return iterator; - } else - { - free(iterator); - return NULL; - } + free(iterator); + return NULL; } item = iterator->forward ? item->next : item->previous; diff --git a/runtime_file.c b/runtime_file.c index 8b4f814fa0..18246ba3d1 100644 --- a/runtime_file.c +++ b/runtime_file.c @@ -327,12 +327,12 @@ runtime_log_t *runtime_log_init( char *last_slash = find_last_slash(content_path); if (last_slash) { - size_t path_length = last_slash + 1 - content_path; - if (path_length < PATH_MAX_LENGTH) + size_t _len = last_slash + 1 - content_path; + if (_len < PATH_MAX_LENGTH) { memset(tmp_buf, 0, sizeof(tmp_buf)); strlcpy(tmp_buf, - content_path, path_length * sizeof(char)); + content_path, _len * sizeof(char)); fill_pathname(content_name, path_basename(tmp_buf), ".lrtl", sizeof(content_name)); }