From 0ced85b91d2cde949241f2bd80b08174eecf7911 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sun, 16 Jun 2024 15:09:31 +0200 Subject: [PATCH] Get rid of some unnecessary strlcat usage --- gfx/gfx_animation.c | 11 +++++------ gfx/video_shader_parse.c | 5 +++-- network/cloud_sync/webdav.c | 5 ++--- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/gfx/gfx_animation.c b/gfx/gfx_animation.c index 95dc7e9005..b2381979fe 100644 --- a/gfx/gfx_animation.c +++ b/gfx/gfx_animation.c @@ -1361,15 +1361,14 @@ static void build_ticker_loop_string( size_t char_offset1, size_t num_chars1, size_t char_offset2, size_t num_chars2, size_t char_offset3, size_t num_chars3, - char *dest_str, size_t dest_str_len) + char *s, size_t len) { /* Copy 'trailing' chunk of source string, if required */ if (num_chars1 > 0) - utf8cpy( - dest_str, dest_str_len, + utf8cpy(s, len, utf8skip(src_str, char_offset1), num_chars1); else - dest_str[0] = '\0'; + s[0] = '\0'; /* Copy chunk of spacer string, if required */ if (num_chars2 > 0) @@ -1378,7 +1377,7 @@ static void build_ticker_loop_string( utf8cpy( tmp, sizeof(tmp), utf8skip(spacer, char_offset2), num_chars2); - strlcat(dest_str, tmp, dest_str_len); + strlcat(s, tmp, len); } /* Copy 'leading' chunk of source string, if required */ @@ -1388,7 +1387,7 @@ static void build_ticker_loop_string( utf8cpy( tmp, sizeof(tmp), utf8skip(src_str, char_offset3), num_chars3); - strlcat(dest_str, tmp, dest_str_len); + strlcat(s, tmp, len); } } diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 744cc24ce0..71add020cf 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -2780,11 +2780,12 @@ static bool video_shader_load_shader_preset_internal( len); else { + size_t _len; if (string_is_empty(special_name)) break; - fill_pathname_join(s, shader_directory, special_name, len); - strlcat(s, video_shader_get_preset_extension(types[i]), len); + _len = fill_pathname_join(s, shader_directory, special_name, len); + strlcpy(s + _len, video_shader_get_preset_extension(types[i]), len - _len); } if (path_is_valid(s)) diff --git a/network/cloud_sync/webdav.c b/network/cloud_sync/webdav.c index b8be2c246a..cba1726339 100644 --- a/network/cloud_sync/webdav.c +++ b/network/cloud_sync/webdav.c @@ -824,9 +824,8 @@ static bool webdav_delete(const char *path, cloud_sync_complete_handler_t cb, vo } else { - char dir[PATH_MAX_LENGTH] = {0}; - size_t _len; - _len = strlcat(dir, "deleted/", sizeof(dir)); + char dir[PATH_MAX_LENGTH]; + size_t _len = strlcpy(dir, "deleted/", sizeof(dir)); fill_pathname_basedir(dir + _len, path, sizeof(dir) - _len); webdav_ensure_dir(dir, webdav_do_backup, webdav_cb_st); }