Standardize len variables - argument should always be named 'len',

while local len variables should have '_' prefix
This commit is contained in:
LibretroAdmin 2025-01-13 21:53:49 +01:00
parent e081bde064
commit 47d888364d
20 changed files with 139 additions and 145 deletions

View File

@ -142,7 +142,7 @@ static void stream_state_cb(pa_stream *s, void *data)
}
}
static void stream_request_cb(pa_stream *s, size_t length, void *data)
static void stream_request_cb(pa_stream *s, size_t len, void *data)
{
pa_t *pa = (pa_t*)data;
pa_threaded_mainloop_signal(pa->mainloop, 0);

View File

@ -100,11 +100,11 @@ static core_info_state_t core_info_st = {
/* JSON Handlers START */
static bool CCJSONObjectMemberHandler(void *context,
const char *pValue, size_t length)
const char *pValue, size_t len)
{
CCJSONContext *pCtx = (CCJSONContext *)context;
if (length)
if (len)
{
switch (pCtx->array_depth)
{
@ -262,12 +262,12 @@ static bool CCJSONObjectMemberHandler(void *context,
}
static bool CCJSONStringHandler(void *context,
const char *pValue, size_t length)
const char *pValue, size_t len)
{
CCJSONContext *pCtx = (CCJSONContext*)context;
if ( pCtx->current_string_val
&& length
&& len
&& !string_is_empty(pValue))
{
if (*pCtx->current_string_val)
@ -290,7 +290,7 @@ static bool CCJSONStringHandler(void *context,
}
static bool CCJSONNumberHandler(void *context,
const char *pValue, size_t length)
const char *pValue, size_t len)
{
CCJSONContext *pCtx = (CCJSONContext*)context;

View File

@ -278,7 +278,7 @@ static bool ITifJSONObjectEndHandler(void* context)
return true;
}
static bool ITifJSONObjectMemberHandler(void* context, const char *pValue, size_t length)
static bool ITifJSONObjectMemberHandler(void* context, const char *pValue, size_t len)
{
ITifJSONContext *pCtx = (ITifJSONContext*)context;
@ -286,7 +286,7 @@ static bool ITifJSONObjectMemberHandler(void* context, const char *pValue, size_
if (pCtx->current_entry_str_val)
return false;
if (length)
if (len)
{
if (string_is_equal(pValue, "expected_button"))
pCtx->current_entry_uint_val = &pCtx->expected_button;
@ -298,11 +298,11 @@ static bool ITifJSONObjectMemberHandler(void* context, const char *pValue, size_
return true;
}
static bool ITifJSONNumberHandler(void* context, const char *pValue, size_t length)
static bool ITifJSONNumberHandler(void* context, const char *pValue, size_t len)
{
ITifJSONContext *pCtx = (ITifJSONContext*)context;
if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_uint_val && len && !string_is_empty(pValue))
*pCtx->current_entry_uint_val = string_to_unsigned(pValue);
/* ignore unknown members */
@ -311,11 +311,11 @@ static bool ITifJSONNumberHandler(void* context, const char *pValue, size_t leng
return true;
}
static bool ITifJSONStringHandler(void* context, const char *pValue, size_t length)
static bool ITifJSONStringHandler(void* context, const char *pValue, size_t len)
{
ITifJSONContext *pCtx = (ITifJSONContext*)context;
if (pCtx->current_entry_str_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_str_val && len && !string_is_empty(pValue))
{
if (*pCtx->current_entry_str_val)
free(*pCtx->current_entry_str_val);
@ -728,7 +728,7 @@ static void retropad_update_input(void)
pointer_y = (int16_t)state;
}
}
/* Do not send extra descriptor state - RA side is not prepared to receive it */
if (i>1)
continue;
@ -1035,7 +1035,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
sensor_item_colors[median_index] = (uint16_t)(fabsf(32*4*value)) << 11;
}
}
/* Button values for sensor test screen, since they do not follow any pattern, it is *
* provided as a direct list. */
if (mouse_type == NETRETROPAD_MOUSE)
@ -1062,7 +1062,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
offset = DESC_OFFSET(&mouse, 0, 0, RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP);
sensor_item_colors[86] = mouse.value[offset] ? 0xA000 : 0x0000;
offset = DESC_OFFSET(&mouse, 0, 0, RETRO_DEVICE_ID_MOUSE_BUTTON_4);
sensor_item_colors[88] = mouse.value[offset] ? 0xA000 : 0x0000;
@ -1094,7 +1094,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
offset = DESC_OFFSET(&lightgun, 0, 0, RETRO_DEVICE_ID_LIGHTGUN_SELECT);
sensor_item_colors[76] = lightgun.value[offset] ? 0xA000 : 0x0000;
offset = DESC_OFFSET(&lightgun, 0, 0, RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN);
sensor_item_colors[77] = lightgun.value[offset] ? 0xA000 : 0x0000;
@ -1390,7 +1390,7 @@ void NETRETROPAD_CORE_PREFIX(retro_run)(void)
pointer_prev_y = pointer_y_coord;
}
}
NETRETROPAD_CORE_PREFIX(video_cb)(frame_buf, 320, 240, 640);
retro_sleep(4);
}

View File

@ -43,7 +43,7 @@ typedef struct
char *image_path;
} DCifJSONContext;
static bool DCifJSONObjectMemberHandler(void* context, const char *pValue, size_t length)
static bool DCifJSONObjectMemberHandler(void* context, const char *pValue, size_t len)
{
DCifJSONContext *pCtx = (DCifJSONContext*)context;
@ -51,7 +51,7 @@ static bool DCifJSONObjectMemberHandler(void* context, const char *pValue, size_
if (pCtx->current_entry_str_val)
return false;
if (length)
if (len)
{
if (string_is_equal(pValue, "image_index"))
pCtx->current_entry_uint_val = &pCtx->image_index;
@ -63,11 +63,11 @@ static bool DCifJSONObjectMemberHandler(void* context, const char *pValue, size_
return true;
}
static bool DCifJSONNumberHandler(void* context, const char *pValue, size_t length)
static bool DCifJSONNumberHandler(void* context, const char *pValue, size_t len)
{
DCifJSONContext *pCtx = (DCifJSONContext*)context;
if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_uint_val && len && !string_is_empty(pValue))
*pCtx->current_entry_uint_val = string_to_unsigned(pValue);
/* ignore unknown members */
@ -76,11 +76,11 @@ static bool DCifJSONNumberHandler(void* context, const char *pValue, size_t leng
return true;
}
static bool DCifJSONStringHandler(void* context, const char *pValue, size_t length)
static bool DCifJSONStringHandler(void* context, const char *pValue, size_t len)
{
DCifJSONContext *pCtx = (DCifJSONContext*)context;
if (pCtx->current_entry_str_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_str_val && len && !string_is_empty(pValue))
{
free(*pCtx->current_entry_str_val);

View File

@ -996,8 +996,7 @@ static void wl_data_device_handle_drop(void *data,
FILE *stream;
int pipefd[2];
void *buffer;
size_t length;
size_t _len = 0;
size_t __len, _len = 0;
ssize_t read = 0;
char *line = NULL;
char file_list[512][512] = { 0 };
@ -1012,7 +1011,7 @@ static void wl_data_device_handle_drop(void *data,
pipe(pipefd);
buffer = wayland_data_offer_receive(wl->input.dpy, offer_data->offer, &length, FILE_MIME, false);
buffer = wayland_data_offer_receive(wl->input.dpy, offer_data->offer, &__len, FILE_MIME, false);
close(pipefd[1]);
close(pipefd[0]);
@ -1023,7 +1022,7 @@ static void wl_data_device_handle_drop(void *data,
wl_data_offer_destroy(offer_data->offer);
free(offer_data);
if (!(stream = fmemopen(buffer, length, "r")))
if (!(stream = fmemopen(buffer, __len, "r")))
{
RARCH_WARN("[Wayland]: Failed to open DnD buffer\n");
return;

View File

@ -125,7 +125,7 @@ static bool KTifJSONObjectEndHandler(void* context)
return true;
}
static bool KTifJSONObjectMemberHandler(void* context, const char *pValue, size_t length)
static bool KTifJSONObjectMemberHandler(void* context, const char *pValue, size_t len)
{
KTifJSONContext *pCtx = (KTifJSONContext*)context;
@ -133,7 +133,7 @@ static bool KTifJSONObjectMemberHandler(void* context, const char *pValue, size_
if (pCtx->current_entry_str_val)
return false;
if (length)
if (len)
{
if (string_is_equal(pValue, "frame"))
pCtx->current_entry_uint_val = &pCtx->frame;
@ -149,11 +149,11 @@ static bool KTifJSONObjectMemberHandler(void* context, const char *pValue, size_
return true;
}
static bool KTifJSONNumberHandler(void* context, const char *pValue, size_t length)
static bool KTifJSONNumberHandler(void* context, const char *pValue, size_t len)
{
KTifJSONContext *pCtx = (KTifJSONContext*)context;
if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_uint_val && len && !string_is_empty(pValue))
*pCtx->current_entry_uint_val = string_to_unsigned(pValue);
/* ignore unknown members */
@ -162,11 +162,11 @@ static bool KTifJSONNumberHandler(void* context, const char *pValue, size_t leng
return true;
}
static bool KTifJSONStringHandler(void* context, const char *pValue, size_t length)
static bool KTifJSONStringHandler(void* context, const char *pValue, size_t len)
{
KTifJSONContext *pCtx = (KTifJSONContext*)context;
if (pCtx->current_entry_str_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_str_val && len && !string_is_empty(pValue))
{
if (*pCtx->current_entry_str_val)
free(*pCtx->current_entry_str_val);

View File

@ -125,7 +125,7 @@ static bool JTifJSONObjectEndHandler(void* context)
return true;
}
static bool JTifJSONObjectMemberHandler(void* context, const char *pValue, size_t length)
static bool JTifJSONObjectMemberHandler(void* context, const char *pValue, size_t len)
{
JTifJSONContext *pCtx = (JTifJSONContext*)context;
@ -133,7 +133,7 @@ static bool JTifJSONObjectMemberHandler(void* context, const char *pValue, size_
if (pCtx->current_entry_str_val)
return false;
if (length)
if (len)
{
if (string_is_equal(pValue, "frame"))
pCtx->current_entry_uint_val = &pCtx->frame;
@ -149,11 +149,11 @@ static bool JTifJSONObjectMemberHandler(void* context, const char *pValue, size_
return true;
}
static bool JTifJSONNumberHandler(void* context, const char *pValue, size_t length)
static bool JTifJSONNumberHandler(void* context, const char *pValue, size_t len)
{
JTifJSONContext *pCtx = (JTifJSONContext*)context;
if (pCtx->current_entry_uint_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_uint_val && len && !string_is_empty(pValue))
*pCtx->current_entry_uint_val = string_to_unsigned(pValue);
/* ignore unknown members */
@ -162,11 +162,11 @@ static bool JTifJSONNumberHandler(void* context, const char *pValue, size_t leng
return true;
}
static bool JTifJSONStringHandler(void* context, const char *pValue, size_t length)
static bool JTifJSONStringHandler(void* context, const char *pValue, size_t len)
{
JTifJSONContext *pCtx = (JTifJSONContext*)context;
if (pCtx->current_entry_str_val && length && !string_is_empty(pValue))
if (pCtx->current_entry_str_val && len && !string_is_empty(pValue))
{
if (*pCtx->current_entry_str_val)
free(*pCtx->current_entry_str_val);

View File

@ -520,17 +520,18 @@ static void udev_joypad_poll(void)
for (p = 0; p < MAX_USERS; p++)
{
int i, len;
int i;
ssize_t _len;
struct input_event events[32];
struct udev_joypad *pad = &udev_pads[p];
if (pad->fd < 0)
continue;
while ((len = read(pad->fd, events, sizeof(events))) > 0)
while ((_len = read(pad->fd, events, sizeof(events))) > 0)
{
len /= sizeof(*events);
for (i = 0; i < len; i++)
_len /= sizeof(*events);
for (i = 0; i < _len; i++)
{
uint16_t type = events[i].type;
uint16_t code = events[i].code;

View File

@ -50,8 +50,8 @@ struct hid_driver
const char *(*name)(void *handle, unsigned pad);
const char *ident;
void (*send_control)(void *handle, uint8_t *buf, size_t size);
int32_t (*set_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t length);
int32_t (*get_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t length);
int32_t (*set_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t len);
int32_t (*get_report)(void *handle, uint8_t report_type, uint8_t report_id, uint8_t *data, size_t len);
int32_t (*set_idle)(void *handle, uint8_t amount);
int32_t (*set_protocol)(void *handle, uint8_t protocol);
int32_t (*read)(void *handle, void *buf, size_t size);

View File

@ -526,7 +526,7 @@ error:
*/
int file_archive_compressed_read(
const char * path, void **buf,
const char* optional_filename, int64_t *length)
const char* optional_filename, int64_t *len)
{
const struct
file_archive_file_backend *backend = NULL;
@ -540,7 +540,7 @@ int file_archive_compressed_read(
*/
if (optional_filename && path_is_valid(optional_filename))
{
*length = 0;
*len = 0;
return 1;
}
@ -555,17 +555,17 @@ int file_archive_compressed_read(
{
/* could not extract string and substring. */
string_list_free(str_list);
*length = 0;
*len = 0;
return 0;
}
backend = file_archive_get_file_backend(str_list->elems[0].data);
*length = backend->compressed_file_read(str_list->elems[0].data,
*len = backend->compressed_file_read(str_list->elems[0].data,
str_list->elems[1].data, buf, optional_filename);
string_list_free(str_list);
if (*length != -1)
if (*len != -1)
return 1;
return 0;

View File

@ -515,9 +515,9 @@ static int sevenzip_parse_file_iterate_step(void *context,
}
static uint32_t sevenzip_stream_crc32_calculate(uint32_t crc,
const uint8_t *data, size_t length)
const uint8_t *data, size_t len)
{
return encoding_crc32(crc, data, length);
return encoding_crc32(crc, data, len);
}
const struct file_archive_file_backend sevenzip_backend = {

View File

@ -256,9 +256,9 @@ static int zlib_stream_decompress_data_to_file_iterate(
}
static uint32_t zlib_stream_crc32_calculate(uint32_t crc,
const uint8_t *data, size_t length)
const uint8_t *data, size_t len)
{
return encoding_crc32(crc, data, length);
return encoding_crc32(crc, data, len);
}
static bool zip_file_decompressed_handle(

View File

@ -66,16 +66,16 @@ static void *nbio_mmap_unix_open(const char * filename, unsigned mode)
static const int o_flags[] = { O_RDONLY, O_RDWR|O_CREAT|O_TRUNC, O_RDWR, O_RDONLY, O_RDWR|O_CREAT|O_TRUNC };
static const int map_flags[] = { PROT_READ, PROT_WRITE|PROT_READ, PROT_WRITE|PROT_READ, PROT_READ, PROT_WRITE|PROT_READ };
size_t len;
size_t _len;
void* ptr = NULL;
struct nbio_mmap_unix_t* handle = NULL;
int fd = open(filename, o_flags[mode]|O_CLOEXEC, 0644);
if (fd < 0)
return NULL;
len = lseek(fd, 0, SEEK_END);
if (len != 0)
ptr = mmap(NULL, len, map_flags[mode], MAP_SHARED, fd, 0);
_len = lseek(fd, 0, SEEK_END);
if (_len != 0)
ptr = mmap(NULL, _len, map_flags[mode], MAP_SHARED, fd, 0);
if (ptr == MAP_FAILED)
{
@ -86,7 +86,7 @@ static void *nbio_mmap_unix_open(const char * filename, unsigned mode)
handle = malloc(sizeof(struct nbio_mmap_unix_t));
handle->fd = fd;
handle->map_flags = map_flags[mode];
handle->len = len;
handle->len = _len;
handle->ptr = ptr;
return handle;
}
@ -132,7 +132,7 @@ static void nbio_mmap_unix_resize(void *data, size_t len)
abort();
}
static void *nbio_mmap_unix_get_ptr(void *data, size_t* len)
static void *nbio_mmap_unix_get_ptr(void *data, size_t *len)
{
struct nbio_mmap_unix_t* handle = (struct nbio_mmap_unix_t*)data;
if (!handle)

View File

@ -987,12 +987,12 @@ void rjson_set_max_depth(rjson_t *json, unsigned int max_depth)
json->stack_max = max_depth;
}
const char *rjson_get_string(rjson_t *json, size_t *length)
const char *rjson_get_string(rjson_t *json, size_t *len)
{
char* str = (json->string_pass_through
? json->string_pass_through : json->string);
if (length)
*length = json->string_len;
if (len)
*len = json->string_len;
str[json->string_len] = '\0';
return str;
}
@ -1112,7 +1112,7 @@ void rjson_free(rjson_t *json)
}
static bool _rjson_nop_default(void *context) { return true; }
static bool _rjson_nop_string(void *context, const char *value, size_t length) { return true; }
static bool _rjson_nop_string(void *context, const char *value, size_t len) { return true; }
static bool _rjson_nop_bool(void *context, bool value) { return true; }
enum rjson_type rjson_parse(rjson_t *json, void* context,

View File

@ -252,11 +252,11 @@ uint32_t crc32_adjust(uint32_t checksum, uint8_t input)
return ((checksum >> 8) & 0x00ffffff) ^ crc32_hash_table[(checksum ^ input) & 0xff];
}
uint32_t crc32_calculate(const uint8_t *data, size_t length)
uint32_t crc32_calculate(const uint8_t *data, size_t len)
{
size_t i;
uint32_t checksum = ~0;
for (i = 0; i < length; i++)
for (i = 0; i < len; i++)
checksum = crc32_adjust(checksum, data[i]);
return ~checksum;
}
@ -486,9 +486,9 @@ static int SHA1Result(struct sha1_context *context)
static void SHA1Input(struct sha1_context *context,
const unsigned char *message_array,
unsigned length)
unsigned len)
{
if (!length)
if (!len)
return;
if (context->Computed || context->Corrupted)
@ -497,7 +497,7 @@ static void SHA1Input(struct sha1_context *context,
return;
}
while (length-- && !context->Corrupted)
while (len-- && !context->Corrupted)
{
context->Message_Block[context->Message_Block_Index++] =
(*message_array & 0xFF);

View File

@ -92,7 +92,7 @@ void* mmap(void *addr, size_t len, int prot, int flags,
return((void*) ((int8_t*)map + offset));
}
int munmap(void *addr, size_t length)
int munmap(void *addr, size_t len)
{
if (!UnmapViewOfFile(addr))
return -1;

View File

@ -32,7 +32,7 @@ int main(void)
{
char *data;
struct http_t *http1, *http3;
size_t len, pos = 0, tot = 0;
size_t _len, pos = 0, tot = 0;
if (!network_init())
return -1;
@ -45,7 +45,7 @@ int main(void)
http3 = net_http_new("http://www.wikipedia.org/");
while (!net_http_update(http3, NULL, NULL)) {}
data = (char*)net_http_data(http3, &len, false);
data = (char*)net_http_data(http3, &_len, false);
printf("%.*s\n", (int)256, data);

View File

@ -4069,8 +4069,7 @@ static size_t menu_driver_get_current_menu_label(struct menu_state *menu_st,
#endif
static size_t menu_driver_get_current_menu_sublabel(
struct menu_state *menu_st,
char *s, size_t len)
struct menu_state *menu_st, char *s, size_t len)
{
menu_entry_t entry;
MENU_ENTRY_INITIALIZE(entry);

View File

@ -1141,8 +1141,7 @@ static bool validate_game_specific_options(char *s, size_t len)
return true;
}
static bool validate_folder_options(
char *s, size_t len, bool mkdir)
static bool validate_folder_options(char *s, size_t len, bool mkdir)
{
const char *game_path = path_get(RARCH_PATH_BASENAME);
@ -4852,42 +4851,42 @@ void runloop_path_fill_names(void)
if (string_is_empty(runloop_st->name.ups))
{
size_t len = strlcpy(runloop_st->name.ups,
size_t _len = strlcpy(runloop_st->name.ups,
runloop_st->runtime_content_path_basename,
sizeof(runloop_st->name.ups));
strlcpy(runloop_st->name.ups + len,
strlcpy(runloop_st->name.ups + _len,
".ups",
sizeof(runloop_st->name.ups) - len);
sizeof(runloop_st->name.ups) - _len);
}
if (string_is_empty(runloop_st->name.bps))
{
size_t len = strlcpy(runloop_st->name.bps,
size_t _len = strlcpy(runloop_st->name.bps,
runloop_st->runtime_content_path_basename,
sizeof(runloop_st->name.bps));
strlcpy(runloop_st->name.bps + len,
strlcpy(runloop_st->name.bps + _len,
".bps",
sizeof(runloop_st->name.bps) - len);
sizeof(runloop_st->name.bps) - _len);
}
if (string_is_empty(runloop_st->name.ips))
{
size_t len = strlcpy(runloop_st->name.ips,
size_t _len = strlcpy(runloop_st->name.ips,
runloop_st->runtime_content_path_basename,
sizeof(runloop_st->name.ips));
strlcpy(runloop_st->name.ips + len,
strlcpy(runloop_st->name.ips + _len,
".ips",
sizeof(runloop_st->name.ips) - len);
sizeof(runloop_st->name.ips) - _len);
}
if (string_is_empty(runloop_st->name.xdelta))
{
size_t len = strlcpy(runloop_st->name.xdelta,
size_t _len = strlcpy(runloop_st->name.xdelta,
runloop_st->runtime_content_path_basename,
sizeof(runloop_st->name.xdelta));
strlcpy(runloop_st->name.xdelta + len,
strlcpy(runloop_st->name.xdelta + _len,
".xdelta",
sizeof(runloop_st->name.xdelta) - len);
sizeof(runloop_st->name.xdelta) - _len);
}
}
@ -7345,19 +7344,19 @@ void runloop_task_msg_queue_push(
}
bool runloop_get_current_savestate_path(char *path, size_t len)
bool runloop_get_current_savestate_path(char *s, size_t len)
{
settings_t *settings = config_get_ptr();
int state_slot = settings ? settings->ints.state_slot : 0;
return runloop_get_savestate_path(path, len, state_slot);
return runloop_get_savestate_path(s, len, state_slot);
}
bool runloop_get_savestate_path(char *path, size_t len, int state_slot)
bool runloop_get_savestate_path(char *s, size_t len, int state_slot)
{
runloop_state_t *runloop_st = &runloop_state;
const char *name_savestate = NULL;
if (!path)
if (!s)
return false;
name_savestate = runloop_st->name.savestate;
@ -7365,61 +7364,61 @@ bool runloop_get_savestate_path(char *path, size_t len, int state_slot)
return false;
if (state_slot < 0)
fill_pathname_join_delim(path, name_savestate, "auto", '.', len);
fill_pathname_join_delim(s, name_savestate, "auto", '.', len);
else
{
size_t _len = strlcpy(path, name_savestate, len);
size_t _len = strlcpy(s, name_savestate, len);
if (state_slot > 0)
snprintf(path + _len, len - _len, "%d", state_slot);
snprintf(s + _len, len - _len, "%d", state_slot);
}
return true;
}
bool runloop_get_current_replay_path(char *path, size_t len)
bool runloop_get_current_replay_path(char *s, size_t len)
{
settings_t *settings = config_get_ptr();
int slot = settings ? settings->ints.replay_slot : 0;
return runloop_get_replay_path(path, len, slot);
return runloop_get_replay_path(s, len, slot);
}
bool runloop_get_replay_path(char *path, size_t len, unsigned slot)
bool runloop_get_replay_path(char *s, size_t len, unsigned slot)
{
size_t _len;
runloop_state_t *runloop_st = &runloop_state;
const char *name_replay = NULL;
if (!path)
if (!s)
return false;
name_replay = runloop_st->name.replay;
if (string_is_empty(name_replay))
return false;
_len = strlcpy(path, name_replay, len);
_len = strlcpy(s, name_replay, len);
if (slot >= 0)
snprintf(path + _len, len - _len, "%d", slot);
snprintf(s + _len, len - _len, "%d", slot);
return true;
}
bool runloop_get_entry_state_path(char *path, size_t len, unsigned slot)
bool runloop_get_entry_state_path(char *s, size_t len, unsigned slot)
{
size_t _len;
runloop_state_t *runloop_st = &runloop_state;
const char *name_savestate = NULL;
if (!path || !slot)
if (!s || !slot)
return false;
name_savestate = runloop_st->name.savestate;
if (string_is_empty(name_savestate))
return false;
_len = strlcpy(path, name_savestate, len);
snprintf(path + _len, len - _len, "%d.entry", slot);
_len = strlcpy(s, name_savestate, len);
snprintf(s + _len, len - _len, "%d.entry", slot);
return true;
}
@ -7892,8 +7891,8 @@ void runloop_path_set_names(void)
}
void runloop_path_set_redirect(settings_t *settings,
const char *old_savefile_dir,
const char *old_savestate_dir)
const char *old_savefile_dir,
const char *old_savestate_dir)
{
char content_dir_name[DIR_MAX_LENGTH];
char new_savefile_dir[DIR_MAX_LENGTH];

View File

@ -551,14 +551,12 @@ int detect_scd_game(intfstream_t *fd, char *s, size_t len, const char *filename)
#define SCD_SERIAL_OFFSET 0x0193
#define SCD_SERIAL_LEN 11
#define SCD_REGION_OFFSET 0x0200
size_t _len;
int index;
size_t _len, __len, ___len;
char pre_game_id[SCD_SERIAL_LEN+1];
char raw_game_id[SCD_SERIAL_LEN+1];
char check_suffix_50[10];
char region_id;
size_t length;
size_t lengthref;
int index;
char lgame_id[10];
/* Load raw serial or quit */
@ -588,9 +586,9 @@ int detect_scd_game(intfstream_t *fd, char *s, size_t len, const char *filename)
string_remove_all_whitespace(pre_game_id, raw_game_id); /** rule: remove all spaces from the raw serial globally **/
/** Dissect this pre serial into parts **/
length = strlen(pre_game_id);
lengthref = length - 2;
strncpy(check_suffix_50, &pre_game_id[lengthref], length - 2 + 1);
__len = strlen(pre_game_id);
___len = __len - 2;
strncpy(check_suffix_50, &pre_game_id[___len], __len - 2 + 1);
check_suffix_50[2] = '\0';
/** redump serials are built differently for each prefix **/
@ -666,7 +664,7 @@ int detect_sat_game(intfstream_t *fd, char *s, size_t len, const char *filename)
#define SAT_SERIAL_OFFSET 0x0030
#define SAT_SERIAL_LEN 9
#define SAT_REGION_OFFSET 0x0050
size_t _len, length;
size_t _len, __len;
char raw_game_id[SAT_SERIAL_LEN+1];
char region_id;
char check_suffix_5[10];
@ -703,10 +701,10 @@ int detect_sat_game(intfstream_t *fd, char *s, size_t len, const char *filename)
string_trim_whitespace_left(raw_game_id);
/** Dissect this raw serial into parts **/
length = strlen(raw_game_id);
strncpy(check_suffix_5, &raw_game_id[length - 2], 2);
__len = strlen(raw_game_id);
strncpy(check_suffix_5, &raw_game_id[__len - 2], 2);
check_suffix_5[2] = '\0';
strncpy(check_suffix_50, &raw_game_id[length - 2], 2);
strncpy(check_suffix_50, &raw_game_id[__len - 2], 2);
check_suffix_50[2] = '\0';
/** redump serials are built differently for each region **/
@ -717,8 +715,8 @@ int detect_sat_game(intfstream_t *fd, char *s, size_t len, const char *filename)
&& raw_game_id[1] == 'K'
&& raw_game_id[2] == '-')
{
strncpy(s, &raw_game_id[3], length - 3);
s[length - 3] = '\0';
strncpy(s, &raw_game_id[3], __len - 3);
s[__len - 3] = '\0';
}
else
strlcpy(s, raw_game_id, len);
@ -730,13 +728,13 @@ int detect_sat_game(intfstream_t *fd, char *s, size_t len, const char *filename)
if ( !strcmp(check_suffix_5, "-5")
|| !strcmp(check_suffix_50, "50"))
{
strncpy(rgame_id, &raw_game_id[2], length - 4);
rgame_id[length - 4] = '\0';
strncpy(rgame_id, &raw_game_id[2], __len - 4);
rgame_id[__len - 4] = '\0';
}
else
{
strncpy(rgame_id, &raw_game_id[2], length - 1);
rgame_id[length - 1] = '\0';
strncpy(rgame_id, &raw_game_id[2], __len - 1);
rgame_id[__len - 1] = '\0';
}
_len = strlcat(s, lgame_id, len);
_len += strlcpy(s + _len, rgame_id, len - _len);
@ -759,13 +757,11 @@ int detect_sat_game(intfstream_t *fd, char *s, size_t len, const char *filename)
int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
{
size_t _len;
size_t _len, __len, ___len;
int total_hyphens;
int total_hyphens_recalc;
char pre_game_id[50];
char raw_game_id[50];
size_t length;
size_t length_recalc;
int index;
size_t size_t_var;
char lgame_id[20];
@ -794,7 +790,7 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
string_trim_whitespace_left(raw_game_id);
string_replace_multi_space_with_single_space(raw_game_id);
string_replace_whitespace_with_single_character(raw_game_id, '-');
length = strlen(raw_game_id);
__len = strlen(raw_game_id);
total_hyphens = string_count_occurrences_single_character(raw_game_id, '-');
/** redump serials are built differently for each prefix **/
@ -809,14 +805,14 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
size_t_var = (size_t)index;
strncpy(lgame_id, &raw_game_id[0], size_t_var);
lgame_id[index] = '\0';
strncpy(rgame_id, &raw_game_id[index + 1], length - 1);
rgame_id[length - 1] = '\0';
strncpy(rgame_id, &raw_game_id[index + 1], __len - 1);
rgame_id[__len - 1] = '\0';
_len = strlcat(s, lgame_id, len);
s[ _len] = '-';
s[++_len] = '\0';
strlcpy(s + _len, rgame_id, len - _len);
}
else if (length <= 7)
else if (__len <= 7)
{
strncpy(s, raw_game_id, 7);
s[7] = '\0';
@ -825,8 +821,8 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
{
strncpy(lgame_id, raw_game_id, 7);
lgame_id[7] = '\0';
strncpy(rgame_id, &raw_game_id[length - 2], length - 1);
rgame_id[length - 1] = '\0';
strncpy(rgame_id, &raw_game_id[__len - 2], __len - 1);
rgame_id[__len - 1] = '\0';
_len = strlcat(s, lgame_id, len);
s[ _len] = '-';
s[++_len] = '\0';
@ -839,8 +835,8 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
{
strncpy(lgame_id, raw_game_id, 1);
lgame_id[1] = '\0';
strncpy(rgame_id, &raw_game_id[1], length - 1);
rgame_id[length - 1] = '\0';
strncpy(rgame_id, &raw_game_id[1], __len - 1);
rgame_id[__len - 1] = '\0';
_len = strlcpy(pre_game_id, lgame_id, sizeof(pre_game_id));
pre_game_id[ _len] = '-';
pre_game_id[++_len] = '\0';
@ -855,12 +851,12 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
size_t_var = (size_t)index;
strncpy(lgame_id, pre_game_id, size_t_var);
lgame_id[index] = '\0';
length_recalc = strlen(pre_game_id);
___len = strlen(pre_game_id);
}
else
{
length_recalc = strlen(pre_game_id) - 1;
if (length_recalc <= 8)
___len = strlen(pre_game_id) - 1;
if (___len <= 8)
{
strncpy(s, pre_game_id, 8);
s[8] = '\0';
@ -870,8 +866,8 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
strncpy(lgame_id, pre_game_id, 7);
lgame_id[7] = '\0';
}
strncpy(rgame_id, &pre_game_id[length_recalc - 2], length_recalc - 1);
rgame_id[length_recalc - 1] = '\0';
strncpy(rgame_id, &pre_game_id[___len - 2], ___len - 1);
rgame_id[___len - 1] = '\0';
_len = strlcat(s, lgame_id, len);
s[ _len] = '-';
s[++_len] = '\0';
@ -891,8 +887,8 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
return false;
strncpy(lgame_id, raw_game_id, index - 1);
lgame_id[index - 1] = '\0';
strncpy(rgame_id, &raw_game_id[length - 4], length - 3);
rgame_id[length - 3] = '\0';
strncpy(rgame_id, &raw_game_id[__len - 4], __len - 3);
rgame_id[__len - 3] = '\0';
_len = strlcat(s, lgame_id, len);
s[ _len] = '-';
s[++_len] = '\0';
@ -907,7 +903,7 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
&& raw_game_id[1] == 'K'
&& raw_game_id[2] == '-')
{
if (length <= 8)
if (__len <= 8)
{
/* For 8 chars serials in 'MK-xxxxx' format, we need to remove 'MK-' to match Redump database
* Sega GT being the only exception (MK-51053), we have to check if it's not that game first */
@ -926,8 +922,8 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename)
{
strncpy(lgame_id, raw_game_id, 8);
lgame_id[8] = '\0';
strncpy(rgame_id, &raw_game_id[length - 2], length - 1);
rgame_id[length - 1] = '\0';
strncpy(rgame_id, &raw_game_id[__len - 2], __len - 1);
rgame_id[__len - 1] = '\0';
_len = strlcat(s, lgame_id, len);
s[ _len] = '-';
s[++_len] = '\0';