Go back to plain strlcpy/strlcat - probably best to look at

opportunities to reduce these calls vs. replacing them with
unsafe macros
This commit is contained in:
twinaphex 2019-09-23 00:18:29 +02:00
parent 21a2ba3f79
commit b94b9e2adb
26 changed files with 191 additions and 321 deletions

View File

@ -58,7 +58,6 @@ static void core_info_list_resolve_all_extensions(
core_info_list_t *core_info_list) core_info_list_t *core_info_list)
{ {
size_t i = 0; size_t i = 0;
size_t buf_pos = 0;
size_t all_ext_len = 0; size_t all_ext_len = 0;
char *all_ext = NULL; char *all_ext = NULL;
@ -83,17 +82,15 @@ static void core_info_list_resolve_all_extensions(
if (!core_info_list->list[i].supported_extensions) if (!core_info_list->list[i].supported_extensions)
continue; continue;
buf_pos = strlcat(core_info_list->all_ext, 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_CONST(core_info_list->all_ext, buf_pos, "|", all_ext_len); strlcat(core_info_list->all_ext, "|", all_ext_len);
buf_pos++;
} }
#ifdef HAVE_7ZIP #ifdef HAVE_7ZIP
STRLCAT_CONST(core_info_list->all_ext, buf_pos,"7z|", all_ext_len); strlcat(core_info_list->all_ext, "7z|", all_ext_len);
buf_pos += 3;
#endif #endif
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
STRLCAT_CONST(core_info_list->all_ext, buf_pos, "zip|", all_ext_len); strlcat(core_info_list->all_ext, "zip|", all_ext_len);
#endif #endif
} }

View File

@ -35,74 +35,73 @@ int database_info_build_query_enum(char *s, size_t len,
enum database_query_type type, enum database_query_type type,
const char *path) const char *path)
{ {
size_t buf_pos = 2;
bool add_quotes = true; bool add_quotes = true;
bool add_glob = false; bool add_glob = false;
STRLCPY_CONST(s, "{'"); strlcpy(s, "{'", len);
switch (type) switch (type)
{ {
case DATABASE_QUERY_ENTRY: case DATABASE_QUERY_ENTRY:
STRLCAT_CONST_INCR(s, buf_pos, "name", len); strlcat(s, "name", len);
break; break;
case DATABASE_QUERY_ENTRY_PUBLISHER: case DATABASE_QUERY_ENTRY_PUBLISHER:
STRLCAT_CONST_INCR(s, buf_pos, "publisher", len); strlcat(s, "publisher", len);
break; break;
case DATABASE_QUERY_ENTRY_DEVELOPER: case DATABASE_QUERY_ENTRY_DEVELOPER:
STRLCAT_CONST_INCR(s, buf_pos, "developer", len); strlcat(s, "developer", len);
add_glob = true; add_glob = true;
add_quotes = false; add_quotes = false;
break; break;
case DATABASE_QUERY_ENTRY_ORIGIN: case DATABASE_QUERY_ENTRY_ORIGIN:
STRLCAT_CONST_INCR(s, buf_pos, "origin", len); strlcat(s, "origin", len);
break; break;
case DATABASE_QUERY_ENTRY_FRANCHISE: case DATABASE_QUERY_ENTRY_FRANCHISE:
STRLCAT_CONST_INCR(s, buf_pos, "franchise", len); strlcat(s, "franchise", len);
break; break;
case DATABASE_QUERY_ENTRY_RATING: case DATABASE_QUERY_ENTRY_RATING:
STRLCAT_CONST_INCR(s, buf_pos, "esrb_rating", len); strlcat(s, "esrb_rating", len);
break; break;
case DATABASE_QUERY_ENTRY_BBFC_RATING: case DATABASE_QUERY_ENTRY_BBFC_RATING:
STRLCAT_CONST_INCR(s, buf_pos, "bbfc_rating", len); strlcat(s, "bbfc_rating", len);
break; break;
case DATABASE_QUERY_ENTRY_ELSPA_RATING: case DATABASE_QUERY_ENTRY_ELSPA_RATING:
STRLCAT_CONST_INCR(s, buf_pos, "elspa_rating", len); strlcat(s, "elspa_rating", len);
break; break;
case DATABASE_QUERY_ENTRY_ESRB_RATING: case DATABASE_QUERY_ENTRY_ESRB_RATING:
STRLCAT_CONST_INCR(s, buf_pos, "esrb_rating", len); strlcat(s, "esrb_rating", len);
break; break;
case DATABASE_QUERY_ENTRY_PEGI_RATING: case DATABASE_QUERY_ENTRY_PEGI_RATING:
STRLCAT_CONST_INCR(s, buf_pos, "pegi_rating", len); strlcat(s, "pegi_rating", len);
break; break;
case DATABASE_QUERY_ENTRY_CERO_RATING: case DATABASE_QUERY_ENTRY_CERO_RATING:
STRLCAT_CONST_INCR(s, buf_pos, "cero_rating", len); strlcat(s, "cero_rating", len);
break; break;
case DATABASE_QUERY_ENTRY_ENHANCEMENT_HW: case DATABASE_QUERY_ENTRY_ENHANCEMENT_HW:
STRLCAT_CONST_INCR(s, buf_pos, "enhancement_hw", len); strlcat(s, "enhancement_hw", len);
break; break;
case DATABASE_QUERY_ENTRY_EDGE_MAGAZINE_RATING: case DATABASE_QUERY_ENTRY_EDGE_MAGAZINE_RATING:
STRLCAT_CONST_INCR(s, buf_pos, "edge_rating", len); strlcat(s, "edge_rating", len);
add_quotes = false; add_quotes = false;
break; break;
case DATABASE_QUERY_ENTRY_EDGE_MAGAZINE_ISSUE: case DATABASE_QUERY_ENTRY_EDGE_MAGAZINE_ISSUE:
STRLCAT_CONST_INCR(s, buf_pos, "edge_issue", len); strlcat(s, "edge_issue", len);
add_quotes = false; add_quotes = false;
break; break;
case DATABASE_QUERY_ENTRY_FAMITSU_MAGAZINE_RATING: case DATABASE_QUERY_ENTRY_FAMITSU_MAGAZINE_RATING:
STRLCAT_CONST_INCR(s, buf_pos, "famitsu_rating", len); strlcat(s, "famitsu_rating", len);
add_quotes = false; add_quotes = false;
break; break;
case DATABASE_QUERY_ENTRY_RELEASEDATE_MONTH: case DATABASE_QUERY_ENTRY_RELEASEDATE_MONTH:
STRLCAT_CONST_INCR(s, buf_pos, "releasemonth", len); strlcat(s, "releasemonth", len);
add_quotes = false; add_quotes = false;
break; break;
case DATABASE_QUERY_ENTRY_RELEASEDATE_YEAR: case DATABASE_QUERY_ENTRY_RELEASEDATE_YEAR:
STRLCAT_CONST_INCR(s, buf_pos, "releaseyear", len); strlcat(s, "releaseyear", len);
add_quotes = false; add_quotes = false;
break; break;
case DATABASE_QUERY_ENTRY_MAX_USERS: case DATABASE_QUERY_ENTRY_MAX_USERS:
STRLCAT_CONST_INCR(s, buf_pos, "users", len); strlcat(s, "users", len);
add_quotes = false; add_quotes = false;
break; break;
case DATABASE_QUERY_NONE: case DATABASE_QUERY_NONE:
@ -110,26 +109,18 @@ int database_info_build_query_enum(char *s, size_t len,
break; break;
} }
STRLCAT_CONST_INCR(s, buf_pos, "':", len); strlcat(s, "':", len);
if (add_glob) if (add_glob)
{ strlcat(s, "glob('*", len);
STRLCAT_CONST_INCR(s, buf_pos, "glob('*", len);
}
if (add_quotes) if (add_quotes)
{ strlcat(s, "\"", len);
STRLCAT_CONST_INCR(s, buf_pos, "\"", len); strlcat(s, path, len);
}
buf_pos = strlcat(s, path, len);
if (add_glob) if (add_glob)
{ strlcat(s, "*')", len);
STRLCAT_CONST_INCR(s, buf_pos, "*')", len);
}
if (add_quotes) if (add_quotes)
{ strlcat(s, "\"", len);
STRLCAT_CONST_INCR(s, buf_pos, "\"", len);
}
STRLCAT_CONST_INCR(s, buf_pos, "{'", len); strlcat(s, "{'", len);
#if 0 #if 0
RARCH_LOG("query: %s\n", s); RARCH_LOG("query: %s\n", s);

View File

@ -1694,17 +1694,13 @@ static void frontend_unix_get_env(int *argc,
if (xdg) if (xdg)
{ {
size_t buf_pos = strlcpy(base_path, xdg, sizeof(base_path)); strlcpy(base_path, xdg, sizeof(base_path));
STRLCAT_CONST_INCR(base_path, buf_pos, "/", sizeof(base_path)); strlcat(base_path, "/retroarch", sizeof(base_path));
STRLCAT_CONST_INCR(base_path, buf_pos, "retroarch", sizeof(base_path));
} }
else if (home) else if (home)
{ {
size_t buf_pos = strlcpy(base_path, home, sizeof(base_path)); strlcpy(base_path, home, sizeof(base_path));
STRLCAT_CONST_INCR(base_path, buf_pos, "/", sizeof(base_path)); strlcat(base_path, "/.config/retroarch", sizeof(base_path));
STRLCAT_CONST_INCR(base_path, buf_pos, ".config", sizeof(base_path));
STRLCAT_CONST_INCR(base_path, buf_pos, "/", sizeof(base_path));
STRLCAT_CONST_INCR(base_path, buf_pos, "retroarch", sizeof(base_path));
} }
else else
strlcpy(base_path, "retroarch", sizeof(base_path)); strlcpy(base_path, "retroarch", sizeof(base_path));

View File

@ -70,7 +70,7 @@ static std::string build_stage_source(
expected[0] = '\0'; expected[0] = '\0';
STRLCPY_CONST(expected, "#pragma stage "); strlcpy(expected, "#pragma stage ", sizeof(expected));
strlcat(expected, stage, sizeof(expected)); strlcat(expected, stage, sizeof(expected));
active = strcmp(expected, line) == 0; active = strcmp(expected, line) == 0;

View File

@ -571,21 +571,17 @@ static void gl_glsl_find_uniforms_frame(glsl_shader_data_t *glsl,
char texture_size[64]; char texture_size[64];
char input_size[64]; char input_size[64];
char tex_coord[64]; char tex_coord[64];
size_t buf_pos;
texture[0] = texture_size[0] = input_size[0] = tex_coord[0] = '\0'; texture[0] = texture_size[0] = input_size[0] = tex_coord[0] = '\0';
buf_pos = strlcpy(texture, base, sizeof(texture)); strlcpy(texture, base, sizeof(texture));
STRLCAT_CONST_INCR(texture, buf_pos, "Texture", sizeof(texture)); strlcat(texture, "Texture", sizeof(texture));
strlcpy(texture_size, base, sizeof(texture_size));
buf_pos = strlcpy(texture_size, base, sizeof(texture_size)); strlcat(texture_size, "TextureSize", sizeof(texture_size));
STRLCAT_CONST_INCR(texture_size, buf_pos, "TextureSize", sizeof(texture_size)); strlcpy(input_size, base, sizeof(input_size));
strlcat(input_size, "InputSize", sizeof(input_size));
buf_pos = strlcpy(input_size, base, sizeof(input_size)); strlcpy(tex_coord, base, sizeof(tex_coord));
STRLCAT_CONST_INCR(input_size, buf_pos, "InputSize", sizeof(input_size)); strlcat(tex_coord, "TexCoord", sizeof(tex_coord));
buf_pos = strlcpy(tex_coord, base, sizeof(tex_coord));
STRLCAT_CONST_INCR(tex_coord, buf_pos, "TexCoord", sizeof(tex_coord));
if (frame->texture < 0) if (frame->texture < 0)
frame->texture = gl_glsl_get_uniform(glsl, prog, texture); frame->texture = gl_glsl_get_uniform(glsl, prog, texture);

View File

@ -341,7 +341,6 @@ static bool video_shader_parse_textures(config_file_t *conf,
char id_mipmap[64]; char id_mipmap[64];
bool mipmap = false; bool mipmap = false;
bool smooth = false; bool smooth = false;
size_t buf_pos = 0;
id_filter[0] = id_wrap[0] = wrap_mode[0] = id_mipmap[0] = '\0'; id_filter[0] = id_wrap[0] = wrap_mode[0] = id_mipmap[0] = '\0';
@ -358,21 +357,21 @@ static bool video_shader_parse_textures(config_file_t *conf,
strlcpy(shader->lut[shader->luts].id, id, strlcpy(shader->lut[shader->luts].id, id,
sizeof(shader->lut[shader->luts].id)); sizeof(shader->lut[shader->luts].id));
buf_pos = strlcpy(id_filter, id, sizeof(id_filter)); strlcpy(id_filter, id, sizeof(id_filter));
STRLCAT_CONST_INCR(id_filter, buf_pos, "_linear", sizeof(id_filter)); strlcat(id_filter, "_linear", sizeof(id_filter));
if (config_get_bool(conf, id_filter, &smooth)) if (config_get_bool(conf, id_filter, &smooth))
shader->lut[shader->luts].filter = smooth ? shader->lut[shader->luts].filter = smooth ?
RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST; RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST;
else else
shader->lut[shader->luts].filter = RARCH_FILTER_UNSPEC; shader->lut[shader->luts].filter = RARCH_FILTER_UNSPEC;
buf_pos = strlcpy(id_wrap, id, sizeof(id_wrap)); strlcpy(id_wrap, id, sizeof(id_wrap));
STRLCAT_CONST_INCR(id_wrap, buf_pos, "_wrap_mode", sizeof(id_wrap)); strlcat(id_wrap, "_wrap_mode", sizeof(id_wrap));
if (config_get_array(conf, id_wrap, wrap_mode, sizeof(wrap_mode))) if (config_get_array(conf, id_wrap, wrap_mode, sizeof(wrap_mode)))
shader->lut[shader->luts].wrap = wrap_str_to_mode(wrap_mode); shader->lut[shader->luts].wrap = wrap_str_to_mode(wrap_mode);
buf_pos = strlcpy(id_mipmap, id, sizeof(id_mipmap)); strlcpy(id_mipmap, id, sizeof(id_mipmap));
STRLCAT_CONST_INCR(id_mipmap, buf_pos, "_mipmap", sizeof(id_mipmap)); strlcat(id_mipmap, "_mipmap", sizeof(id_mipmap));
if (config_get_bool(conf, id_mipmap, &mipmap)) if (config_get_bool(conf, id_mipmap, &mipmap))
shader->lut[shader->luts].mipmap = mipmap; shader->lut[shader->luts].mipmap = mipmap;
else else
@ -1106,31 +1105,28 @@ void video_shader_write_conf_preset(config_file_t *conf,
if (shader->lut[i].filter != RARCH_FILTER_UNSPEC) if (shader->lut[i].filter != RARCH_FILTER_UNSPEC)
{ {
size_t buf_pos;
char key[128]; char key[128];
key[0] = '\0'; key[0] = '\0';
buf_pos = strlcpy(key, shader->lut[i].id, sizeof(key)); strlcpy(key, shader->lut[i].id, sizeof(key));
STRLCAT_CONST_INCR(key, buf_pos, "_linear", sizeof(key)); strlcat(key, "_linear", sizeof(key));
config_set_bool(conf, key, config_set_bool(conf, key,
shader->lut[i].filter == RARCH_FILTER_LINEAR); shader->lut[i].filter == RARCH_FILTER_LINEAR);
} }
{ {
size_t buf_pos;
char key[128]; char key[128];
key[0] = '\0'; key[0] = '\0';
buf_pos = strlcpy(key, shader->lut[i].id, sizeof(key)); strlcpy(key, shader->lut[i].id, sizeof(key));
STRLCAT_CONST_INCR(key, buf_pos, "_wrap_mode", sizeof(key)); strlcat(key, "_wrap_mode", sizeof(key));
config_set_string(conf, key, config_set_string(conf, key,
wrap_mode_to_str(shader->lut[i].wrap)); wrap_mode_to_str(shader->lut[i].wrap));
} }
{ {
size_t buf_pos;
char key[128]; char key[128];
key[0] = '\0'; key[0] = '\0';
buf_pos = strlcpy(key, shader->lut[i].id, sizeof(key)); strlcpy(key, shader->lut[i].id, sizeof(key));
STRLCAT_CONST_INCR(key, buf_pos, "_mipmap", sizeof(key)); strlcat(key, "_mipmap", sizeof(key));
config_set_bool(conf, key, config_set_bool(conf, key,
shader->lut[i].mipmap); shader->lut[i].mipmap);
} }

View File

@ -914,7 +914,7 @@ size_t path_relative_to(char *out,
out[0] = '\0'; out[0] = '\0';
for (i = 0; trimmed_base[i]; i++) for (i = 0; trimmed_base[i]; i++)
if (trimmed_base[i] == path_default_slash_c()) if (trimmed_base[i] == path_default_slash_c())
STRLCAT_CONST_INCR(out, written, ".." path_default_slash(), size); strlcat(out, ".." path_default_slash(), size);
return strlcat(out, trimmed_path, size); return strlcat(out, trimmed_path, size);
} }
@ -1293,9 +1293,8 @@ void fill_pathname_application_path(char *s, size_t len)
char resolved_bundle_dir_buf[PATH_MAX_LENGTH] = {0}; char resolved_bundle_dir_buf[PATH_MAX_LENGTH] = {0};
if (realpath(s, resolved_bundle_dir_buf)) if (realpath(s, resolved_bundle_dir_buf))
{ {
size_t buf_pos = strlcpy(s, resolved_bundle_dir_buf, len - 1); strlcpy(s, resolved_bundle_dir_buf, len - 1);
s[buf_pos] = '/'; strlcat(s, "/", len);
s[buf_pos+1] = '\0';
} }
} }
#endif #endif

View File

@ -49,16 +49,6 @@ static INLINE bool string_is_equal(const char *a, const char *b)
#define string_is_not_equal(a, b) !string_is_equal((a), (b)) #define string_is_not_equal(a, b) !string_is_equal((a), (b))
#define STRLCPY_CONST(buf, str) \
do { size_t i; for (i = 0; i < sizeof(str); i++) (buf)[i] = (str)[i]; } while (0)
#define STRLCAT_CONST(buf, strlcpy_ret, str, buf_size) \
STRLCPY_CONST((buf) + MIN((strlcpy_ret), (buf_size)-1 - STRLEN_CONST((str))), (str))
#define STRLCAT_CONST_INCR(buf, strlcpy_ret, str, buf_size) \
do { STRLCAT_CONST(buf, strlcpy_ret, str, buf_size); \
(strlcpy_ret) += STRLEN_CONST((str)); } while(0)
#define string_is_not_equal_fast(a, b, size) (memcmp(a, b, size) != 0) #define string_is_not_equal_fast(a, b, size) (memcmp(a, b, size) != 0)
#define string_is_equal_fast(a, b, size) (memcmp(a, b, size) == 0) #define string_is_equal_fast(a, b, size) (memcmp(a, b, size) == 0)

View File

@ -4904,11 +4904,10 @@ void netplay_refresh_rooms_menu(file_list_t *list)
if (*netplay_room_list[i].country) if (*netplay_room_list[i].country)
{ {
size_t buf_pos = STRLEN_CONST("("); strlcpy(country, "(", sizeof(country));
STRLCPY_CONST(country, "("); strlcat(country, netplay_room_list[i].country,
buf_pos = strlcat(country, netplay_room_list[i].country,
sizeof(country)); sizeof(country));
STRLCAT_CONST_INCR(country, buf_pos, ")", sizeof(country)); strlcat(country, ")", sizeof(country));
} }
/* Uncomment this to debug mismatched room parameters*/ /* Uncomment this to debug mismatched room parameters*/

View File

@ -61,13 +61,11 @@
static int menu_action_sublabel_file_browser_core(file_list_t *list, unsigned type, unsigned i, const char *label, const char *path, char *s, size_t len) static int menu_action_sublabel_file_browser_core(file_list_t *list, unsigned type, unsigned i, const char *label, const char *path, char *s, size_t len)
{ {
size_t buf_pos = 0;
core_info_list_t *core_list = NULL; core_info_list_t *core_list = NULL;
core_info_get_list(&core_list); core_info_get_list(&core_list);
STRLCPY_CONST(s, "License: "); strlcpy(s, "License: ", len);
buf_pos = STRLEN_CONST("License: ");
if (core_list) if (core_list)
{ {
@ -84,14 +82,14 @@ static int menu_action_sublabel_file_browser_core(file_list_t *list, unsigned ty
string_list_join_concat(tmp, sizeof(tmp), string_list_join_concat(tmp, sizeof(tmp),
core_list->list[j].licenses_list, ", "); core_list->list[j].licenses_list, ", ");
buf_pos = strlcat(s, tmp, len); strlcat(s, tmp, len);
return 1; return 1;
} }
} }
} }
} }
STRLCAT_CONST(s, buf_pos, "N/A", len); strlcat(s, "N/A", len);
return 1; return 1;
} }
@ -998,7 +996,6 @@ static int action_bind_sublabel_playlist_entry(
const char *label, const char *path, const char *label, const char *path,
char *s, size_t len) char *s, size_t len)
{ {
size_t buf_pos;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
playlist_t *playlist = NULL; playlist_t *playlist = NULL;
const struct playlist_entry *entry = NULL; const struct playlist_entry *entry = NULL;
@ -1023,9 +1020,9 @@ static int action_bind_sublabel_playlist_entry(
return 0; return 0;
/* Add core name */ /* Add core name */
buf_pos = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE), len); strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE), len);
STRLCAT_CONST_INCR(s, buf_pos, " ", len); strlcat(s, " ", len);
buf_pos = strlcat(s, entry->core_name, len); strlcat(s, entry->core_name, len);
/* Get runtime info *if* required runtime log is enabled /* Get runtime info *if* required runtime log is enabled
* *and* this is a valid playlist type */ * *and* this is a valid playlist type */

View File

@ -293,19 +293,17 @@ static int action_get_title_generic(char *s, size_t len, const char *path,
if (list_path) if (list_path)
{ {
char elem0_path[255]; char elem0_path[255];
size_t buf_pos;
elem0_path[0] = '\0'; elem0_path[0] = '\0';
if (list_path->size > 0) if (list_path->size > 0)
strlcpy(elem0_path, list_path->elems[0].data, sizeof(elem0_path)); strlcpy(elem0_path, list_path->elems[0].data, sizeof(elem0_path));
string_list_free(list_path); string_list_free(list_path);
buf_pos = strlcpy(s, text, len); strlcpy(s, text, len);
s[buf_pos ] = '\n';
if (!string_is_empty(elem0_path)) if (!string_is_empty(elem0_path))
{ {
STRLCAT_CONST_INCR(s, buf_pos, "- ", len); strlcat(s, "- ", len);
strlcat(s, path_basename(elem0_path), len); strlcat(s, path_basename(elem0_path), len);
} }
} }
@ -342,8 +340,8 @@ default_title_generic_macro(action_get_title_list_rdb_entry_database_info,MENU_E
static int action_get_title_default(const char *path, const char *label, static int action_get_title_default(const char *path, const char *label,
unsigned menu_type, char *s, size_t len) unsigned menu_type, char *s, size_t len)
{ {
size_t buf_pos = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SELECT_FILE), len); strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SELECT_FILE), len);
STRLCAT_CONST_INCR(s, buf_pos, " ", len); strlcat(s, " ", len);
strlcat(s, path, len); strlcat(s, path, len);
return 0; return 0;
} }
@ -377,7 +375,6 @@ static int action_get_title_group_settings(const char *path, const char *label,
{ {
char elem0[255]; char elem0[255];
char elem1[255]; char elem1[255];
size_t buf_pos;
struct string_list *list_label = string_split(label, "|"); struct string_list *list_label = string_split(label, "|");
elem0[0] = elem1[0] = '\0'; elem0[0] = elem1[0] = '\0';
@ -393,11 +390,11 @@ static int action_get_title_group_settings(const char *path, const char *label,
string_list_free(list_label); string_list_free(list_label);
} }
buf_pos = strlcpy(s, elem0, len); strlcpy(s, elem0, len);
if (!string_is_empty(elem1)) if (!string_is_empty(elem1))
{ {
STRLCAT_CONST_INCR(s, buf_pos, " - ", len); strlcat(s, " - ", len);
strlcat(s, elem1, len); strlcat(s, elem1, len);
} }
} }

View File

@ -1156,7 +1156,6 @@ static void materialui_draw_bg(menu_display_ctx_draw_t *draw,
and the menu list */ and the menu list */
static void materialui_frame(void *data, video_frame_info_t *video_info) static void materialui_frame(void *data, video_frame_info_t *video_info)
{ {
size_t buf_pos;
/* This controls the main background color */ /* This controls the main background color */
menu_display_ctx_clearcolor_t clearcolor; menu_display_ctx_clearcolor_t clearcolor;
@ -1635,13 +1634,13 @@ static void materialui_frame(void *data, video_frame_info_t *video_info)
/* Title */ /* Title */
usable_width = width - (mui->margin * 2) - title_margin; usable_width = width - (mui->margin * 2) - title_margin;
buf_pos = strlcpy(menu_title, mui->menu_title, sizeof(menu_title)); strlcpy(menu_title, mui->menu_title, sizeof(menu_title));
if (materialui_get_core_title(title_msg, sizeof(title_msg)) == 0) if (materialui_get_core_title(title_msg, sizeof(title_msg)) == 0)
{ {
STRLCAT_CONST_INCR(menu_title, buf_pos, " (", sizeof(menu_title)); strlcat(menu_title, " (", sizeof(menu_title));
buf_pos = strlcat(menu_title, title_msg, sizeof(menu_title)); strlcat(menu_title, title_msg, sizeof(menu_title));
STRLCAT_CONST_INCR(menu_title, buf_pos, ")", sizeof(menu_title)); strlcat(menu_title, ")", sizeof(menu_title));
} }
if (use_smooth_ticker) if (use_smooth_ticker)

View File

@ -574,17 +574,16 @@ static void ozone_context_reset(void *data, bool is_threaded)
/* Textures init */ /* Textures init */
for (i = 0; i < OZONE_TEXTURE_LAST; i++) for (i = 0; i < OZONE_TEXTURE_LAST; i++)
{ {
size_t buf_pos;
char filename[PATH_MAX_LENGTH]; char filename[PATH_MAX_LENGTH];
filename[0] = '\0'; filename[0] = '\0';
#if 0 #if 0
if (i == OZONE_TEXTURE_DISCORD_OWN_AVATAR && discord_avatar_is_ready()) if (i == OZONE_TEXTURE_DISCORD_OWN_AVATAR && discord_avatar_is_ready())
buf_pos = strlcpy(filename, discord_get_own_avatar(), sizeof(filename)); strlcpy(filename, discord_get_own_avatar(), sizeof(filename));
else else
#endif #endif
buf_pos = strlcpy(filename, OZONE_TEXTURES_FILES[i], sizeof(filename)); strlcpy(filename, OZONE_TEXTURES_FILES[i], sizeof(filename));
STRLCAT_CONST_INCR(filename, buf_pos, ".png", sizeof(filename)); strlcat(filename, ".png", sizeof(filename));
#if 0 #if 0
if (i == OZONE_TEXTURE_DISCORD_OWN_AVATAR && discord_avatar_is_ready()) if (i == OZONE_TEXTURE_DISCORD_OWN_AVATAR && discord_avatar_is_ready())
@ -612,13 +611,12 @@ static void ozone_context_reset(void *data, bool is_threaded)
/* Sidebar textures */ /* Sidebar textures */
for (i = 0; i < OZONE_TAB_TEXTURE_LAST; i++) for (i = 0; i < OZONE_TAB_TEXTURE_LAST; i++)
{ {
size_t buf_pos;
char filename[PATH_MAX_LENGTH]; char filename[PATH_MAX_LENGTH];
filename[0] = '\0'; filename[0] = '\0';
buf_pos = strlcpy(filename, strlcpy(filename,
OZONE_TAB_TEXTURES_FILES[i], sizeof(filename)); OZONE_TAB_TEXTURES_FILES[i], sizeof(filename));
STRLCAT_CONST_INCR(filename, buf_pos, ".png", sizeof(filename)); strlcat(filename, ".png", sizeof(filename));
if (!menu_display_reset_textures_list(filename, ozone->tab_path, &ozone->tab_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL)) if (!menu_display_reset_textures_list(filename, ozone->tab_path, &ozone->tab_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL))
{ {

View File

@ -972,7 +972,6 @@ static void xmb_update_savestate_thumbnail_path(void *data, unsigned i)
|| (string_is_equal(entry.label, "loadstate")) || (string_is_equal(entry.label, "loadstate"))
|| (string_is_equal(entry.label, "savestate")))) || (string_is_equal(entry.label, "savestate"))))
{ {
size_t buf_pos = 0;
size_t path_size = 8204 * sizeof(char); size_t path_size = 8204 * sizeof(char);
char *path = (char*)malloc(path_size); char *path = (char*)malloc(path_size);
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
@ -984,16 +983,16 @@ static void xmb_update_savestate_thumbnail_path(void *data, unsigned i)
int state_slot = settings->ints.state_slot; int state_slot = settings->ints.state_slot;
if (state_slot > 0) if (state_slot > 0)
buf_pos = snprintf(path, path_size, "%s%d", snprintf(path, path_size, "%s%d",
global->name.savestate, state_slot); global->name.savestate, state_slot);
else if (state_slot < 0) else if (state_slot < 0)
buf_pos = fill_pathname_join_delim(path, fill_pathname_join_delim(path,
global->name.savestate, "auto", '.', path_size); global->name.savestate, "auto", '.', path_size);
else else
buf_pos = strlcpy(path, global->name.savestate, path_size); strlcpy(path, global->name.savestate, path_size);
} }
STRLCAT_CONST_INCR(path, buf_pos, ".png", path_size); strlcat(path, ".png", path_size);
if (path_is_valid(path)) if (path_is_valid(path))
{ {

View File

@ -1402,9 +1402,9 @@ bool menu_animation_ticker(menu_animation_ctx_ticker_t *ticker)
if (!ticker->selected) if (!ticker->selected)
{ {
size_t buf_pos = utf8cpy(ticker->s, utf8cpy(ticker->s,
PATH_MAX_LENGTH, ticker->str, ticker->len - 3); PATH_MAX_LENGTH, ticker->str, ticker->len - 3);
STRLCAT_CONST_INCR(ticker->s, buf_pos, "...", ticker->len); strlcat(ticker->s, "...", ticker->len);
return false; return false;
} }
@ -1500,7 +1500,6 @@ bool menu_animation_ticker_smooth_fw(menu_animation_ctx_ticker_smooth_t *ticker)
* and add '...' suffix */ * and add '...' suffix */
if (!ticker->selected) if (!ticker->selected)
{ {
size_t buf_pos;
unsigned num_chars = 0; unsigned num_chars = 0;
unsigned suffix_len = 3; unsigned suffix_len = 3;
unsigned suffix_width = suffix_len * glyph_width; unsigned suffix_width = suffix_len * glyph_width;
@ -1513,8 +1512,8 @@ bool menu_animation_ticker_smooth_fw(menu_animation_ctx_ticker_smooth_t *ticker)
num_chars = (ticker->field_width - suffix_width) / glyph_width; num_chars = (ticker->field_width - suffix_width) / glyph_width;
/* Copy string segment + add suffix */ /* Copy string segment + add suffix */
buf_pos = utf8cpy(ticker->dst_str, ticker->dst_str_len, ticker->src_str, num_chars); utf8cpy(ticker->dst_str, ticker->dst_str_len, ticker->src_str, num_chars);
STRLCAT_CONST_INCR(ticker->dst_str, buf_pos, "...", ticker->dst_str_len); strlcat(ticker->dst_str, "...", ticker->dst_str_len);
if (ticker->dst_str_width) if (ticker->dst_str_width)
*ticker->dst_str_width = (num_chars * glyph_width) + suffix_width; *ticker->dst_str_width = (num_chars * glyph_width) + suffix_width;
@ -1682,7 +1681,6 @@ bool menu_animation_ticker_smooth(menu_animation_ctx_ticker_smooth_t *ticker)
* and add '...' suffix */ * and add '...' suffix */
if (!ticker->selected) if (!ticker->selected)
{ {
size_t buf_pos;
unsigned text_width; unsigned text_width;
unsigned current_width = 0; unsigned current_width = 0;
unsigned num_chars = 0; unsigned num_chars = 0;
@ -1714,8 +1712,8 @@ bool menu_animation_ticker_smooth(menu_animation_ctx_ticker_smooth_t *ticker)
} }
/* Copy string segment + add suffix */ /* Copy string segment + add suffix */
buf_pos = utf8cpy(ticker->dst_str, ticker->dst_str_len, ticker->src_str, num_chars); utf8cpy(ticker->dst_str, ticker->dst_str_len, ticker->src_str, num_chars);
STRLCAT_CONST_INCR(ticker->dst_str, buf_pos, "...", ticker->dst_str_len); strlcat(ticker->dst_str, "...", ticker->dst_str_len);
if (ticker->dst_str_width) if (ticker->dst_str_width)
*ticker->dst_str_width = current_width + (3 * period_width); *ticker->dst_str_width = current_width + (3 * period_width);

View File

@ -603,7 +603,6 @@ static unsigned menu_displaylist_parse_system_info(menu_displaylist_info_t *info
if (frontend->get_powerstate) if (frontend->get_powerstate)
{ {
size_t buf_pos = 0;
int seconds = 0, percent = 0; int seconds = 0, percent = 0;
enum frontend_powerstate state = enum frontend_powerstate state =
frontend->get_powerstate(&seconds, &percent); frontend->get_powerstate(&seconds, &percent);
@ -611,47 +610,47 @@ static unsigned menu_displaylist_parse_system_info(menu_displaylist_info_t *info
tmp2[0] = '\0'; tmp2[0] = '\0';
if (percent != 0) if (percent != 0)
buf_pos = snprintf(tmp2, sizeof(tmp2), "%d%%", percent); snprintf(tmp2, sizeof(tmp2), "%d%%", percent);
switch (state) switch (state)
{ {
case FRONTEND_POWERSTATE_NONE: case FRONTEND_POWERSTATE_NONE:
STRLCAT_CONST_INCR(tmp2, buf_pos, " ", sizeof(tmp2)); strlcat(tmp2, " ", sizeof(tmp2));
buf_pos = strlcat(tmp2, strlcat(tmp2,
msg_hash_to_str( msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), sizeof(tmp2)); MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), sizeof(tmp2));
break; break;
case FRONTEND_POWERSTATE_NO_SOURCE: case FRONTEND_POWERSTATE_NO_SOURCE:
STRLCAT_CONST_INCR(tmp2, buf_pos, " (", sizeof(tmp2)); strlcat(tmp2, " (", sizeof(tmp2));
buf_pos = strlcat(tmp2, strlcat(tmp2,
msg_hash_to_str( msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_NO_SOURCE), MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_NO_SOURCE),
sizeof(tmp2)); sizeof(tmp2));
STRLCAT_CONST_INCR(tmp2, buf_pos, ")", sizeof(tmp2)); strlcat(tmp2, ")", sizeof(tmp2));
break; break;
case FRONTEND_POWERSTATE_CHARGING: case FRONTEND_POWERSTATE_CHARGING:
STRLCAT_CONST_INCR(tmp2, buf_pos, " (", sizeof(tmp2)); strlcat(tmp2, " (", sizeof(tmp2));
buf_pos = strlcat(tmp2, strlcat(tmp2,
msg_hash_to_str( msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_CHARGING), MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_CHARGING),
sizeof(tmp2)); sizeof(tmp2));
STRLCAT_CONST_INCR(tmp2, buf_pos, ")", sizeof(tmp2)); strlcat(tmp2, ")", sizeof(tmp2));
break; break;
case FRONTEND_POWERSTATE_CHARGED: case FRONTEND_POWERSTATE_CHARGED:
STRLCAT_CONST_INCR(tmp2, buf_pos, " (", sizeof(tmp2)); strlcat(tmp2, " (", sizeof(tmp2));
buf_pos = strlcat(tmp2, strlcat(tmp2,
msg_hash_to_str( msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_CHARGED), MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_CHARGED),
sizeof(tmp2)); sizeof(tmp2));
STRLCAT_CONST_INCR(tmp2, buf_pos, ")", sizeof(tmp2)); strlcat(tmp2, ")", sizeof(tmp2));
break; break;
case FRONTEND_POWERSTATE_ON_POWER_SOURCE: case FRONTEND_POWERSTATE_ON_POWER_SOURCE:
STRLCAT_CONST_INCR(tmp2, buf_pos, " (", sizeof(tmp2)); strlcat(tmp2, " (", sizeof(tmp2));
buf_pos = strlcat(tmp2, strlcat(tmp2,
msg_hash_to_str( msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_DISCHARGING), MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_POWER_SOURCE_DISCHARGING),
sizeof(tmp2)); sizeof(tmp2));
STRLCAT_CONST_INCR(tmp2, buf_pos, ")", sizeof(tmp2)); strlcat(tmp2, ")", sizeof(tmp2));
break; break;
} }
@ -2983,9 +2982,8 @@ static unsigned menu_displaylist_parse_content_information(
tmp[0] = '\0'; tmp[0] = '\0';
n = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_LABEL), sizeof(tmp)); n = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_LABEL), sizeof(tmp));
STRLCAT_CONST_INCR(tmp, n, ": ", sizeof(tmp)); strlcat(tmp, ": ", sizeof(tmp));
n = strlcat(tmp, content_label, sizeof(tmp)); n = strlcat(tmp, content_label, sizeof(tmp));
tmp[n ] = '\0';
/* Silence gcc compiler warning /* Silence gcc compiler warning
* (getting so sick of these...) */ * (getting so sick of these...) */
@ -3005,9 +3003,8 @@ static unsigned menu_displaylist_parse_content_information(
tmp[0] = '\0'; tmp[0] = '\0';
n = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_PATH), sizeof(tmp)); n = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_PATH), sizeof(tmp));
STRLCAT_CONST_INCR(tmp, n, ": ", sizeof(tmp)); n = strlcat(tmp, ": ", sizeof(tmp));
n = strlcat(tmp, content_path, sizeof(tmp)); n = strlcat(tmp, content_path, sizeof(tmp));
tmp[n ] = '\0';
/* Silence gcc compiler warning /* Silence gcc compiler warning
* (getting so sick of these...) */ * (getting so sick of these...) */
@ -3028,9 +3025,8 @@ static unsigned menu_displaylist_parse_content_information(
tmp[0] = '\0'; tmp[0] = '\0';
n = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_CORE_NAME), sizeof(tmp)); n = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_CORE_NAME), sizeof(tmp));
STRLCAT_CONST_INCR(tmp, n, ": ", sizeof(tmp)); n = strlcat(tmp, ": ", sizeof(tmp));
n = strlcat(tmp, core_name, sizeof(tmp)); n = strlcat(tmp, core_name, sizeof(tmp));
tmp[n ] = '\0';
/* Silence gcc compiler warning /* Silence gcc compiler warning
* (getting so sick of these...) */ * (getting so sick of these...) */
@ -3063,9 +3059,8 @@ static unsigned menu_displaylist_parse_content_information(
tmp[0] = '\0'; tmp[0] = '\0';
n = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_DATABASE), sizeof(tmp)); n = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_DATABASE), sizeof(tmp));
STRLCAT_CONST_INCR(tmp, n, ": ", sizeof(tmp)); n = strlcat(tmp, ": ", sizeof(tmp));
n = strlcat(tmp, db_name_no_ext, sizeof(tmp)); n = strlcat(tmp, db_name_no_ext, sizeof(tmp));
tmp[n ] = '\0';
/* Silence gcc compiler warning /* Silence gcc compiler warning
* (getting so sick of these...) */ * (getting so sick of these...) */

View File

@ -1177,20 +1177,16 @@ int menu_entries_get_core_title(char *s, size_t len)
#else #else
const char *extra_version = ""; const char *extra_version = "";
#endif #endif
size_t buf_pos = 0; strlcpy(s, PACKAGE_VERSION, len);
STRLCPY_CONST(s, PACKAGE_VERSION);
buf_pos += STRLEN_CONST(PACKAGE_VERSION);
if (!string_is_empty(extra_version)) if (!string_is_empty(extra_version))
{ strlcat(s, extra_version, len);
STRLCAT_CONST_INCR(s, buf_pos, extra_version, len); strlcat(s, " - ", len);
} strlcat(s, core_name, len);
STRLCAT_CONST_INCR(s, buf_pos, " - ", len);
buf_pos = strlcat(s, core_name, len);
if (!string_is_empty(core_version)) if (!string_is_empty(core_version))
{ {
STRLCAT_CONST_INCR(s, buf_pos, " (", len); strlcat(s, " (", len);
buf_pos = strlcat(s, core_version, len); strlcat(s, core_version, len);
STRLCAT_CONST_INCR(s, buf_pos, ")", len); strlcat(s, ")", len);
} }
return 0; return 0;
@ -3918,13 +3914,10 @@ void menu_subsystem_populate(const struct retro_subsystem_info* subsystem, menu_
for (j = 0; j < content_get_subsystem_rom_id(); j++) for (j = 0; j < content_get_subsystem_rom_id(); j++)
{ {
size_t buf_pos = strlcat(rom_buff, strlcat(rom_buff,
path_basename(content_get_subsystem_rom(j)), sizeof(rom_buff)); path_basename(content_get_subsystem_rom(j)), sizeof(rom_buff));
if (j != content_get_subsystem_rom_id() - 1) if (j != content_get_subsystem_rom_id() - 1)
{ strlcat(rom_buff, "|", sizeof(rom_buff));
STRLCAT_CONST_INCR(rom_buff, buf_pos,
"|", sizeof(rom_buff));
}
} }
if (!string_is_empty(rom_buff)) if (!string_is_empty(rom_buff))

View File

@ -1054,7 +1054,7 @@ int setting_generic_action_start_default(rarch_setting_t *setting)
static void setting_get_string_representation_default(rarch_setting_t *setting, static void setting_get_string_representation_default(rarch_setting_t *setting,
char *s, size_t len) char *s, size_t len)
{ {
STRLCPY_CONST(s, "..."); strlcpy(s, "...", len);
} }
/** /**

View File

@ -253,7 +253,7 @@ bool menu_thumbnail_set_system(menu_thumbnail_path_data_t *path_data, const char
* so filter any input starting with 'MAME...' */ * so filter any input starting with 'MAME...' */
if (strncmp(system, "MAME", 4) == 0) if (strncmp(system, "MAME", 4) == 0)
{ {
STRLCPY_CONST(path_data->system, "MAME"); strlcpy(path_data->system, "MAME", sizeof(path_data->system));
} }
else else
strlcpy(path_data->system, system, sizeof(path_data->system)); strlcpy(path_data->system, system, sizeof(path_data->system));
@ -414,15 +414,15 @@ bool menu_thumbnail_set_content_image(
img_dir, img_name, sizeof(path_data->content_path)); img_dir, img_name, sizeof(path_data->content_path));
/* Set core name to "imageviewer" */ /* Set core name to "imageviewer" */
STRLCPY_CONST( strlcpy(
path_data->content_core_name, path_data->content_core_name,
"imageviewer"); "imageviewer", sizeof(path_data->content_core_name));
/* Set database name (arbitrarily) to "_images_" /* Set database name (arbitrarily) to "_images_"
* (required for compatibility with menu_thumbnail_update_path(), * (required for compatibility with menu_thumbnail_update_path(),
* but not actually used...) */ * but not actually used...) */
STRLCPY_CONST(path_data->content_db_name, strlcpy(path_data->content_db_name,
"_images_"); "_images_", sizeof(path_data->content_db_name));
/* Redundant error check */ /* Redundant error check */
if (string_is_empty(path_data->content_path)) if (string_is_empty(path_data->content_path))
@ -516,9 +516,7 @@ bool menu_thumbnail_set_content_playlist(menu_thumbnail_path_data_t *path_data,
/* Hack: There is only one MAME thumbnail repo, /* Hack: There is only one MAME thumbnail repo,
* so filter any input starting with 'MAME...' */ * so filter any input starting with 'MAME...' */
if (strncmp(db_name, "MAME", 4) == 0) if (strncmp(db_name, "MAME", 4) == 0)
{ strlcpy(path_data->content_db_name, "MAME", sizeof(path_data->content_db_name));
STRLCPY_CONST(path_data->content_db_name, "MAME");
}
else else
{ {
char *db_name_no_ext = NULL; char *db_name_no_ext = NULL;

View File

@ -2240,7 +2240,6 @@ static void menu_widgets_start_achievement_notification()
static void menu_widgets_get_badge_texture(menu_texture_item *tex, const char *badge) static void menu_widgets_get_badge_texture(menu_texture_item *tex, const char *badge)
{ {
char badge_file[16]; char badge_file[16];
size_t buf_pos;
char fullpath[PATH_MAX_LENGTH]; char fullpath[PATH_MAX_LENGTH];
if (!badge) if (!badge)
@ -2249,8 +2248,8 @@ static void menu_widgets_get_badge_texture(menu_texture_item *tex, const char *b
return; return;
} }
buf_pos = strlcpy(badge_file, badge, sizeof(badge_file)); strlcpy(badge_file, badge, sizeof(badge_file));
STRLCAT_CONST_INCR(badge_file, buf_pos, ".png", sizeof(badge_file)); strlcat(badge_file, ".png", sizeof(badge_file));
fill_pathname_application_special(fullpath, fill_pathname_application_special(fullpath,
PATH_MAX_LENGTH * sizeof(char), PATH_MAX_LENGTH * sizeof(char),
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES); APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES);

View File

@ -4228,7 +4228,7 @@ static bool command_event_save_config(
msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO), msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO),
config_path); config_path);
STRLCPY_CONST(log, "[config]"); strlcpy(log, "[config]", sizeof(log));
strlcat(log, s, sizeof(log)); strlcat(log, s, sizeof(log));
RARCH_LOG("%s\n", log); RARCH_LOG("%s\n", log);
return true; return true;
@ -4240,7 +4240,7 @@ static bool command_event_save_config(
msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO), msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO),
str); str);
STRLCPY_CONST(log, "[config]"); strlcpy(log, "[config]", sizeof(log));
strlcat(log, s, sizeof(log)); strlcat(log, s, sizeof(log));
RARCH_ERR("%s\n", log); RARCH_ERR("%s\n", log);
} }
@ -4303,7 +4303,6 @@ static bool command_event_save_core_config(void)
/* In case of collision, find an alternative name. */ /* In case of collision, find an alternative name. */
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
size_t buf_pos = 0;
char tmp[64] = {0}; char tmp[64] = {0};
fill_pathname_base_noext( fill_pathname_base_noext(
@ -4315,9 +4314,9 @@ static bool command_event_save_core_config(void)
config_size); config_size);
if (i) if (i)
buf_pos = snprintf(tmp, sizeof(tmp), "-%u", i); snprintf(tmp, sizeof(tmp), "-%u", i);
STRLCAT_CONST_INCR(tmp, buf_pos, ".cfg", sizeof(tmp)); strlcat(tmp, ".cfg", sizeof(tmp));
strlcat(config_path, tmp, config_size); strlcat(config_path, tmp, config_size);
if (!path_is_valid(config_path)) if (!path_is_valid(config_path))
@ -10492,7 +10491,6 @@ static void bsv_movie_deinit(void)
static bool runloop_check_movie_init(void) static bool runloop_check_movie_init(void)
{ {
char msg[16384], path[8192]; char msg[16384], path[8192];
size_t buf_pos = 0;
settings_t *settings = configuration_settings; settings_t *settings = configuration_settings;
msg[0] = path[0] = '\0'; msg[0] = path[0] = '\0';
@ -10500,13 +10498,13 @@ static bool runloop_check_movie_init(void)
configuration_set_uint(settings, settings->uints.rewind_granularity, 1); configuration_set_uint(settings, settings->uints.rewind_granularity, 1);
if (settings->ints.state_slot > 0) if (settings->ints.state_slot > 0)
buf_pos = snprintf(path, sizeof(path), "%s%d", snprintf(path, sizeof(path), "%s%d",
bsv_movie_state.movie_path, bsv_movie_state.movie_path,
settings->ints.state_slot); settings->ints.state_slot);
else else
buf_pos = strlcpy(path, bsv_movie_state.movie_path, sizeof(path)); strlcpy(path, bsv_movie_state.movie_path, sizeof(path));
STRLCAT_CONST_INCR(path, buf_pos, ".bsv", sizeof(path)); strlcat(path, ".bsv", sizeof(path));
snprintf(msg, sizeof(msg), "%s \"%s\".", snprintf(msg, sizeof(msg), "%s \"%s\".",
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
@ -19220,9 +19218,7 @@ static void video_driver_frame(const void *data, unsigned width,
{ {
char frames_text[64]; char frames_text[64];
if (video_info.fps_text[buf_pos-1] != '\0') if (video_info.fps_text[buf_pos-1] != '\0')
{ strlcat(video_info.fps_text, " || ", sizeof(video_info.fps_text));
STRLCAT_CONST_INCR(video_info.fps_text, buf_pos, " || ", sizeof(video_info.fps_text));
}
snprintf(frames_text, snprintf(frames_text,
sizeof(frames_text), sizeof(frames_text),
"%s: %" PRIu64, msg_hash_to_str(MSG_FRAMES), "%s: %" PRIu64, msg_hash_to_str(MSG_FRAMES),
@ -19241,9 +19237,7 @@ static void video_driver_frame(const void *data, unsigned width,
mem, sizeof(mem), "MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f), mem, sizeof(mem), "MEM: %.2f/%.2fMB", mem_bytes_used / (1024.0f * 1024.0f),
mem_bytes_total / (1024.0f * 1024.0f)); mem_bytes_total / (1024.0f * 1024.0f));
if (video_info.fps_text[buf_pos-1] != '\0') if (video_info.fps_text[buf_pos-1] != '\0')
{ strlcat(video_info.fps_text, " || ", sizeof(video_info.fps_text));
STRLCAT_CONST_INCR(video_info.fps_text, buf_pos, " || ", sizeof(video_info.fps_text));
}
strlcat(video_info.fps_text, mem, sizeof(video_info.fps_text)); strlcat(video_info.fps_text, mem, sizeof(video_info.fps_text));
} }
@ -19257,7 +19251,7 @@ static void video_driver_frame(const void *data, unsigned width,
if (!string_is_empty(video_info.fps_text)) if (!string_is_empty(video_info.fps_text))
{ {
STRLCAT_CONST_INCR(video_driver_window_title, buf_pos, strlcat(video_driver_window_title,
" || ", sizeof(video_driver_window_title)); " || ", sizeof(video_driver_window_title));
strlcat(video_driver_window_title, strlcat(video_driver_window_title,
video_info.fps_text, sizeof(video_driver_window_title)); video_info.fps_text, sizeof(video_driver_window_title));
@ -21754,22 +21748,20 @@ static retro_time_t rarch_core_runtime_tick(void)
} }
#define _PSUPP_BUF(buf, var, name, desc) \ #define _PSUPP_BUF(buf, var, name, desc) \
STRLCAT_CONST_INCR(buf, buf_pos, " ", sizeof(buf)); \ strlcat(buf, " ", sizeof(buf)); \
STRLCAT_CONST_INCR(buf, buf_pos, name, sizeof(buf)); \ strlcat(buf, name, sizeof(buf)); \
STRLCAT_CONST_INCR(buf, buf_pos, ":\n\t\t", sizeof(buf)); \ strlcat(buf, ":\n\t\t", sizeof(buf)); \
STRLCAT_CONST_INCR(buf, buf_pos, desc, sizeof(buf)); \ strlcat(buf, desc, sizeof(buf)); \
STRLCAT_CONST_INCR(buf, buf_pos, ": ", sizeof(buf)); \ strlcat(buf, ": ", sizeof(buf)); \
buf_pos = strlcat(buf, var ? "yes\n" : "no\n", sizeof(buf)); \ strlcat(buf, var ? "yes\n" : "no\n", sizeof(buf))
buf[buf_pos ] = '\0'
static void retroarch_print_features(void) static void retroarch_print_features(void)
{ {
char buf[2048]; char buf[2048];
size_t buf_pos = 0;
buf[0] = '\0'; buf[0] = '\0';
frontend_driver_attach_console(); frontend_driver_attach_console();
STRLCAT_CONST_INCR(buf, buf_pos, "\nFeatures:\n", sizeof(buf)); strlcat(buf, "\nFeatures:\n", sizeof(buf));
_PSUPP_BUF(buf, SUPPORTS_LIBRETRODB, "LibretroDB", "LibretroDB support"); _PSUPP_BUF(buf, SUPPORTS_LIBRETRODB, "LibretroDB", "LibretroDB support");
_PSUPP_BUF(buf, SUPPORTS_COMMAND, "Command", "Command interface support"); _PSUPP_BUF(buf, SUPPORTS_COMMAND, "Command", "Command interface support");
@ -22084,9 +22076,9 @@ static void retroarch_parse_input_and_config(int argc, char *argv[])
/* Copy the args into a buffer so launch arguments can be reused */ /* Copy the args into a buffer so launch arguments can be reused */
for (i = 0; i < (unsigned)argc; i++) for (i = 0; i < (unsigned)argc; i++)
{ {
size_t buf_pos = strlcat(launch_arguments, strlcat(launch_arguments,
argv[i], sizeof(launch_arguments)); argv[i], sizeof(launch_arguments));
STRLCAT_CONST(launch_arguments, buf_pos, " ", strlcat(launch_arguments, " ",
sizeof(launch_arguments)); sizeof(launch_arguments));
} }
string_trim_whitespace_left(launch_arguments); string_trim_whitespace_left(launch_arguments);
@ -22813,38 +22805,24 @@ bool retroarch_main_init(int argc, char *argv[])
RARCH_LOG_OUTPUT(str_output); RARCH_LOG_OUTPUT(str_output);
} }
{ {
size_t buf_pos;
char str_output[256]; char str_output[256];
char str[128]; char str[128];
str[0] = str_output[0] = '\0'; str[0] = str_output[0] = '\0';
retroarch_get_capabilities(RARCH_CAPABILITIES_CPU, str, sizeof(str)); retroarch_get_capabilities(RARCH_CAPABILITIES_CPU, str, sizeof(str));
buf_pos = strlcat(str_output, msg_hash_to_str(MSG_CAPABILITIES), strlcat(str_output, msg_hash_to_str(MSG_CAPABILITIES),
sizeof(str_output)); sizeof(str_output));
STRLCAT_CONST_INCR(str_output, buf_pos, ": ", sizeof(str_output)); strlcat(str_output, ": ", sizeof(str_output));
buf_pos = strlcat(str_output, str, sizeof(str_output)); strlcat(str_output, str, sizeof(str_output));
STRLCAT_CONST_INCR(str_output, buf_pos, "\n", sizeof(str_output)); strlcat(str_output, "\n"FILE_PATH_LOG_INFO " Built: " __DATE__ "\n" FILE_PATH_LOG_INFO " Version: " PACKAGE_VERSION "\n", sizeof(str_output));
STRLCAT_CONST_INCR(str_output, buf_pos, FILE_PATH_LOG_INFO, sizeof(str_output));
STRLCAT_CONST_INCR(str_output, buf_pos, " Built: ", sizeof(str_output));
buf_pos = strlcat(str_output, __DATE__, sizeof(str_output));
STRLCAT_CONST_INCR(str_output, buf_pos, "\n", sizeof(str_output));
STRLCAT_CONST_INCR(str_output, buf_pos, FILE_PATH_LOG_INFO, sizeof(str_output));
STRLCAT_CONST_INCR(str_output, buf_pos, " Version: ", sizeof(str_output));
STRLCAT_CONST_INCR(str_output, buf_pos, PACKAGE_VERSION, sizeof(str_output));
STRLCAT_CONST_INCR(str_output, buf_pos, "\n", sizeof(str_output));
#ifdef HAVE_GIT_VERSION #ifdef HAVE_GIT_VERSION
STRLCAT_CONST_INCR(str_output, buf_pos, FILE_PATH_LOG_INFO, sizeof(str_output)); strlcat(str_output, FILE_PATH_LOG_INFO " Git: ", sizeof(str_output));
STRLCAT_CONST_INCR(str_output, buf_pos, " Git: ", sizeof(str_output)); strlcat(str_output, retroarch_git_version, sizeof(str_output));
buf_pos = strlcat(str_output, retroarch_git_version,sizeof(str_output)); strlcat(str_output, "\n", sizeof(str_output));
STRLCAT_CONST_INCR(str_output, buf_pos, "\n", sizeof(str_output));
#endif #endif
STRLCAT_CONST_INCR(str_output, buf_pos, FILE_PATH_LOG_INFO, sizeof(str_output)); strlcat(str_output, FILE_PATH_LOG_INFO " =================================================\n", sizeof(str_output));
STRLCAT_CONST_INCR(str_output, buf_pos, " ", sizeof(str_output));
STRLCAT_CONST_INCR(str_output, buf_pos, "=================================================\n", sizeof(str_output));
RARCH_LOG_OUTPUT(str_output); RARCH_LOG_OUTPUT(str_output);
} }
} }
@ -23974,86 +23952,46 @@ int retroarch_get_capabilities(enum rarch_capabilities type,
{ {
case RARCH_CAPABILITIES_CPU: case RARCH_CAPABILITIES_CPU:
{ {
unsigned buf_pos = strlen(s);
uint64_t cpu = cpu_features_get(); uint64_t cpu = cpu_features_get();
if (cpu & RETRO_SIMD_MMX) if (cpu & RETRO_SIMD_MMX)
{ strlcat(s, " MMX", len);
STRLCAT_CONST_INCR(s, buf_pos, " MMX", len);
}
if (cpu & RETRO_SIMD_MMXEXT) if (cpu & RETRO_SIMD_MMXEXT)
{ strlcat(s, " MMXEXT", len);
STRLCAT_CONST_INCR(s, buf_pos, " MMXEXT", len);
}
if (cpu & RETRO_SIMD_SSE) if (cpu & RETRO_SIMD_SSE)
{ strlcat(s, " SSE", len);
STRLCAT_CONST_INCR(s, buf_pos, " SSE", len);
}
if (cpu & RETRO_SIMD_SSE2) if (cpu & RETRO_SIMD_SSE2)
{ strlcat(s, " SSE2", len);
STRLCAT_CONST_INCR(s, buf_pos, " SSE2", len);
}
if (cpu & RETRO_SIMD_SSE3) if (cpu & RETRO_SIMD_SSE3)
{ strlcat(s, " SSE3", len);
STRLCAT_CONST_INCR(s, buf_pos, " SSE3", len);
}
if (cpu & RETRO_SIMD_SSSE3) if (cpu & RETRO_SIMD_SSSE3)
{ strlcat(s, " SSSE3", len);
STRLCAT_CONST_INCR(s, buf_pos, " SSSE3", len);
}
if (cpu & RETRO_SIMD_SSE4) if (cpu & RETRO_SIMD_SSE4)
{ strlcat(s, " SSE4", len);
STRLCAT_CONST_INCR(s, buf_pos, " SSE4", len);
}
if (cpu & RETRO_SIMD_SSE42) if (cpu & RETRO_SIMD_SSE42)
{ strlcat(s, " SSE4.2", len);
STRLCAT_CONST_INCR(s, buf_pos, " SSE4.2", len);
}
if (cpu & RETRO_SIMD_AES) if (cpu & RETRO_SIMD_AES)
{ strlcat(s, " AES", len);
STRLCAT_CONST_INCR(s, buf_pos, " AES", len);
}
if (cpu & RETRO_SIMD_AVX) if (cpu & RETRO_SIMD_AVX)
{ strlcat(s, " AVX", len);
STRLCAT_CONST_INCR(s, buf_pos, " AVX", len);
}
if (cpu & RETRO_SIMD_AVX2) if (cpu & RETRO_SIMD_AVX2)
{ strlcat(s, " AVX2", len);
STRLCAT_CONST_INCR(s, buf_pos, " AVX2", len);
}
if (cpu & RETRO_SIMD_NEON) if (cpu & RETRO_SIMD_NEON)
{ strlcat(s, " NEON", len);
STRLCAT_CONST_INCR(s, buf_pos, " NEON", len);
}
if (cpu & RETRO_SIMD_VFPV3) if (cpu & RETRO_SIMD_VFPV3)
{ strlcat(s, " VFPv3", len);
STRLCAT_CONST_INCR(s, buf_pos, " VFPv3", len);
}
if (cpu & RETRO_SIMD_VFPV4) if (cpu & RETRO_SIMD_VFPV4)
{ strlcat(s, " VFPv4", len);
STRLCAT_CONST_INCR(s, buf_pos, " VFPv4", len);
}
if (cpu & RETRO_SIMD_VMX) if (cpu & RETRO_SIMD_VMX)
{ strlcat(s, " VMX", len);
STRLCAT_CONST_INCR(s, buf_pos, " VMX", len);
}
if (cpu & RETRO_SIMD_VMX128) if (cpu & RETRO_SIMD_VMX128)
{ strlcat(s, " VMX128", len);
STRLCAT_CONST_INCR(s, buf_pos, " VMX128", len);
}
if (cpu & RETRO_SIMD_VFPU) if (cpu & RETRO_SIMD_VFPU)
{ strlcat(s, " VFPU", len);
STRLCAT_CONST_INCR(s, buf_pos, " VFPU", len);
}
if (cpu & RETRO_SIMD_PS) if (cpu & RETRO_SIMD_PS)
{ strlcat(s, " PS", len);
STRLCAT_CONST_INCR(s, buf_pos, " PS", len);
}
if (cpu & RETRO_SIMD_ASIMD) if (cpu & RETRO_SIMD_ASIMD)
{ strlcat(s, " ASIMD", len);
STRLCAT_CONST_INCR(s, buf_pos, " ASIMD", len);
}
s[buf_pos++] = '\0';
} }
break; break;
case RARCH_CAPABILITIES_COMPILER: case RARCH_CAPABILITIES_COMPILER:

View File

@ -273,7 +273,6 @@ runtime_log_t *runtime_log_init(const char *content_path,
char log_file_dir[PATH_MAX_LENGTH]; char log_file_dir[PATH_MAX_LENGTH];
char log_file_path[PATH_MAX_LENGTH]; char log_file_path[PATH_MAX_LENGTH];
char tmp_buf[PATH_MAX_LENGTH]; char tmp_buf[PATH_MAX_LENGTH];
size_t buf_pos = 0;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
core_info_list_t *core_info = NULL; core_info_list_t *core_info = NULL;
runtime_log_t *runtime_log = NULL; runtime_log_t *runtime_log = NULL;
@ -411,8 +410,8 @@ runtime_log_t *runtime_log_init(const char *content_path,
return NULL; return NULL;
/* Build final log file path */ /* Build final log file path */
buf_pos = fill_pathname_join(log_file_path, log_file_dir, content_name, sizeof(log_file_path)); fill_pathname_join(log_file_path, log_file_dir, content_name, sizeof(log_file_path));
STRLCAT_CONST_INCR(log_file_path, buf_pos, ".lrtl", sizeof(log_file_path)); strlcat(log_file_path, ".lrtl", sizeof(log_file_path));
if (string_is_empty(log_file_path)) if (string_is_empty(log_file_path))
return NULL; return NULL;

View File

@ -235,9 +235,8 @@ static void input_autoconfigure_joypad_add(config_file_t *conf,
static bool remote_is_bound = false; static bool remote_is_bound = false;
const char *autoconfig_str = (string_is_empty(display_name) && const char *autoconfig_str = (string_is_empty(display_name) &&
!string_is_empty(params->name)) ? params->name : (!string_is_empty(display_name) ? display_name : "N/A"); !string_is_empty(params->name)) ? params->name : (!string_is_empty(display_name) ? display_name : "N/A");
size_t buf_pos = strlcpy( strlcpy(msg, autoconfig_str, sizeof(msg));
msg, autoconfig_str, sizeof(msg)); strlcat(msg, " configured.", sizeof(msg));
STRLCAT_CONST_INCR(msg, buf_pos, " configured.", sizeof(msg));
if (!remote_is_bound) if (!remote_is_bound)
{ {

View File

@ -251,7 +251,6 @@ static void* task_push_http_transfer_generic(
{ {
task_finder_data_t find_data; task_finder_data_t find_data;
char tmp[255]; char tmp[255];
size_t buf_pos = 0;
const char *s = NULL; const char *s = NULL;
retro_task_t *t = NULL; retro_task_t *t = NULL;
http_handle_t *http = NULL; http_handle_t *http = NULL;
@ -300,10 +299,9 @@ static void* task_push_http_transfer_generic(
else else
s = url; s = url;
buf_pos = strlcpy(tmp, strlcpy(tmp,
msg_hash_to_str(MSG_DOWNLOADING), sizeof(tmp)); msg_hash_to_str(MSG_DOWNLOADING), sizeof(tmp));
strlcat(tmp, " ", sizeof(tmp));
STRLCAT_CONST_INCR(tmp, buf_pos, " ", sizeof(tmp));
if (strstr(s, ".index")) if (strstr(s, ".index"))
strlcat(tmp, msg_hash_to_str(MSG_INDEX_FILE), sizeof(tmp)); strlcat(tmp, msg_hash_to_str(MSG_INDEX_FILE), sizeof(tmp));

View File

@ -81,7 +81,6 @@ static bool get_thumbnail_paths(
char *path, size_t path_size, char *path, size_t path_size,
char *url, size_t url_size) char *url, size_t url_size)
{ {
size_t buf_pos;
const char *system = NULL; const char *system = NULL;
const char *db_name = NULL; const char *db_name = NULL;
const char *img_name = NULL; const char *img_name = NULL;
@ -144,12 +143,12 @@ static bool get_thumbnail_paths(
return false; return false;
/* Generate remote path */ /* Generate remote path */
buf_pos = strlcpy(raw_url, file_path_str(FILE_PATH_CORE_THUMBNAILS_URL), sizeof(raw_url)); strlcpy(raw_url, file_path_str(FILE_PATH_CORE_THUMBNAILS_URL), sizeof(raw_url));
STRLCAT_CONST_INCR(raw_url, buf_pos, "/", sizeof(raw_url)); strlcat(raw_url, "/", sizeof(raw_url));
buf_pos = strlcat(raw_url, system_name, sizeof(raw_url)); strlcat(raw_url, system_name, sizeof(raw_url));
STRLCAT_CONST_INCR(raw_url, buf_pos, "/", sizeof(raw_url)); strlcat(raw_url, "/", sizeof(raw_url));
buf_pos = strlcat(raw_url, sub_dir, sizeof(raw_url)); strlcat(raw_url, sub_dir, sizeof(raw_url));
STRLCAT_CONST_INCR(raw_url, buf_pos, "/", sizeof(raw_url)); strlcat(raw_url, "/", sizeof(raw_url));
strlcat(raw_url, img_name, sizeof(raw_url)); strlcat(raw_url, img_name, sizeof(raw_url));
if (string_is_empty(raw_url)) if (string_is_empty(raw_url))

View File

@ -261,9 +261,9 @@ static bool screenshot_dump(
{ {
if (savestate) if (savestate)
{ {
size_t buf_pos = strlcpy(state->filename, strlcpy(state->filename,
name_base, sizeof(state->filename)); name_base, sizeof(state->filename));
STRLCAT_CONST_INCR(state->filename, buf_pos, ".png", sizeof(state->filename)); strlcat(state->filename, ".png", sizeof(state->filename));
} }
else else
{ {
@ -289,9 +289,9 @@ static bool screenshot_dump(
} }
else else
{ {
size_t buf_pos = strlcpy(state->shotname, path_basename(name_base), strlcpy(state->shotname, path_basename(name_base),
sizeof(state->shotname)); sizeof(state->shotname));
STRLCAT_CONST_INCR(state->shotname, buf_pos, ".png", sizeof(state->shotname)); strlcat(state->shotname, ".png", sizeof(state->shotname));
} }
if ( string_is_empty(screenshot_dir) || if ( string_is_empty(screenshot_dir) ||