mirror of
https://github.com/libretro/RetroArch
synced 2025-04-15 23:42:30 +00:00
Small cleanups - conventionalize char *s, size_t parameter usage
This commit is contained in:
parent
e07028e892
commit
56c63b8c19
27
command.c
27
command.c
@ -694,12 +694,14 @@ bool command_show_osd_msg(command_t *cmd, const char* arg)
|
||||
bool command_load_state_slot(command_t *cmd, const char *arg)
|
||||
{
|
||||
char state_path[16384];
|
||||
size_t _len = 0;
|
||||
char reply[128] = "";
|
||||
unsigned int slot = (unsigned int)strtoul(arg, NULL, 10);
|
||||
bool savestates_enabled = core_info_current_supports_savestate();
|
||||
bool ret = false;
|
||||
state_path[0] = '\0';
|
||||
snprintf(reply, sizeof(reply) - 1, "LOAD_STATE_SLOT %d", slot);
|
||||
_len = strlcpy(reply, "LOAD_STATE_SLOT ", sizeof(reply));
|
||||
_len += snprintf(reply + _len, sizeof(reply) - _len, "%d", slot);
|
||||
if (savestates_enabled)
|
||||
{
|
||||
size_t info_size;
|
||||
@ -716,7 +718,7 @@ bool command_load_state_slot(command_t *cmd, const char *arg)
|
||||
else
|
||||
ret = false;
|
||||
|
||||
cmd->replier(cmd, reply, strlen(reply));
|
||||
cmd->replier(cmd, reply, _len);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -743,7 +745,7 @@ bool command_play_replay_slot(command_t *cmd, const char *arg)
|
||||
if (ret)
|
||||
{
|
||||
input_driver_state_t *input_st = input_state_get_ptr();
|
||||
task_queue_wait(NULL,NULL);
|
||||
task_queue_wait(NULL, NULL);
|
||||
if (input_st->bsv_movie_state_next_handle)
|
||||
snprintf(reply, sizeof(reply) - 1, "PLAY_REPLAY_SLOT %lld", (long long)(input_st->bsv_movie_state_next_handle->identifier));
|
||||
else
|
||||
@ -1449,6 +1451,7 @@ static void scan_states(settings_t *settings,
|
||||
for (i = 0; i < dir_list->size; i++)
|
||||
{
|
||||
unsigned idx;
|
||||
size_t _len;
|
||||
char elem_base[128];
|
||||
const char *ext = NULL;
|
||||
const char *end = NULL;
|
||||
@ -1457,7 +1460,7 @@ static void scan_states(settings_t *settings,
|
||||
if (string_is_empty(dir_elem))
|
||||
continue;
|
||||
|
||||
fill_pathname_base(elem_base, dir_elem, sizeof(elem_base));
|
||||
_len = fill_pathname_base(elem_base, dir_elem, sizeof(elem_base));
|
||||
|
||||
/* Only consider files with a '.state' extension
|
||||
* > i.e. Ignore '.state.auto', '.state.bak', etc. */
|
||||
@ -1476,11 +1479,11 @@ static void scan_states(settings_t *settings,
|
||||
if (savefile_root_length == 0)
|
||||
{
|
||||
savefile_root = dir_elem;
|
||||
savefile_root_length = strlen(dir_elem);
|
||||
savefile_root_length = _len;
|
||||
}
|
||||
|
||||
/* Decode the savestate index */
|
||||
end = dir_elem + strlen(dir_elem);
|
||||
end = dir_elem + _len;
|
||||
while ((end > dir_elem) && ISDIGIT((int)end[-1]))
|
||||
{
|
||||
end--;
|
||||
@ -1500,7 +1503,7 @@ static void scan_states(settings_t *settings,
|
||||
if (idx < 512)
|
||||
BIT512_SET(slot_mapping_low,idx);
|
||||
else if (idx < 1024)
|
||||
BIT512_SET(slot_mapping_high,idx-512);
|
||||
BIT512_SET(slot_mapping_high, idx - 512);
|
||||
}
|
||||
|
||||
/* Next loop on the bitmap, since the file system may have presented the files in any order above */
|
||||
@ -1700,13 +1703,12 @@ void command_event_set_replay_auto_index(settings_t *settings)
|
||||
char elem_base[128] = {0};
|
||||
const char *end = NULL;
|
||||
const char *dir_elem = dir_list->elems[i].data;
|
||||
|
||||
fill_pathname_base(elem_base, dir_elem, sizeof(elem_base));
|
||||
size_t _len = fill_pathname_base(elem_base, dir_elem, sizeof(elem_base));
|
||||
|
||||
if (strstr(elem_base, state_base) != elem_base)
|
||||
continue;
|
||||
|
||||
end = dir_elem + strlen(dir_elem);
|
||||
end = dir_elem + _len;
|
||||
|
||||
while ((end > dir_elem) && ISDIGIT((int)end[-1]))
|
||||
end--;
|
||||
@ -1756,6 +1758,7 @@ void command_event_set_replay_garbage_collect(
|
||||
for (i = 0; i < dir_list->size; i++)
|
||||
{
|
||||
unsigned idx;
|
||||
size_t _len;
|
||||
char elem_base[128];
|
||||
const char *ext = NULL;
|
||||
const char *end = NULL;
|
||||
@ -1764,7 +1767,7 @@ void command_event_set_replay_garbage_collect(
|
||||
if (string_is_empty(dir_elem))
|
||||
continue;
|
||||
|
||||
fill_pathname_base(elem_base, dir_elem, sizeof(elem_base));
|
||||
_len = fill_pathname_base(elem_base, dir_elem, sizeof(elem_base));
|
||||
|
||||
/* Only consider files with a '.replayXX' extension
|
||||
* > i.e. Ignore '.replay.auto', '.replay.bak', etc. */
|
||||
@ -1782,7 +1785,7 @@ void command_event_set_replay_garbage_collect(
|
||||
cnt++;
|
||||
|
||||
/* > Get index */
|
||||
end = dir_elem + strlen(dir_elem);
|
||||
end = dir_elem + _len;
|
||||
|
||||
while ((end > dir_elem) && ISDIGIT((int)end[-1]))
|
||||
end--;
|
||||
|
@ -201,7 +201,7 @@ static int task_database_iterate_start(retro_task_t *task,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int intfstream_get_serial(intfstream_t *fd, char *serial, size_t serial_len, const char *filename)
|
||||
static int intfstream_get_serial(intfstream_t *fd, char *s, size_t len, const char *filename)
|
||||
{
|
||||
const char *system_name = NULL;
|
||||
if (detect_system(fd, &system_name, filename) >= 1)
|
||||
@ -212,19 +212,19 @@ static int intfstream_get_serial(intfstream_t *fd, char *serial, size_t serial_l
|
||||
if (STRLEN_CONST("Sony - PlayStation Portable") == system_len &&
|
||||
string_is_equal_fast(system_name, "Sony - PlayStation Portable", system_len))
|
||||
{
|
||||
if (detect_psp_game(fd, serial, serial_len, filename) != 0)
|
||||
if (detect_psp_game(fd, s, len, filename) != 0)
|
||||
return 1;
|
||||
}
|
||||
else if (STRLEN_CONST("Sony - PlayStation") == system_len &&
|
||||
string_is_equal_fast(system_name, "Sony - PlayStation", system_len))
|
||||
{
|
||||
if (detect_ps1_game(fd, serial, serial_len, filename) != 0)
|
||||
if (detect_ps1_game(fd, s, len, filename) != 0)
|
||||
return 1;
|
||||
}
|
||||
else if (STRLEN_CONST("Sony - PlayStation 2") == system_len &&
|
||||
string_is_equal_fast(system_name, "Sony - PlayStation 2", system_len))
|
||||
{
|
||||
if (detect_ps2_game(fd, serial, serial_len, filename) != 0)
|
||||
if (detect_ps2_game(fd, s, len, filename) != 0)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -233,13 +233,13 @@ static int intfstream_get_serial(intfstream_t *fd, char *serial, size_t serial_l
|
||||
if (STRLEN_CONST("Nintendo - GameCube") == system_len &&
|
||||
string_is_equal_fast(system_name, "Nintendo - GameCube", system_len))
|
||||
{
|
||||
if (detect_gc_game(fd, serial, serial_len, filename) != 0)
|
||||
if (detect_gc_game(fd, s, len, filename) != 0)
|
||||
return 1;
|
||||
}
|
||||
else if (STRLEN_CONST("Nintendo - Wii") == system_len &&
|
||||
string_is_equal_fast(system_name, "Nintendo - Wii", system_len))
|
||||
{
|
||||
if (detect_wii_game(fd, serial, serial_len, filename) != 0)
|
||||
if (detect_wii_game(fd, s, len, filename) != 0)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -248,19 +248,19 @@ static int intfstream_get_serial(intfstream_t *fd, char *serial, size_t serial_l
|
||||
if (STRLEN_CONST("Sega - Mega-CD - Sega CD") == system_len &&
|
||||
string_is_equal_fast(system_name, "Sega - Mega-CD - Sega CD", system_len))
|
||||
{
|
||||
if (detect_scd_game(fd, serial, serial_len, filename) != 0)
|
||||
if (detect_scd_game(fd, s, len, filename) != 0)
|
||||
return 1;
|
||||
}
|
||||
else if (STRLEN_CONST("Sega - Saturn") == system_len &&
|
||||
string_is_equal_fast(system_name, "Sega - Saturn", system_len))
|
||||
{
|
||||
if (detect_sat_game(fd, serial, serial_len, filename) != 0)
|
||||
if (detect_sat_game(fd, s, len, filename) != 0)
|
||||
return 1;
|
||||
}
|
||||
else if (STRLEN_CONST("Sega - Dreamcast") == system_len &&
|
||||
string_is_equal_fast(system_name, "Sega - Dreamcast", system_len))
|
||||
{
|
||||
if (detect_dc_game(fd, serial, serial_len, filename) != 0)
|
||||
if (detect_dc_game(fd, s, len, filename) != 0)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -269,7 +269,7 @@ static int intfstream_get_serial(intfstream_t *fd, char *serial, size_t serial_l
|
||||
}
|
||||
|
||||
static bool intfstream_file_get_serial(const char *name,
|
||||
uint64_t offset, size_t size, char *serial, size_t serial_len)
|
||||
uint64_t offset, size_t size, char *s, size_t len)
|
||||
{
|
||||
int rv;
|
||||
uint8_t *data = NULL;
|
||||
@ -315,7 +315,7 @@ static bool intfstream_file_get_serial(const char *name,
|
||||
}
|
||||
}
|
||||
|
||||
rv = intfstream_get_serial(fd, serial, serial_len, name);
|
||||
rv = intfstream_get_serial(fd, s, len, name);
|
||||
intfstream_close(fd);
|
||||
free(fd);
|
||||
free(data);
|
||||
@ -327,7 +327,7 @@ error:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int task_database_cue_get_serial(const char *name, char* serial, size_t serial_len)
|
||||
static int task_database_cue_get_serial(const char *name, char *s, size_t len)
|
||||
{
|
||||
char track_path[PATH_MAX_LENGTH];
|
||||
uint64_t offset = 0;
|
||||
@ -335,8 +335,8 @@ static int task_database_cue_get_serial(const char *name, char* serial, size_t s
|
||||
|
||||
track_path[0] = '\0';
|
||||
|
||||
if (cue_find_track(name, true, &offset, &size, track_path,
|
||||
sizeof(track_path)) < 0)
|
||||
if (cue_find_track(name, true, &offset, &size,
|
||||
track_path, sizeof(track_path)) < 0)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
RARCH_LOG("%s\n",
|
||||
@ -345,10 +345,10 @@ static int task_database_cue_get_serial(const char *name, char* serial, size_t s
|
||||
return 0;
|
||||
}
|
||||
|
||||
return intfstream_file_get_serial(track_path, offset, size, serial, serial_len);
|
||||
return intfstream_file_get_serial(track_path, offset, size, s, len);
|
||||
}
|
||||
|
||||
static int task_database_gdi_get_serial(const char *name, char* serial, size_t serial_len)
|
||||
static int task_database_gdi_get_serial(const char *name, char *s, size_t len)
|
||||
{
|
||||
char track_path[PATH_MAX_LENGTH];
|
||||
|
||||
@ -364,10 +364,10 @@ static int task_database_gdi_get_serial(const char *name, char* serial, size_t s
|
||||
return 0;
|
||||
}
|
||||
|
||||
return intfstream_file_get_serial(track_path, 0, SIZE_MAX, serial, serial_len);
|
||||
return intfstream_file_get_serial(track_path, 0, SIZE_MAX, s, len);
|
||||
}
|
||||
|
||||
static int task_database_chd_get_serial(const char *name, char* serial, size_t serial_len)
|
||||
static int task_database_chd_get_serial(const char *name, char *serial, size_t len)
|
||||
{
|
||||
int result;
|
||||
intfstream_t *fd = intfstream_open_chd_track(
|
||||
@ -378,7 +378,7 @@ static int task_database_chd_get_serial(const char *name, char* serial, size_t s
|
||||
if (!fd)
|
||||
return 0;
|
||||
|
||||
result = intfstream_get_serial(fd, serial, serial_len, name);
|
||||
result = intfstream_get_serial(fd, serial, len, name);
|
||||
intfstream_close(fd);
|
||||
free(fd);
|
||||
return result;
|
||||
|
@ -1110,7 +1110,7 @@ static bool update_cand(int64_t *cand_index, int64_t *last_index,
|
||||
}
|
||||
|
||||
int cue_find_track(const char *cue_path, bool first,
|
||||
uint64_t *offset, size_t *size, char *track_path, uint64_t max_len)
|
||||
uint64_t *offset, size_t *size, char *s, size_t len)
|
||||
{
|
||||
int rv;
|
||||
intfstream_info_t info;
|
||||
@ -1162,7 +1162,7 @@ int cue_find_track(const char *cue_path, bool first,
|
||||
/* We're changing files since the candidate, update it */
|
||||
if (update_cand(&cand_index, &last_index,
|
||||
&largest, last_file, offset,
|
||||
size, track_path, (size_t)max_len))
|
||||
size, s, len))
|
||||
{
|
||||
rv = 0;
|
||||
if (first)
|
||||
@ -1187,11 +1187,11 @@ int cue_find_track(const char *cue_path, bool first,
|
||||
}
|
||||
else if (string_is_equal_noncase(tmp_token, "INDEX"))
|
||||
{
|
||||
int m, s, f;
|
||||
int _m, _s, _f;
|
||||
task_database_cue_get_token(fd, tmp_token, sizeof(tmp_token));
|
||||
task_database_cue_get_token(fd, tmp_token, sizeof(tmp_token));
|
||||
|
||||
if (sscanf(tmp_token, "%02d:%02d:%02d", &m, &s, &f) < 3)
|
||||
if (sscanf(tmp_token, "%02d:%02d:%02d", &_m, &_s, &_f) < 3)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
RARCH_LOG("Error parsing time stamp '%s'\n", tmp_token);
|
||||
@ -1199,14 +1199,14 @@ int cue_find_track(const char *cue_path, bool first,
|
||||
goto error;
|
||||
}
|
||||
|
||||
last_index = (size_t) (((m * 60 + s) * 75) + f) * 2352;
|
||||
last_index = (size_t)(((_m * 60 + _s) * 75) + _f) * 2352;
|
||||
|
||||
/* If we've changed tracks since the candidate, update it */
|
||||
if ( (cand_track != -1)
|
||||
&& (track != cand_track)
|
||||
&& update_cand(&cand_index, &last_index, &largest,
|
||||
last_file, offset,
|
||||
size, track_path, (size_t)max_len))
|
||||
size, s, len))
|
||||
{
|
||||
rv = 0;
|
||||
if (first)
|
||||
@ -1229,7 +1229,7 @@ int cue_find_track(const char *cue_path, bool first,
|
||||
|
||||
if (update_cand(&cand_index, &last_index,
|
||||
&largest, last_file, offset,
|
||||
size, track_path, (size_t)max_len))
|
||||
size, s, len))
|
||||
rv = 0;
|
||||
|
||||
clean:
|
||||
@ -1268,8 +1268,7 @@ bool cue_next_file(intfstream_t *fd,
|
||||
return false;
|
||||
}
|
||||
|
||||
int gdi_find_track(const char *gdi_path, bool first,
|
||||
char *track_path, uint64_t max_len)
|
||||
int gdi_find_track(const char *gdi_path, bool first, char *s, uint64_t len)
|
||||
{
|
||||
intfstream_info_t info;
|
||||
char tmp_token[MAX_TOKEN_LEN];
|
||||
@ -1341,7 +1340,7 @@ int gdi_find_track(const char *gdi_path, bool first,
|
||||
|
||||
if ((uint64_t)file_size > largest)
|
||||
{
|
||||
strlcpy(track_path, last_file, (size_t)max_len);
|
||||
strlcpy(s, last_file, len);
|
||||
|
||||
rv = 0;
|
||||
largest = file_size;
|
||||
@ -1370,8 +1369,8 @@ error:
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool gdi_next_file(intfstream_t *fd, const char *gdi_path,
|
||||
char *path, uint64_t max_len)
|
||||
size_t gdi_next_file(intfstream_t *fd, const char *gdi_path,
|
||||
char *s, size_t len)
|
||||
{
|
||||
char tmp_token[MAX_TOKEN_LEN];
|
||||
|
||||
@ -1389,15 +1388,15 @@ bool gdi_next_file(intfstream_t *fd, const char *gdi_path,
|
||||
/* File name */
|
||||
if (task_database_cue_get_token(fd, tmp_token, sizeof(tmp_token)) > 0)
|
||||
{
|
||||
size_t _len;
|
||||
char gdi_dir[DIR_MAX_LENGTH];
|
||||
|
||||
fill_pathname_basedir(gdi_dir, gdi_path, sizeof(gdi_dir));
|
||||
fill_pathname_join_special(path, gdi_dir, tmp_token, (size_t)max_len);
|
||||
_len = fill_pathname_join_special(s, gdi_dir, tmp_token, len);
|
||||
|
||||
/* Disc offset */
|
||||
task_database_cue_get_token(fd, tmp_token, sizeof(tmp_token));
|
||||
return true;
|
||||
return _len;
|
||||
}
|
||||
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
@ -45,13 +45,13 @@ size_t detect_wii_game(intfstream_t *fd, char *s, size_t len,
|
||||
int detect_system(intfstream_t *fd, const char **system_name,
|
||||
const char * filename);
|
||||
int cue_find_track(const char *cue_path, bool first, uint64_t *offset,
|
||||
size_t *size, char *track_path, uint64_t max_len);
|
||||
size_t *size, char *s, size_t len);
|
||||
bool cue_next_file(intfstream_t *fd, const char *cue_path,
|
||||
char *s, uint64_t len);
|
||||
int gdi_find_track(const char *gdi_path, bool first, char *track_path,
|
||||
uint64_t max_len);
|
||||
bool gdi_next_file(intfstream_t *fd, const char *gdi_path, char *path,
|
||||
uint64_t max_len);
|
||||
int gdi_find_track(const char *gdi_path, bool first, char *s,
|
||||
size_t len);
|
||||
size_t gdi_next_file(intfstream_t *fd, const char *gdi_path, char *s,
|
||||
size_t len);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user