Standardize naming of local len variables

This commit is contained in:
LibretroAdmin 2024-12-30 14:27:24 +01:00
parent 1e656261b0
commit 6be18bfee9
5 changed files with 25 additions and 32 deletions

View File

@ -231,7 +231,7 @@ static bool caca_frame(void *data, const void *frame,
unsigned frame_width, unsigned frame_height, uint64_t frame_count, unsigned frame_width, unsigned frame_height, uint64_t frame_count,
unsigned pitch, const char *msg, video_frame_info_t *video_info) unsigned pitch, const char *msg, video_frame_info_t *video_info)
{ {
size_t len = 0; size_t _len = 0;
void *buffer = NULL; void *buffer = NULL;
const void *frame_to_copy = frame; const void *frame_to_copy = frame;
unsigned width = 0; unsigned width = 0;
@ -297,11 +297,11 @@ static bool caca_frame(void *data, const void *frame,
height, height,
caca->dither, frame_to_copy); caca->dither, frame_to_copy);
buffer = caca_export_canvas_to_memory(caca->cv, "caca", &len); buffer = caca_export_canvas_to_memory(caca->cv, "caca", &_len);
if (buffer) if (buffer)
{ {
if (len) if (_len > 0)
caca_refresh_display(caca->display); caca_refresh_display(caca->display);
free(buffer); free(buffer);

View File

@ -617,8 +617,8 @@ bool gfx_thumbnail_update_path(
if ( string_is_equal(path_data->system, "history") if ( string_is_equal(path_data->system, "history")
|| string_is_equal(path_data->system, "favorites")) || string_is_equal(path_data->system, "favorites"))
{ {
if (!gfx_thumbnail_get_content_dir( if (gfx_thumbnail_get_content_dir(
path_data, content_dir, sizeof(content_dir))) path_data, content_dir, sizeof(content_dir)) == 0)
return false; return false;
system_name = content_dir; system_name = content_dir;
@ -720,26 +720,19 @@ bool gfx_thumbnail_update_path(
/* Fetches current content directory. /* Fetches current content directory.
* Returns true if content directory is valid. */ * Returns true if content directory is valid. */
bool gfx_thumbnail_get_content_dir( size_t gfx_thumbnail_get_content_dir(
gfx_thumbnail_path_data_t *path_data, char *content_dir, size_t len) gfx_thumbnail_path_data_t *path_data, char *s, size_t len)
{ {
char *last_slash; char *last_slash;
size_t path_length; size_t _len;
char tmp_buf[NAME_MAX_LENGTH]; char tmp_buf[NAME_MAX_LENGTH];
if (!path_data || string_is_empty(path_data->content_path)) if (!path_data || string_is_empty(path_data->content_path))
return false; return 0;
if (!(last_slash = find_last_slash(path_data->content_path))) if (!(last_slash = find_last_slash(path_data->content_path)))
return false; return 0;
_len = last_slash + 1 - path_data->content_path;
path_length = last_slash + 1 - path_data->content_path; if (!((_len > 1) && (_len < PATH_MAX_LENGTH)))
return 0;
if (!((path_length > 1) && (path_length < PATH_MAX_LENGTH))) strlcpy(tmp_buf, path_data->content_path, _len * sizeof(char));
return false; return strlcpy(s, path_basename_nocompression(tmp_buf), len);
strlcpy(tmp_buf, path_data->content_path, path_length * sizeof(char));
strlcpy(content_dir, path_basename_nocompression(tmp_buf), len);
return !string_is_empty(content_dir);
} }

View File

@ -141,7 +141,7 @@ bool gfx_thumbnail_update_path(gfx_thumbnail_path_data_t *path_data, enum gfx_th
/* Fetches current content directory. /* Fetches current content directory.
* Returns true if content directory is valid. */ * Returns true if content directory is valid. */
bool gfx_thumbnail_get_content_dir(gfx_thumbnail_path_data_t *path_data, char *content_dir, size_t len); size_t gfx_thumbnail_get_content_dir(gfx_thumbnail_path_data_t *path_data, char *s, size_t len);
RETRO_END_DECLS RETRO_END_DECLS

View File

@ -193,15 +193,15 @@ static enum patch_error bps_apply_patch(
while (bps.modify_offset < bps.modify_length - 12) while (bps.modify_offset < bps.modify_length - 12)
{ {
size_t length = bps_decode(&bps); size_t _len = bps_decode(&bps);
unsigned mode = length & 3; unsigned mode = _len & 3;
length = (length >> 2) + 1; _len = (_len >> 2) + 1;
switch (mode) switch (mode)
{ {
case SOURCE_READ: case SOURCE_READ:
while (length--) while (_len--)
{ {
uint8_t data = bps.source_data[bps.output_offset]; uint8_t data = bps.source_data[bps.output_offset];
bps.target_data[bps.output_offset++] = data; bps.target_data[bps.output_offset++] = data;
@ -210,7 +210,7 @@ static enum patch_error bps_apply_patch(
break; break;
case TARGET_READ: case TARGET_READ:
while (length--) while (_len--)
{ {
uint8_t data = bps_read(&bps); uint8_t data = bps_read(&bps);
bps.target_data[bps.output_offset++] = data; bps.target_data[bps.output_offset++] = data;
@ -232,7 +232,7 @@ static enum patch_error bps_apply_patch(
if (mode == SOURCE_COPY) if (mode == SOURCE_COPY)
{ {
bps.source_offset += offset; bps.source_offset += offset;
while (length--) while (_len--)
{ {
uint8_t data = bps.source_data[bps.source_offset++]; uint8_t data = bps.source_data[bps.source_offset++];
bps.target_data[bps.output_offset++] = data; bps.target_data[bps.output_offset++] = data;
@ -242,7 +242,7 @@ static enum patch_error bps_apply_patch(
else else
{ {
bps.target_offset += offset; bps.target_offset += offset;
while (length--) while (_len--)
{ {
uint8_t data = bps.target_data[bps.target_offset++]; uint8_t data = bps.target_data[bps.target_offset++];
bps.target_data[bps.output_offset++] = data; bps.target_data[bps.output_offset++] = data;

View File

@ -218,8 +218,8 @@ static bool task_pl_thumbnail_get_thumbnail_paths(
if ( string_is_equal(system, "history") if ( string_is_equal(system, "history")
|| string_is_equal(system, "favorites")) || string_is_equal(system, "favorites"))
{ {
if (!gfx_thumbnail_get_content_dir( if (gfx_thumbnail_get_content_dir(
pl_thumb->thumbnail_path_data, content_dir, sizeof(content_dir))) pl_thumb->thumbnail_path_data, content_dir, sizeof(content_dir)) == 0)
return false; return false;
system_name = content_dir; system_name = content_dir;