Replace more strlcats

This commit is contained in:
libretroadmin 2024-06-16 19:42:32 +02:00
parent d3c14a6e3e
commit 3f0d3ec393
3 changed files with 92 additions and 87 deletions

View File

@ -1899,12 +1899,13 @@ static void core_info_list_resolve_all_extensions(
for (i = 0; i < core_info_list->count; i++) for (i = 0; i < core_info_list->count; i++)
{ {
size_t _len;
if (!core_info_list->list[i].supported_extensions) if (!core_info_list->list[i].supported_extensions)
continue; continue;
strlcat(core_info_list->all_ext, _len = strlcat(core_info_list->all_ext,
core_info_list->list[i].supported_extensions, all_ext_len); core_info_list->list[i].supported_extensions, all_ext_len);
strlcat(core_info_list->all_ext, "|", all_ext_len); strlcpy(core_info_list->all_ext + _len, "|", all_ext_len - _len);
} }
#ifdef HAVE_7ZIP #ifdef HAVE_7ZIP
strlcat(core_info_list->all_ext, "7z|", all_ext_len); strlcat(core_info_list->all_ext, "7z|", all_ext_len);

View File

@ -1523,9 +1523,9 @@ static int action_bind_sublabel_subsystem_load(
for (j = 0; j < content_get_subsystem_rom_id(); j++) for (j = 0; j < content_get_subsystem_rom_id(); j++)
{ {
strlcat(buf, path_basename(content_get_subsystem_rom(j)), sizeof(buf)); size_t _len = strlcat(buf, path_basename(content_get_subsystem_rom(j)), sizeof(buf));
if (j != content_get_subsystem_rom_id() - 1) if (j != content_get_subsystem_rom_id() - 1)
strlcat(buf, "\n", sizeof(buf)); _len += strlcpy(buf + _len, "\n", sizeof(buf) - _len);
} }
if (!string_is_empty(buf)) if (!string_is_empty(buf))

View File

@ -6185,7 +6185,8 @@ static void retroarch_print_version(void)
static void retroarch_print_help(const char *arg0) static void retroarch_print_help(const char *arg0)
{ {
char buf[2048]; char buf[2048];
buf[0] = '\0'; size_t _len = 0;
buf[0] = '\0';
frontend_driver_attach_console(); frontend_driver_attach_console();
fputs("\n", stdout); fputs("\n", stdout);
@ -6196,7 +6197,7 @@ static void retroarch_print_help(const char *arg0)
fprintf(stdout, "Usage: %s [OPTIONS]... [FILE]\n\n", arg0); fprintf(stdout, "Usage: %s [OPTIONS]... [FILE]\n\n", arg0);
strlcat(buf, _len = strlcpy(buf + _len,
" -h, --help " " -h, --help "
"Show this help message.\n" "Show this help message.\n"
" -v, --verbose " " -v, --verbose "
@ -6207,29 +6208,29 @@ static void retroarch_print_help(const char *arg0)
"Show version.\n" "Show version.\n"
" --features " " --features "
"Print available features compiled into program.\n" "Print available features compiled into program.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#ifdef HAVE_MENU #ifdef HAVE_MENU
strlcat(buf, _len += strlcpy(buf + _len,
" --menu " " --menu "
"Do not require content or libretro core to be loaded,\n" "Do not require content or libretro core to be loaded,\n"
" " " "
" starts directly in menu. If no arguments are passed to\n" " starts directly in menu. If no arguments are passed to\n"
" " " "
" the program, it is equivalent to using --menu as only argument.\n" " the program, it is equivalent to using --menu as only argument.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#endif #endif
#ifdef HAVE_CONFIGFILE #ifdef HAVE_CONFIGFILE
strlcat(buf, " -c, --config=FILE " _len += strlcpy(buf + _len, " -c, --config=FILE "
"Path for config file.\n", sizeof(buf)); "Path for config file.\n", sizeof(buf) - _len);
#ifdef _WIN32 #ifdef _WIN32
strlcat(buf, " " _len += strlcpy(buf + _len, " "
" Defaults to retroarch.cfg in same directory as retroarch.exe.\n" " Defaults to retroarch.cfg in same directory as retroarch.exe.\n"
" " " "
" If a default config is not found, the program will attempt to create one.\n" " If a default config is not found, the program will attempt to create one.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#else #else
strlcat(buf, _len += strlcpy(buf + _len,
" " " "
" By default looks for config in\n" " By default looks for config in\n"
" " " "
@ -6242,22 +6243,32 @@ static void retroarch_print_help(const char *arg0)
" If a default config is not found, the program will attempt to create one\n" " If a default config is not found, the program will attempt to create one\n"
" " " "
" based on the skeleton config (" GLOBAL_CONFIG_DIR "/retroarch.cfg).\n" " based on the skeleton config (" GLOBAL_CONFIG_DIR "/retroarch.cfg).\n"
, sizeof(buf)); , sizeof(buf) - _len);
#endif #endif
strlcat(buf, " --appendconfig=FILE " _len += strlcpy(buf + _len, " --appendconfig=FILE "
"Extra config files are loaded in, and take priority over\n" "Extra config files are loaded in, and take priority over\n"
" " " "
" config selected in -c (or default). Multiple configs are\n" " config selected in -c (or default). Multiple configs are\n"
" " " "
" delimited by '|'.\n" " delimited by '|'.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#endif #endif
fputs(buf, stdout); fputs(buf, stdout);
buf[0] = '\0'; buf[0] = '\0';
_len = 0;
_len += strlcpy(buf + _len,
" --subsystem=NAME "
"Use a subsystem of the libretro core. Multiple content\n"
" "
" files are loaded as multiple arguments. If a content\n"
" "
" file is skipped, use a blank (\"\") command line argument.\n"
, sizeof(buf) - _len);
#ifdef HAVE_DYNAMIC #ifdef HAVE_DYNAMIC
strlcat(buf, _len += strlcpy(buf + _len,
" -L, --libretro=FILE " " -L, --libretro=FILE "
"Path to libretro implementation. Overrides any config setting.\n" "Path to libretro implementation. Overrides any config setting.\n"
" " " "
@ -6266,42 +6277,34 @@ static void retroarch_print_help(const char *arg0)
" 1. The full path to a core shared object library: path/to/<core_name>_libretro.<lib_ext>\n" " 1. The full path to a core shared object library: path/to/<core_name>_libretro.<lib_ext>\n"
" " " "
" 2. A core shared object library 'file name' (*): <core_name>_libretro.<lib_ext>\n" " 2. A core shared object library 'file name' (*): <core_name>_libretro.<lib_ext>\n"
, sizeof(buf)); , sizeof(buf) - _len);
strlcat(buf, _len += strlcpy(buf + _len,
" " " "
" 3. A core 'short name' (*): <core_name>_libretro OR <core_name>\n" " 3. A core 'short name' (*): <core_name>_libretro OR <core_name>\n"
" " " "
" (*) If 'file name' or 'short name' do not correspond to an existing full file path,\n" " (*) If 'file name' or 'short name' do not correspond to an existing full file path,\n"
" " " "
" the configured frontend 'cores' directory will be searched for a match.\n" " the configured frontend 'cores' directory will be searched for a match.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#endif #endif
strlcat(buf, _len += strlcpy(buf + _len,
" --subsystem=NAME "
"Use a subsystem of the libretro core. Multiple content\n"
" "
" files are loaded as multiple arguments. If a content\n"
" "
" file is skipped, use a blank (\"\") command line argument.\n"
, sizeof(buf));
strlcat(buf,
" " " "
" Content must be loaded in an order which depends on the\n" " Content must be loaded in an order which depends on the\n"
" " " "
" particular subsystem used. See verbose log output to learn\n" " particular subsystem used. See verbose log output to learn\n"
" " " "
" how a particular subsystem wants content to be loaded.\n" " how a particular subsystem wants content to be loaded.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#ifdef HAVE_LIBRETRODB #ifdef HAVE_LIBRETRODB
strlcat(buf, _len += strlcpy(buf + _len,
" --scan=PATH|FILE " " --scan=PATH|FILE "
"Import content from path.\n" "Import content from path.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#endif #endif
strlcat(buf, _len = strlcpy(buf + _len,
" -f, --fullscreen " " -f, --fullscreen "
"Start the program in fullscreen regardless of config setting.\n" "Start the program in fullscreen regardless of config setting.\n"
" --set-shader=PATH " " --set-shader=PATH "
@ -6310,18 +6313,20 @@ static void retroarch_print_help(const char *arg0)
" Effectively overrides automatic shader presets.\n" " Effectively overrides automatic shader presets.\n"
" " " "
" An empty argument \"\" will disable automatic shader presets.\n" " An empty argument \"\" will disable automatic shader presets.\n"
, sizeof(buf)); , sizeof(buf) - _len);
fputs(buf, stdout); fputs(buf, stdout);
buf[0] = '\0'; buf[0] = '\0';
_len = 0;
printf( " -N, --nodevice=PORT " _len += snprintf(buf + _len, sizeof(buf) - _len," -N, --nodevice=PORT "
"Disconnects controller device connected to PORT (1 to %d).\n", MAX_USERS); "Disconnects controller device connected to PORT (1 to %d).\n", MAX_USERS);
printf( " -A, --dualanalog=PORT " _len += snprintf(buf + _len, sizeof(buf) - _len," -A, --dualanalog=PORT "
"Connect a DualAnalog controller to PORT (1 to %d).\n", MAX_USERS); "Connect a DualAnalog controller to PORT (1 to %d).\n", MAX_USERS);
printf( " -d, --device=PORT:ID " _len += snprintf(buf + _len, sizeof(buf) - _len," -d, --device=PORT:ID "
"Connect a generic device into PORT of the device (1 to %d).\n", MAX_USERS); "Connect a generic device into PORT of the device (1 to %d).\n", MAX_USERS);
strlcat(buf,
_len += strlcpy(buf + _len,
" " " "
" Format is PORT:ID, where ID is a number corresponding to the particular device.\n" " Format is PORT:ID, where ID is a number corresponding to the particular device.\n"
" -M, --sram-mode=MODE " " -M, --sram-mode=MODE "
@ -6330,10 +6335,10 @@ static void retroarch_print_help(const char *arg0)
" 'noload-nosave', 'noload-save', 'load-nosave' or 'load-save'.\n" " 'noload-nosave', 'noload-save', 'load-nosave' or 'load-save'.\n"
" " " "
" Note: 'noload-save' implies that save files *WILL BE OVERWRITTEN*.\n" " Note: 'noload-save' implies that save files *WILL BE OVERWRITTEN*.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#ifdef HAVE_NETWORKING #ifdef HAVE_NETWORKING
strlcat(buf, _len += strlcpy(buf + _len,
" -H, --host " " -H, --host "
"Host netplay as user 1.\n" "Host netplay as user 1.\n"
" -C, --connect=HOST " " -C, --connect=HOST "
@ -6346,87 +6351,86 @@ static void retroarch_print_help(const char *arg0)
"Picks a username (for use with netplay). Not mandatory.\n" "Picks a username (for use with netplay). Not mandatory.\n"
" --check-frames=NUMBER " " --check-frames=NUMBER "
"Check frames when using netplay.\n" "Check frames when using netplay.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#ifdef HAVE_NETWORK_CMD #ifdef HAVE_NETWORK_CMD
strlcat(buf, _len += strlcpy(buf + _len,
" --command " " --command "
"Sends a command over UDP to an already running program process.\n" "Sends a command over UDP to an already running program process.\n"
" " " "
" Available commands are listed if command is invalid.\n" " Available commands are listed if command is invalid.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#endif #endif
#endif #endif
#ifdef HAVE_BSV_MOVIE #ifdef HAVE_BSV_MOVIE
strlcat(buf, _len += strlcpy(buf + _len,
" -P, --play-replay=FILE " " -P, --play-replay=FILE "
"Playback a replay file.\n" "Playback a replay file.\n"
" -R, --record-replay=FILE " " -R, --record-replay=FILE "
"Start recording a replay file from the beginning.\n" "Start recording a replay file from the beginning.\n"
" --eof-exit " " --eof-exit "
"Exit upon reaching the end of the replay file.\n" "Exit upon reaching the end of the replay file.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#endif #endif
strlcat(buf, _len += strlcpy(buf + _len,
" -r, --record=FILE " " -r, --record=FILE "
"Path to record video file. Using mkv extension is recommended.\n" "Path to record video file. Using mkv extension is recommended.\n"
" --recordconfig " " --recordconfig "
"Path to settings used during recording.\n" "Path to settings used during recording.\n"
" --size=WIDTHxHEIGHT " " --size=WIDTHxHEIGHT "
"Overrides output video size when recording.\n" "Overrides output video size when recording.\n"
, sizeof(buf)); , sizeof(buf) - _len);
fputs(buf, stdout); fputs(buf, stdout);
buf[0] = '\0'; buf[0] = '\0';
_len = 0;
strlcat(buf, _len = strlcpy(buf + _len,
" -D, --detach " " -D, --detach "
"Detach program from the running console. Not relevant for all platforms.\n" "Detach program from the running console. Not relevant for all platforms.\n"
" --max-frames=NUMBER " " --max-frames=NUMBER "
"Runs for the specified number of frames, then exits.\n" "Runs for the specified number of frames, then exits.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#ifdef HAVE_PATCH #ifdef HAVE_PATCH
strlcat(buf, _len += strlcpy(buf + _len,
" -U, --ups=FILE " " -U, --ups=FILE "
"Specifies path for UPS patch that will be applied to content.\n" "Specifies path for UPS patch that will be applied to content.\n"
" --bps=FILE " " --bps=FILE "
"Specifies path for BPS patch that will be applied to content.\n" "Specifies path for BPS patch that will be applied to content.\n"
" --ips=FILE " " --ips=FILE "
"Specifies path for IPS patch that will be applied to content.\n" "Specifies path for IPS patch that will be applied to content.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#ifdef HAVE_XDELTA #ifdef HAVE_XDELTA
strlcat(buf, _len += strlcpy(buf + _len,
" --xdelta=FILE " " --xdelta=FILE "
"Specifies path for Xdelta patch that will be applied to content.\n" "Specifies path for Xdelta patch that will be applied to content.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#endif /* HAVE_XDELTA */ #endif /* HAVE_XDELTA */
strlcat(buf, _len += strlcpy(buf + _len,
" --no-patch " " --no-patch "
"Disables all forms of content patching.\n" "Disables all forms of content patching.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#endif /* HAVE_PATCH */ #endif /* HAVE_PATCH */
#ifdef HAVE_SCREENSHOTS #ifdef HAVE_SCREENSHOTS
strlcat(buf, _len += strlcpy(buf + _len,
" --max-frames-ss " " --max-frames-ss "
"Takes a screenshot at the end of max-frames.\n" "Takes a screenshot at the end of max-frames.\n"
" --max-frames-ss-path=FILE " " --max-frames-ss-path=FILE "
"Path to save the screenshot to at the end of max-frames.\n" "Path to save the screenshot to at the end of max-frames.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#endif #endif
#ifdef HAVE_ACCESSIBILITY #ifdef HAVE_ACCESSIBILITY
strlcat(buf, _len += strlcpy(buf + _len,
" --accessibility " " --accessibility "
"Enables accessibilty for blind users using text-to-speech.\n" "Enables accessibilty for blind users using text-to-speech.\n"
, sizeof(buf)); , sizeof(buf) - _len);
#endif #endif
strlcat(buf, _len += strlcpy(buf + _len,
" --load-menu-on-error " " --load-menu-on-error "
"Open menu instead of quitting if specified core or content fails to load.\n" "Open menu instead of quitting if specified core or content fails to load.\n"
" -e, --entryslot=NUMBER " " -e, --entryslot=NUMBER "
@ -6435,7 +6439,7 @@ static void retroarch_print_help(const char *arg0)
"Path for save files (*.srm). (DEPRECATED, use --appendconfig and savefile_directory)\n" "Path for save files (*.srm). (DEPRECATED, use --appendconfig and savefile_directory)\n"
" -S, --savestate=PATH " " -S, --savestate=PATH "
"Path for the save state files (*.state). (DEPRECATED, use --appendconfig and savestate_directory)\n" "Path for the save state files (*.state). (DEPRECATED, use --appendconfig and savestate_directory)\n"
, sizeof(buf)); , sizeof(buf) - _len);
fputs(buf, stdout); fputs(buf, stdout);
} }