diff --git a/cheat_manager.c b/cheat_manager.c index 8cc89d09cc..2bbbd24c2a 100644 --- a/cheat_manager.c +++ b/cheat_manager.c @@ -171,13 +171,9 @@ bool cheat_manager_save( strlcpy(cheats_file, path, sizeof(cheats_file)); else { - size_t len = fill_pathname_join_special(cheats_file, - cheat_database, path, sizeof(cheats_file)); - cheats_file[len ] = '.'; - cheats_file[len+1] = 'c'; - cheats_file[len+2] = 'h'; - cheats_file[len+3] = 't'; - cheats_file[len+4] = '\0'; + size_t len = fill_pathname_join_special(cheats_file, cheat_database, + path, sizeof(cheats_file)); + strlcpy(cheats_file + len, ".cht", sizeof(cheats_file) - len); } if (!overwrite) diff --git a/command.c b/command.c index e8311034ff..6f0b7d8776 100644 --- a/command.c +++ b/command.c @@ -417,11 +417,11 @@ bool command_get_config_param(command_t *cmd, const char* arg) #endif /* TODO: query any string */ - strlcpy(reply, "GET_CONFIG_PARAM ", sizeof(reply)); - _len = strlcat(reply, arg, sizeof(reply)); - reply[_len ] = ' '; - reply[_len+1] = '\0'; - strlcat(reply, value, sizeof(reply)); + _len = strlcpy(reply, "GET_CONFIG_PARAM ", sizeof(reply)); + _len += strlcpy(reply + _len, arg, sizeof(reply) - _len); + reply[ _len] = ' '; + reply[++_len] = '\0'; + _len = strlcpy(reply + _len, value, sizeof(reply) - _len); cmd->replier(cmd, reply, strlen(reply)); return true; } @@ -820,9 +820,9 @@ bool command_write_ram(command_t *cmd, const char *arg) bool command_version(command_t *cmd, const char* arg) { char reply[256]; - size_t _len = strlcpy(reply, PACKAGE_VERSION, sizeof(reply)); - reply[_len ] = '\n'; - reply[_len+1] = '\0'; + size_t _len = strlcpy(reply, PACKAGE_VERSION, sizeof(reply)); + reply[ _len] = '\n'; + reply[++_len] = '\0'; cmd->replier(cmd, reply, strlen(reply)); return true; @@ -1771,8 +1771,8 @@ bool command_event_save_core_config( { size_t _len = strlcpy(tmp, config_path, sizeof(tmp)); if (i) - snprintf(tmp + _len, sizeof(tmp) - _len, "-%u", i); - strlcat(tmp, ".cfg", sizeof(tmp)); + _len += snprintf(tmp + _len, sizeof(tmp) - _len, "-%u", i); + strlcpy(tmp + _len, ".cfg", sizeof(tmp) - _len); if (!path_is_valid(tmp)) { diff --git a/configuration.c b/configuration.c index 17a9b452af..7ee23acbc9 100644 --- a/configuration.c +++ b/configuration.c @@ -4197,9 +4197,8 @@ bool config_load_override(void *data) size_t _len = strlcpy(tmp_path, path_get(RARCH_PATH_CONFIG_OVERRIDE), sizeof(tmp_path)); - tmp_path[_len ] = '|'; - tmp_path[_len+1] = '\0'; - _len += 1; + tmp_path[ _len] = '|'; + tmp_path[++_len] = '\0'; strlcpy(tmp_path + _len, core_path, sizeof(tmp_path) - _len); RARCH_LOG("[Overrides]: Core-specific overrides stacking on top of previous overrides.\n"); } @@ -4228,9 +4227,8 @@ bool config_load_override(void *data) size_t _len = strlcpy(tmp_path, path_get(RARCH_PATH_CONFIG_OVERRIDE), sizeof(tmp_path)); - tmp_path[_len ] = '|'; - tmp_path[_len+1] = '\0'; - _len += 1; + tmp_path[ _len] = '|'; + tmp_path[++_len] = '\0'; strlcpy(tmp_path + _len, content_path, sizeof(tmp_path) - _len); RARCH_LOG("[Overrides]: Content dir-specific overrides stacking on top of previous overrides.\n"); } @@ -4257,9 +4255,8 @@ bool config_load_override(void *data) size_t _len = strlcpy(tmp_path, path_get(RARCH_PATH_CONFIG_OVERRIDE), sizeof(tmp_path)); - tmp_path[_len ] = '|'; - tmp_path[_len+1] = '\0'; - _len += 1; + tmp_path[ _len] = '|'; + tmp_path[++_len] = '\0'; strlcpy(tmp_path + _len, game_path, sizeof(tmp_path) - _len); RARCH_LOG("[Overrides]: Game-specific overrides stacking on top of previous overrides.\n"); } @@ -4603,11 +4600,7 @@ static void save_keybind_joykey(config_file_t *conf, char key[64]; size_t len = fill_pathname_join_delim(key, prefix, base, '_', sizeof(key)); - key[len ] = '_'; - key[len+1] = 'b'; - key[len+2] = 't'; - key[len+3] = 'n'; - key[len+4] = '\0'; + strlcpy(key + len, "_btn", sizeof(key) - len); if (bind->joykey == NO_BTN) { @@ -4627,12 +4620,7 @@ static void save_keybind_axis(config_file_t *conf, { char key[64]; size_t len = fill_pathname_join_delim(key, prefix, base, '_', sizeof(key)); - key[len ] = '_'; - key[len+1] = 'a'; - key[len+2] = 'x'; - key[len+3] = 'i'; - key[len+4] = 's'; - key[len+5] = '\0'; + strlcpy(key + len, "_axis", sizeof(key) - len); if (bind->joyaxis == AXIS_NONE) { @@ -4667,12 +4655,7 @@ static void save_keybind_mbutton(config_file_t *conf, char key[64]; size_t len = fill_pathname_join_delim(key, prefix, base, '_', sizeof(key)); - key[len ] = '_'; - key[len+1] = 'm'; - key[len+2] = 'b'; - key[len+3] = 't'; - key[len+4] = 'n'; - key[len+5] = '\0'; + strlcpy(key + len, "_mbtn", sizeof(key) - len); switch (bind->mbutton) { @@ -4922,11 +4905,7 @@ bool config_save_autoconf_profile(const else len = fill_pathname_join_special(autoconf_file, autoconf_dir, sanitised_name, sizeof(autoconf_file)); - autoconf_file[len ] = '.'; - autoconf_file[len+1] = 'c'; - autoconf_file[len+2] = 'f'; - autoconf_file[len+3] = 'g'; - autoconf_file[len+4] = '\0'; + strlcpy(autoconf_file + len, ".cfg", sizeof(autoconf_file) - len); /* Open config file */ if ( !(conf = config_file_new_from_path_to_string(autoconf_file)) @@ -5654,23 +5633,11 @@ bool input_remapping_load_file(void *data, const char *path) _len = strlcpy(prefix, "input_player", sizeof(prefix)); strlcpy(prefix + _len, formatted_number, sizeof(prefix) - _len); _len = strlcpy(s1, prefix, sizeof(s1)); - s1[_len ] = '_'; - s1[_len+1] = 'b'; - s1[_len+2] = 't'; - s1[_len+3] = 'n'; - s1[_len+4] = '\0'; + strlcpy(s1 + _len, "_btn", sizeof(s1) - _len); _len = strlcpy(s2, prefix, sizeof(s2)); - s2[_len ] = '_'; - s2[_len+1] = 'k'; - s2[_len+2] = 'e'; - s2[_len+3] = 'y'; - s2[_len+4] = '\0'; + strlcpy(s2 + _len, "_key", sizeof(s2) - _len); _len = strlcpy(s3, prefix, sizeof(s3)); - s3[_len ] = '_'; - s3[_len+1] = 's'; - s3[_len+2] = 't'; - s3[_len+3] = 'k'; - s3[_len+4] = '\0'; + strlcpy(s3 + _len, "_stk", sizeof(s3) - _len); for (j = 0; j < RARCH_FIRST_CUSTOM_BIND + 8; j++) { @@ -5832,23 +5799,11 @@ bool input_remapping_save_file(const char *path) _len = strlcpy(prefix, "input_player", sizeof(prefix)); strlcpy(prefix + _len, formatted_number, sizeof(prefix) - _len); _len = strlcpy(s1, prefix, sizeof(s1)); - s1[_len ] = '_'; - s1[_len+1] = 'b'; - s1[_len+2] = 't'; - s1[_len+3] = 'n'; - s1[_len+4] = '\0'; + strlcpy(s1 + _len, "_btn", sizeof(s1) - _len); _len = strlcpy(s2, prefix, sizeof(s2)); - s2[_len ] = '_'; - s2[_len+1] = 'k'; - s2[_len+2] = 'e'; - s2[_len+3] = 'y'; - s2[_len+4] = '\0'; + strlcpy(s2 + _len, "_key", sizeof(s2) - _len); _len = strlcpy(s3, prefix, sizeof(s3)); - s3[_len ] = '_'; - s3[_len+1] = 's'; - s3[_len+2] = 't'; - s3[_len+3] = 'k'; - s3[_len+4] = '\0'; + strlcpy(s3 + _len, "_stk", sizeof(s3) - _len); for (j = 0; j < RARCH_FIRST_CUSTOM_BIND; j++) { diff --git a/core_info.c b/core_info.c index 45e0685505..2cac6cac9c 100644 --- a/core_info.c +++ b/core_info.c @@ -1487,13 +1487,11 @@ static bool core_info_path_is_locked( if (lock_list->size < 1) return false; - len = strlcpy(lock_filename, core_file_name, + len = strlcpy(lock_filename, core_file_name, sizeof(lock_filename)); - lock_filename[len ] = '.'; - lock_filename[len+1] = 'l'; - lock_filename[len+2] = 'c'; - lock_filename[len+3] = 'k'; - lock_filename[len+4] = '\0'; + strlcpy(lock_filename + len, + ".lck", + sizeof(lock_filename) - len); hash = core_info_hash_string(lock_filename); @@ -1520,14 +1518,11 @@ static bool core_info_path_is_standalone_exempt( if (exempt_list->size < 1) return false; - len = strlcpy(exempt_filename, core_file_name, + len = strlcpy(exempt_filename, core_file_name, sizeof(exempt_filename)); - exempt_filename[len ] = '.'; - exempt_filename[len+1] = 'l'; - exempt_filename[len+2] = 's'; - exempt_filename[len+3] = 'a'; - exempt_filename[len+4] = 'e'; - exempt_filename[len+5] = '\0'; + strlcpy(exempt_filename + len, + ".lsae", + sizeof(exempt_filename) - len); hash = core_info_hash_string(exempt_filename); @@ -2889,7 +2884,7 @@ static bool core_info_update_core_aux_file(const char *path, bool create) * core info list this is *not* thread safe */ bool core_info_set_core_lock(const char *core_path, bool lock) { - size_t len; + size_t _len; core_info_t *core_info = NULL; char lock_file_path[PATH_MAX_LENGTH]; @@ -2908,13 +2903,11 @@ bool core_info_set_core_lock(const char *core_path, bool lock) return false; /* Get lock file path */ - len = strlcpy( - lock_file_path, core_info->path, sizeof(lock_file_path)); - lock_file_path[len ] = '.'; - lock_file_path[len+1] = 'l'; - lock_file_path[len+2] = 'c'; - lock_file_path[len+3] = 'k'; - lock_file_path[len+4] = '\0'; + _len = strlcpy(lock_file_path, core_info->path, + sizeof(lock_file_path)); + strlcpy(lock_file_path + _len, + ".lck", + sizeof(lock_file_path) - _len); /* Create or delete lock file, as required */ if (!core_info_update_core_aux_file(lock_file_path, lock)) @@ -2938,7 +2931,7 @@ bool core_info_set_core_lock(const char *core_path, bool lock) * must be checked externally */ bool core_info_get_core_lock(const char *core_path, bool validate_path) { - size_t len; + size_t _len; core_info_t *core_info = NULL; const char *core_file_path = NULL; bool is_locked = false; @@ -2969,14 +2962,11 @@ bool core_info_get_core_lock(const char *core_path, bool validate_path) return false; /* Get lock file path */ - len = strlcpy( - lock_file_path, core_file_path, + _len = strlcpy(lock_file_path, core_file_path, sizeof(lock_file_path)); - lock_file_path[len ] = '.'; - lock_file_path[len+1] = 'l'; - lock_file_path[len+2] = 'c'; - lock_file_path[len+3] = 'k'; - lock_file_path[len+4] = '\0'; + strlcpy(lock_file_path + _len, + ".lck", + sizeof(lock_file_path) - _len); /* Check whether lock file exists */ is_locked = path_is_valid(lock_file_path); @@ -3016,14 +3006,11 @@ bool core_info_set_core_standalone_exempt(const char *core_path, bool exempt) return false; /* Get 'standalone exempt' file path */ - _len = strlcpy(exempt_file_path, core_info->path, + _len = strlcpy(exempt_file_path, core_info->path, sizeof(exempt_file_path)); - exempt_file_path[_len ] = '.'; - exempt_file_path[_len+1] = 'l'; - exempt_file_path[_len+2] = 's'; - exempt_file_path[_len+3] = 'a'; - exempt_file_path[_len+4] = 'e'; - exempt_file_path[_len+5] = '\0'; + strlcpy(exempt_file_path + _len, + ".lsae", + sizeof(exempt_file_path) - _len); /* Create or delete 'standalone exempt' file, as required */ if (core_info_update_core_aux_file(exempt_file_path, exempt)) @@ -3059,15 +3046,11 @@ bool core_info_get_core_standalone_exempt(const char *core_path) return false; /* Get 'standalone exempt' file path */ - _len = strlcpy( - exempt_file_path, core_info->path, + _len = strlcpy(exempt_file_path, core_info->path, sizeof(exempt_file_path)); - exempt_file_path[_len ] = '.'; - exempt_file_path[_len+1] = 'l'; - exempt_file_path[_len+2] = 's'; - exempt_file_path[_len+3] = 'a'; - exempt_file_path[_len+4] = 'e'; - exempt_file_path[_len+5] = '\0'; + strlcpy(exempt_file_path + _len, + ".lsae", + sizeof(exempt_file_path) - _len); /* Check whether 'standalone exempt' file exists */ if (path_is_valid(exempt_file_path)) diff --git a/core_option_manager.c b/core_option_manager.c index 7f05b05d1d..b4923de719 100644 --- a/core_option_manager.c +++ b/core_option_manager.c @@ -1190,7 +1190,6 @@ core_option_manager_t *core_option_manager_new( const char *category_key = opt->opts[size].category_key; char address[256]; - /* Address string is nominally: * * ...where is prepended to the option @@ -1198,17 +1197,18 @@ core_option_manager_t *core_option_manager_new( * collisions */ if (string_is_empty(category_key)) { - address[0] = '#'; - address[1] = '\0'; - strlcat(address, option_def->key, sizeof(address)); + size_t _len = 0; + address[ _len] = '#'; + address[++_len] = '\0'; + strlcpy(address + _len, option_def->key, sizeof(address) - _len); } else { size_t _len = strlcpy(address, category_key, sizeof(address)); - address[_len ] = ':'; - address[_len+1] = '#'; - address[_len+2] = '\0'; - strlcat(address, option_def->key, sizeof(address)); + address[ _len] = ':'; + address[++_len] = '#'; + address[++_len] = '\0'; + strlcpy(address + _len, option_def->key, sizeof(address) - _len); } if (!nested_list_add_item(opt->option_map, diff --git a/disk_control_interface.c b/disk_control_interface.c index 74f55b6e6c..7bef52f555 100644 --- a/disk_control_interface.c +++ b/disk_control_interface.c @@ -634,10 +634,10 @@ bool disk_control_append_image( /* Display log */ _len = strlcpy(msg, msg_hash_to_str(MSG_APPENDED_DISK), sizeof(msg)); - msg[_len ] = ':'; - msg[_len+1] = ' '; - msg[_len+2] = '\0'; - strlcat(msg, image_filename, sizeof(msg)); + msg[ _len] = ':'; + msg[++_len] = ' '; + msg[++_len] = '\0'; + strlcpy(msg + _len, image_filename, sizeof(msg) - _len); RARCH_LOG("[Disc]: %s\n", msg); /* This message should always be displayed, since @@ -664,10 +664,10 @@ error: _len = strlcpy(msg, msg_hash_to_str(MSG_FAILED_TO_APPEND_DISK), sizeof(msg)); - msg[_len ] = ':'; - msg[_len+1] = ' '; - msg[_len+2] = '\0'; - strlcat(msg, image_filename, sizeof(msg)); + msg[ _len] = ':'; + msg[++_len] = ' '; + msg[++_len] = '\0'; + strlcpy(msg + _len, image_filename, sizeof(msg) - _len); runloop_msg_queue_push( msg, 0, 180, diff --git a/disk_index_file.c b/disk_index_file.c index ba9a918c2b..0567475130 100644 --- a/disk_index_file.c +++ b/disk_index_file.c @@ -271,12 +271,9 @@ bool disk_index_file_init( len = fill_pathname_join_special( disk_index_file_path, disk_index_file_dir, content_name, sizeof(disk_index_file_path)); - disk_index_file_path[len ] = '.'; - disk_index_file_path[len+1] = 'l'; - disk_index_file_path[len+2] = 'd'; - disk_index_file_path[len+3] = 'c'; - disk_index_file_path[len+4] = 'i'; - disk_index_file_path[len+5] = '\0'; + strlcpy(disk_index_file_path + len, + ".ldci", + sizeof(disk_index_file_path) - len); if (string_is_empty(disk_index_file_path)) goto error; diff --git a/frontend/drivers/platform_ps2.c b/frontend/drivers/platform_ps2.c index e8f5ba6d66..08694367c7 100644 --- a/frontend/drivers/platform_ps2.c +++ b/frontend/drivers/platform_ps2.c @@ -448,9 +448,9 @@ static int frontend_ps2_parse_drive_list(void *data, bool load_content) if (hddMountStatus == HDD_MOUNT_STATUS_OK) { - size_t _len = strlcpy(hdd, mountString, sizeof(hdd)); - hdd[_len ] = '/'; - hdd[_len+1] = '\0'; + size_t _len = strlcpy(hdd, mountString, sizeof(hdd)); + hdd[ _len] = '/'; + hdd[ ++_len] = '\0'; menu_entries_append(list, hdd, msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR), diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index bd05720e44..61f3623d03 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -2125,9 +2125,8 @@ static void win32_localize_menu(HMENU menu) new_label2 = new_label_text; _len = strlcpy(new_label_text, new_label, buf_size); - new_label_text[_len ] = '\t'; - new_label_text[_len+1] = '\0'; - _len += 1; + new_label_text[ _len] = '\t'; + new_label_text[++_len] = '\0'; strlcpy(new_label_text + _len, meta_key_name, buf_size - _len); /* Make first character of shortcut name uppercase */ new_label_text[len1 + 1] = toupper(new_label_text[len1 + 1]); diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index 5b0a7fd693..dd2ef33172 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -735,8 +735,8 @@ const char *x11_display_server_get_output_options(void *data) _len = strlcat(s, info->name, sizeof(s)); if ((i+1) < res->noutput) { - s[_len ] = '|'; - s[_len+1] = '\0'; + s[ _len] = '|'; + s[++_len] = '\0'; } } diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index 2ee5aa1b3a..7155ec0888 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -839,14 +839,11 @@ static const char *ctr_texture_path(unsigned id) sizeof(state_path))) return NULL; - _len = strlcpy(texture_path, + _len = strlcpy(texture_path, state_path, sizeof(texture_path)); - texture_path[_len ] = '.'; - texture_path[_len+1] = 'p'; - texture_path[_len+2] = 'n'; - texture_path[_len+3] = 'g'; - texture_path[_len+4] = '\0'; - + strlcpy(texture_path + _len, + ".png", + sizeof(texture_path) - _len); return path_basename_nocompression(texture_path); } default: diff --git a/gfx/drivers/gl1.c b/gfx/drivers/gl1.c index a55617420e..4107497c74 100644 --- a/gfx/drivers/gl1.c +++ b/gfx/drivers/gl1.c @@ -1117,18 +1117,18 @@ static void *gl1_init(const video_info_t *video, { char device_str[128]; - + size_t len = 0; device_str[0] = '\0'; if (!string_is_empty(vendor)) { - size_t len = strlcpy(device_str, vendor, sizeof(device_str)); - device_str[len ] = ' '; - device_str[len+1] = '\0'; + len = strlcpy(device_str, vendor, sizeof(device_str)); + device_str[ len] = ' '; + device_str[++len] = '\0'; } if (!string_is_empty(renderer)) - strlcat(device_str, renderer, sizeof(device_str)); + strlcpy(device_str + len, renderer, sizeof(device_str) - len); video_driver_set_gpu_device_string(device_str); diff --git a/gfx/drivers/gl2.c b/gfx/drivers/gl2.c index 09fe824457..9948f17a4c 100644 --- a/gfx/drivers/gl2.c +++ b/gfx/drivers/gl2.c @@ -4323,18 +4323,18 @@ static void *gl2_init(const video_info_t *video, { char device_str[128]; - + size_t len = 0; device_str[0] = '\0'; if (!string_is_empty(vendor)) { - size_t len = strlcpy(device_str, vendor, sizeof(device_str)); - device_str[len ] = ' '; - device_str[len+1] = '\0'; + len = strlcpy(device_str, vendor, sizeof(device_str)); + device_str[ len] = ' '; + device_str[++len] = '\0'; } if (!string_is_empty(renderer)) - strlcat(device_str, renderer, sizeof(device_str)); + strlcpy(device_str + len, renderer, sizeof(device_str) - len); video_driver_set_gpu_device_string(device_str); diff --git a/gfx/drivers/gl3.c b/gfx/drivers/gl3.c index bf2b6ca748..a63c6e0aae 100644 --- a/gfx/drivers/gl3.c +++ b/gfx/drivers/gl3.c @@ -1877,9 +1877,9 @@ static void *gl3_init(const video_info_t *video, { char device_str[128]; size_t len = strlcpy(device_str, vendor, sizeof(device_str)); - device_str[len ] = ' '; - device_str[len+1] = '\0'; - strlcat(device_str, renderer, sizeof(device_str)); + device_str[ len] = ' '; + device_str[++len] = '\0'; + strlcpy(device_str + len, renderer, sizeof(device_str) - len); video_driver_set_gpu_device_string(device_str); video_driver_set_gpu_api_version_string(version); diff --git a/gfx/gfx_animation.c b/gfx/gfx_animation.c index 92e3f1c0fd..5b9cdc34b6 100644 --- a/gfx/gfx_animation.c +++ b/gfx/gfx_animation.c @@ -1438,10 +1438,10 @@ bool gfx_animation_ticker(gfx_animation_ctx_ticker_t *ticker) { size_t len = utf8cpy(ticker->s, PATH_MAX_LENGTH, ticker->str, ticker->len - 3); - ticker->s[len ] = '.'; - ticker->s[len+1] = '.'; - ticker->s[len+2] = '.'; - ticker->s[len+3] = '\0'; + ticker->s[ len] = '.'; + ticker->s[++len] = '.'; + ticker->s[++len] = '.'; + ticker->s[++len] = '\0'; return false; } @@ -1545,13 +1545,12 @@ static bool gfx_animation_ticker_smooth_fw( /* Determine number of characters to copy */ num_chars = (ticker->field_width - suffix_width) / glyph_width; - /* Copy string segment + add suffix */ - _len = utf8cpy(ticker->dst_str, ticker->dst_str_len, ticker->src_str, num_chars); - ticker->dst_str[_len ] = '.'; - ticker->dst_str[_len+1] = '.'; - ticker->dst_str[_len+2] = '.'; - ticker->dst_str[_len+3] = '\0'; + _len = utf8cpy(ticker->dst_str, ticker->dst_str_len, ticker->src_str, num_chars); + ticker->dst_str[ _len] = '.'; + ticker->dst_str[++_len] = '.'; + ticker->dst_str[++_len] = '.'; + ticker->dst_str[++_len] = '\0'; if (ticker->dst_str_width) *ticker->dst_str_width = (num_chars * glyph_width) + suffix_width; @@ -1757,10 +1756,10 @@ bool gfx_animation_ticker_smooth(gfx_animation_ctx_ticker_smooth_t *ticker) /* Copy string segment + add suffix */ _len = utf8cpy(ticker->dst_str, ticker->dst_str_len, ticker->src_str, num_chars); - ticker->dst_str[_len ] = '.'; - ticker->dst_str[_len+1] = '.'; - ticker->dst_str[_len+2] = '.'; - ticker->dst_str[_len+3] = '\0'; + ticker->dst_str[ _len] = '.'; + ticker->dst_str[++_len] = '.'; + ticker->dst_str[++_len] = '.'; + ticker->dst_str[++_len] = '\0'; if (ticker->dst_str_width) *ticker->dst_str_width = current_width + (3 * period_width); diff --git a/gfx/widgets/gfx_widget_load_content_animation.c b/gfx/widgets/gfx_widget_load_content_animation.c index 65503f2b15..461a614a1f 100644 --- a/gfx/widgets/gfx_widget_load_content_animation.c +++ b/gfx/widgets/gfx_widget_load_content_animation.c @@ -390,7 +390,8 @@ bool gfx_widget_start_load_content_animation(void) /* If content was found in playlist but the entry * did not have a db_name, use playlist name itself * as the system name */ - if (playlist_entry_found && !has_system) + if ( playlist_entry_found + && !has_system) { const char *playlist_path = playlist_get_conf_path(playlist); @@ -451,11 +452,9 @@ bool gfx_widget_start_load_content_animation(void) { size_t len = strlcpy(state->icon_file, state->system_name, sizeof(state->icon_file)); - state->icon_file[len] = '.'; - state->icon_file[len+1] = 'p'; - state->icon_file[len+2] = 'n'; - state->icon_file[len+3] = 'g'; - state->icon_file[len+4] = '\0'; + strlcpy(state->icon_file + len, + ".png", + sizeof(state->icon_file) - len); fill_pathname_join_special(icon_path, state->icon_directory, state->icon_file, @@ -480,16 +479,14 @@ bool gfx_widget_start_load_content_animation(void) (databases_list->size == 1)) core_db_name = databases_list->elems[0].data; - if (!string_is_empty(core_db_name) && - !string_is_equal(core_db_name, state->system_name)) + if ( !string_is_empty(core_db_name) + && !string_is_equal(core_db_name, state->system_name)) { size_t len = strlcpy(state->icon_file, core_db_name, sizeof(state->icon_file)); - state->icon_file[len] = '.'; - state->icon_file[len+1] = 'p'; - state->icon_file[len+2] = 'n'; - state->icon_file[len+3] = 'g'; - state->icon_file[len+4] = '\0'; + strlcpy(state->icon_file + len, + ".png", + sizeof(state->icon_file) - len); fill_pathname_join_special(icon_path, state->icon_directory, state->icon_file, diff --git a/input/input_driver.c b/input/input_driver.c index fdaa5a0442..a1bbad2751 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -566,47 +566,47 @@ bool input_driver_button_combo( switch (mode) { case INPUT_COMBO_DOWN_Y_L_R: - if (BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_DOWN) && - BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_Y) && - BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L) && - BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) + if ( BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_DOWN) + && BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_Y) + && BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L) + && BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) return true; break; case INPUT_COMBO_L3_R3: - if (BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L3) && - BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R3)) + if ( BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L3) + && BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R3)) return true; break; case INPUT_COMBO_L1_R1_START_SELECT: - if (BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L) && - BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R) && - BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_START) && - BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) + if ( BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L) + && BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R) + && BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_START) + && BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) return true; break; case INPUT_COMBO_START_SELECT: - if (BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_START) && - BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) + if ( BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_START) + && BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) return true; break; case INPUT_COMBO_L3_R: - if (BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L3) && - BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) + if ( BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L3) + && BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) return true; break; case INPUT_COMBO_L_R: - if (BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L) && - BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) + if ( BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L) + && BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) return true; break; case INPUT_COMBO_DOWN_SELECT: - if (BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_DOWN) && - BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) + if ( BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_DOWN) + && BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) return true; break; case INPUT_COMBO_L2_R2: - if (BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L2) && - BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R2)) + if ( BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L2) + && BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R2)) return true; break; case INPUT_COMBO_HOLD_START: @@ -1263,9 +1263,9 @@ static int16_t input_state_device( } /* Don't allow turbo for D-pad. */ - if ( (id < RETRO_DEVICE_ID_JOYPAD_UP) || - ( (id > RETRO_DEVICE_ID_JOYPAD_RIGHT) && - (id <= RETRO_DEVICE_ID_JOYPAD_R3))) + if ( (id < RETRO_DEVICE_ID_JOYPAD_UP) + || ( (id > RETRO_DEVICE_ID_JOYPAD_RIGHT) + && (id <= RETRO_DEVICE_ID_JOYPAD_R3))) { /* * Apply turbo button if activated. @@ -1314,8 +1314,8 @@ static int16_t input_state_device( /* Avoid detecting buttons being held as multiple toggles */ if (!res) input_st->turbo_btns.turbo_pressed[port] &= ~(1 << id); - else if (!(input_st->turbo_btns.turbo_pressed[port] & (1 << id)) && - turbo_mode == INPUT_TURBO_MODE_SINGLEBUTTON) + else if (!(input_st->turbo_btns.turbo_pressed[port] & (1 << id)) + && turbo_mode == INPUT_TURBO_MODE_SINGLEBUTTON) { uint16_t enable_new; input_st->turbo_btns.turbo_pressed[port] |= 1 << id; @@ -1433,7 +1433,7 @@ static int16_t input_state_device( if (settings->uints.input_remap_ids[port][offset] != offset) reset_state = true; - else if (settings->uints.input_remap_ids[port][offset+1] != (offset+1)) + else if (settings->uints.input_remap_ids[port][offset + 1] != (offset+1)) reset_state = true; } @@ -1444,14 +1444,14 @@ static int16_t input_state_device( res = ret; #ifdef HAVE_OVERLAY - if (input_st->overlay_ptr && - (input_st->overlay_ptr->flags & INPUT_OVERLAY_ALIVE) && - (port == 0) && - (idx != RETRO_DEVICE_INDEX_ANALOG_BUTTON) && - !(((input_analog_dpad_mode == ANALOG_DPAD_LSTICK) && - (idx == RETRO_DEVICE_INDEX_ANALOG_LEFT)) || - ((input_analog_dpad_mode == ANALOG_DPAD_RSTICK) && - (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT)))) + if ( (input_st->overlay_ptr) + && (input_st->overlay_ptr->flags & INPUT_OVERLAY_ALIVE) + && (port == 0) + && (idx != RETRO_DEVICE_INDEX_ANALOG_BUTTON) + && !(((input_analog_dpad_mode == ANALOG_DPAD_LSTICK) + && (idx == RETRO_DEVICE_INDEX_ANALOG_LEFT)) + || ((input_analog_dpad_mode == ANALOG_DPAD_RSTICK) + && (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT)))) { input_overlay_state_t *ol_state = &input_st->overlay_ptr->overlay_state; @@ -1615,8 +1615,8 @@ static int16_t input_state_internal( input_st->flags & INP_FLAG_KB_MAPPING_BLOCKED, mapped_port, device, idx, id); - if ((device == RETRO_DEVICE_ANALOG) && - (ret == 0)) + if ( (device == RETRO_DEVICE_ANALOG) + && (ret == 0)) { if (input_st->libretro_input_binds[mapped_port]) { @@ -3071,13 +3071,7 @@ void input_config_get_bind_string_joykey( { size_t len = fill_pathname_join_delim(buf, prefix, bind->joykey_label, ' ', size); - buf[len ] = ' '; - buf[len+1] = '('; - buf[len+2] = 'h'; - buf[len+3] = 'a'; - buf[len+4] = 't'; - buf[len+5] = ')'; - buf[len+6] = '\0'; + strlcpy(buf + len, " (hat)", size - len); } else { @@ -3114,13 +3108,7 @@ void input_config_get_bind_string_joykey( { size_t len = fill_pathname_join_delim(buf, prefix, bind->joykey_label, ' ', size); - buf[len ] = ' '; - buf[len+1] = '('; - buf[len+2] = 'b'; - buf[len+3] = 't'; - buf[len+4] = 'n'; - buf[len+5] = ')'; - buf[len+6] = '\0'; + strlcpy(buf + len, " (btn)", size - len); } else snprintf(buf, size, "%s%u (%s)", prefix, (unsigned)bind->joykey, @@ -3139,14 +3127,7 @@ void input_config_get_bind_string_joyaxis( { size_t len = fill_pathname_join_delim(buf, prefix, bind->joyaxis_label, ' ', size); - buf[len ] = ' '; - buf[len+1] = '('; - buf[len+2] = 'a'; - buf[len+3] = 'x'; - buf[len+4] = 'i'; - buf[len+5] = 's'; - buf[len+6] = ')'; - buf[len+7] = '\0'; + strlcpy(buf + len, " (axis)", size - len); } else { @@ -3205,6 +3186,7 @@ static unsigned get_kr_utf8( int c1,int c2,int c3) /* utf8 korean composition */ static unsigned get_kr_composition( char* pcur, char* padd) { + size_t _len; static char cc1[] = {"ㄱㄱㄲ ㄷㄷㄸ ㅂㅂㅃ ㅅㅅㅆ ㅈㅈㅉ"}; static char cc2[] = {"ㅗㅏㅘ ㅗㅐㅙ ㅗㅣㅚ ㅜㅓㅝ ㅜㅔㅞ ㅜㅣㅟ ㅡㅣㅢ"}; static char cc3[] = {"ㄱㄱㄲ ㄱㅅㄳ ㄴㅈㄵ ㄴㅎㄶ ㄹㄱㄺ ㄹㅁㄻ ㄹㅂㄼ ㄹㅅㄽ ㄹㅌㄾ ㄹㅍㄿ ㄹㅎㅀ ㅂㅅㅄ ㅅㅅㅆ"}; @@ -3231,8 +3213,8 @@ static unsigned get_kr_composition( char* pcur, char* padd) return ret; /* single element composition */ - strlcpy(utf8, pcur, sizeof(utf8)); - strlcat(utf8, padd, sizeof(utf8)); + _len = strlcpy(utf8, pcur, sizeof(utf8)); + strlcpy(utf8 + _len, padd, sizeof(utf8) - _len); if ((tmp2 = strstr(cc1, utf8))) { @@ -3290,7 +3272,8 @@ static unsigned get_kr_composition( char* pcur, char* padd) strlcpy(utf8, s1 + (19 + c2) * 3, 4); utf8[3] = 0; strlcat(utf8, padd, sizeof(utf8)); - if (!(tmp2 = strstr(cc2, utf8)) || tmp2 >= cc2 + sizeof(cc2) - 10) + if ( !(tmp2 = strstr(cc2, utf8)) + || (tmp2 >= cc2 + sizeof(cc2) - 10)) return ret; strlcpy(utf8, tmp2 + 6, 4); utf8[3] = 0; @@ -5600,9 +5583,9 @@ void input_driver_poll(void) } #endif remap_valid = - (current_button_value == 1) && - (j != remap_button) && - (remap_button != RARCH_UNMAPPED); + (current_button_value == 1) + && (j != remap_button) + && (remap_button != RARCH_UNMAPPED); #ifdef HAVE_ACCESSIBILITY /* gamepad override */ diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index e9ec29f630..dfb5bdaac9 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -383,12 +383,12 @@ void fill_pathname_slash(char *path, size_t size) return; } - path_len = strlen(path); + path_len = strlen(path); /* Try to preserve slash type. */ if (last_slash != (path + path_len - 1)) { - path[path_len] = last_slash[0]; - path[path_len+1] = '\0'; + path[ path_len] = last_slash[0]; + path[++path_len] = '\0'; } } @@ -1002,14 +1002,14 @@ size_t fill_pathname_join_special(char *out_path, /* Try to preserve slash type. */ if (last_slash != (out_path + len - 1)) { - out_path[len] = last_slash[0]; - out_path[len+1] = '\0'; + out_path[ len] = last_slash[0]; + out_path[++len] = '\0'; } } else { - out_path[len] = PATH_DEFAULT_SLASH_C(); - out_path[len+1] = '\0'; + out_path[ len] = PATH_DEFAULT_SLASH_C(); + out_path[++len] = '\0'; } } @@ -1362,8 +1362,8 @@ void fill_pathname_application_path(char *s, size_t len) if (realpath(s, resolved_bundle_dir_buf)) { size_t _len = strlcpy(s, resolved_bundle_dir_buf, len - 1); - s[_len ] = '/'; - s[_len+1] = '\0'; + s[ _len] = '/'; + s[++_len] = '\0'; } } #endif diff --git a/manual_content_scan.c b/manual_content_scan.c index 90f53b22b2..2c5d0b1d67 100644 --- a/manual_content_scan.c +++ b/manual_content_scan.c @@ -1039,11 +1039,9 @@ bool manual_content_scan_get_task_config( task_config->database_name, task_config->system_name, sizeof(task_config->database_name)); - task_config->database_name[len ] = '.'; - task_config->database_name[len+1] = 'l'; - task_config->database_name[len+2] = 'p'; - task_config->database_name[len+3] = 'l'; - task_config->database_name[len+4] = '\0'; + strlcpy(task_config->database_name + len, + ".lpl", + sizeof(task_config->database_name) - len); /* ...which can in turn be used to generate the * playlist path */ @@ -1274,8 +1272,8 @@ static bool manual_content_scan_get_playlist_content_path( if (filter_exts || (archive_list->size == 1)) { /* Build path to file inside archive */ - s[_len ] = '#'; - s[_len+1] = '\0'; + s[ _len] = '#'; + s[++_len] = '\0'; strlcat(s, archive_file, len); } diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index e3c7dc5d8d..652b230bf2 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -859,15 +859,15 @@ static void menu_action_setting_disp_set_label_input_desc( if (remap_idx < RARCH_FIRST_CUSTOM_BIND) { } else if (remap_idx % 2 == 0) { - s[_len ] = ' '; - s[_len+1] = '+'; - s[_len+2] = '\0'; + s[ _len] = ' '; + s[++_len] = '+'; + s[++_len] = '\0'; } else { - s[_len ] = ' '; - s[_len+1] = '-'; - s[_len+2] = '\0'; + s[ _len] = ' '; + s[++_len] = '-'; + s[++_len] = '\0'; } return; } diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 20916b2f1e..dbff673a1c 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -83,10 +83,9 @@ static int menu_action_sublabel_file_browser_core(file_list_t *list, unsigned ty core_info->licenses_list, ", "); _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES), len); - s[_len ] = ':'; - s[_len+1] = ' '; - s[_len+2] = '\0'; - _len += 2; + s[ _len] = ':'; + s[++_len] = ' '; + s[++_len] = '\0'; strlcpy(s + _len, tmp, len - _len); } else @@ -94,10 +93,9 @@ static int menu_action_sublabel_file_browser_core(file_list_t *list, unsigned ty /* No license found - set to N/A */ _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES), len); - s[_len ] = ':'; - s[_len+1] = ' '; - s[_len+2] = '\0'; - _len += 2; + s[ _len] = ':'; + s[++_len] = ' '; + s[++_len] = '\0'; strlcpy(s + _len, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len - _len); } @@ -1660,8 +1658,8 @@ static int action_bind_sublabel_netplay_room(file_list_t *list, buf[0 ] = '('; buf[1 ] = '\0'; _len = strlcat(buf, room->subsystem_name, sizeof(buf)); - buf[_len ] = ')'; - buf[_len+1] = '\0'; + buf[ _len] = ')'; + buf[++_len] = '\0'; } strlcat(s, buf, len); @@ -1704,12 +1702,12 @@ static int action_bind_sublabel_netplay_kick_client(file_list_t *list, { size_t _len = strlcpy(buf, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_STATUS), sizeof(buf)); - buf[_len ] = ':'; - buf[_len+1] = ' '; - buf[_len+2] = '\0'; - _len = strlcat(buf, status, sizeof(buf)); - buf[_len ] = '\n'; - buf[_len+1] = '\0'; + buf[ _len] = ':'; + buf[++_len] = ' '; + buf[++_len] = '\0'; + _len += strlcpy(buf + _len, status, sizeof(buf) - _len); + buf[ _len] = '\n'; + buf[++_len] = '\0'; strlcat(s, buf, len); } @@ -1851,9 +1849,8 @@ static int action_bind_sublabel_playlist_entry( /* Add core name */ _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE), len); - s[_len ] = ' '; - s[_len+1] = '\0'; - _len += 1; + s[ _len] = ' '; + s[++_len] = '\0'; strlcpy(s + _len, entry->core_name, len - _len); /* Get runtime info *if* required runtime log is enabled @@ -1985,20 +1982,20 @@ static int action_bind_sublabel_core_updater_entry( entry->licenses_list, ", "); _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES), len); - s[_len ] = ':'; - s[_len+1] = ' '; - s[_len+2] = '\0'; - strlcat(s, tmp, len); + s[ _len] = ':'; + s[++_len] = ' '; + s[++_len] = '\0'; + strlcpy(s + _len, tmp, len - _len); } else { /* No license found - set to N/A */ _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES), len); - s[_len ] = ':'; - s[_len+1] = ' '; - s[_len+2] = '\0'; - strlcat(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len); + s[ _len] = ':'; + s[++_len] = ' '; + s[++_len] = '\0'; + strlcpy(s + _len, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), len - _len); } return 1; } @@ -2020,15 +2017,15 @@ static int action_bind_sublabel_core_backup_entry( /* Add crc string */ if (string_is_empty(crc)) { - s[_len ] = '0'; - s[_len+1] = '0'; - s[_len+2] = '0'; - s[_len+3] = '0'; - s[_len+4] = '0'; - s[_len+5] = '0'; - s[_len+6] = '0'; - s[_len+7] = '0'; - s[_len+8] = '\0'; + s[ _len] = '0'; + s[++_len] = '0'; + s[++_len] = '0'; + s[++_len] = '0'; + s[++_len] = '0'; + s[++_len] = '0'; + s[++_len] = '0'; + s[++_len] = '0'; + s[++_len] = '\0'; } else strlcpy(s + _len, crc, len - _len); diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 783c7d43bb..3f4fbdca65 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -72,10 +72,9 @@ _len = strlcpy(s, title, len); \ if (!string_is_empty(path)) \ { \ - s[_len ] = ':'; \ - s[_len+1] = ' '; \ - s[_len+2] = '\0'; \ - _len += 2; \ + s[ _len] = ':'; \ + s[++_len] = ' '; \ + s[++_len] = '\0'; \ strlcpy(s + _len, path, len - _len); \ } \ return 1; \ @@ -112,13 +111,10 @@ static void action_get_title_fill_path_search_filter_default( const char *title = msg_hash_to_str(lbl); if (!string_is_empty(title)) _len = strlcpy(s, title, len); - s[_len ] = ' '; - s[_len+1] = '\0'; + s[ _len] = ' '; + s[++_len] = '\0'; if (!string_is_empty(path)) - { - _len += 2; strlcpy(s + _len, path, len - _len); - } menu_entries_search_append_terms_string(s, len); } @@ -428,15 +424,14 @@ static int action_get_title_deferred_core_backup_list( return 0; _len = strlcpy(s, prefix, len); - s[_len ] = ':'; - s[_len+1] = ' '; - s[_len+2] = '\0'; - _len += 2; + s[ _len] = ':'; + s[++_len] = ' '; + s[++_len] = '\0'; /* Search for specified core * > If core is found, add display name */ - if (core_info_find(core_path, &core_info) && - core_info->display_name) + if ( core_info_find(core_path, &core_info) + && core_info->display_name) strlcpy(s + _len, core_info->display_name, len - _len); else { @@ -508,11 +503,10 @@ static int action_get_core_information_steam_list( char *s, size_t len) { size_t _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFORMATION), len); - s[_len ] = ' '; - s[_len+1] = '-'; - s[_len+2] = ' '; - s[_len+3] = '\0'; - _len += 3; + s[ _len] = ' '; + s[++_len] = '-'; + s[++_len] = ' '; + s[++_len] = '\0'; strlcpy(s + _len, path, len - _len); return 1; } @@ -823,10 +817,9 @@ static int action_get_title_generic(char *s, size_t len, if (!string_is_empty(elem0_path)) { path_remove_extension(elem0_path); - s[_len ] = ':'; - s[_len+1] = ' '; - s[_len+2] = '\0'; - _len += 2; + s[ _len] = ':'; + s[++_len] = ' '; + s[++_len] = '\0'; strlcpy(s + _len, path_basename(elem0_path), len - _len); } return 0; @@ -860,9 +853,8 @@ static int action_get_sideload_core_list(const char *path, const char *label, unsigned menu_type, char *s, size_t len) { size_t _len = strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SIDELOAD_CORE_LIST), len); - s[_len ] = ' '; - s[_len+1] = '\0'; - _len += 2; + s[ _len] = ' '; + s[++_len] = '\0'; if (!string_is_empty(path)) strlcpy(s + _len, path, len - _len); return 0; @@ -875,10 +867,9 @@ static int action_get_title_default(const char *path, const char *label, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SELECT_FILE), len); if (!string_is_empty(path)) { - s[_len ] = ':'; - s[_len+1] = ' '; - s[_len+2] = '\0'; - _len += 2; + s[ _len] = ':'; + s[++_len] = ' '; + s[++_len] = '\0'; strlcpy(s + _len, path, len - _len); } @@ -949,11 +940,10 @@ static int action_get_title_group_settings(const char *path, const char *label, _len = strlcpy(s, elem0, len); if (!string_is_empty(elem1)) { - s[_len ] = ' '; - s[_len+1] = '-'; - s[_len+2] = ' '; - s[_len+2] = '\0'; - _len += 3; + s[ _len] = ' '; + s[++_len] = '-'; + s[++_len] = ' '; + s[++_len] = '\0'; strlcpy(s + _len, elem1, len - _len); } } diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 92ab88d251..24b710044a 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -7181,9 +7181,8 @@ static void materialui_frame(void *data, video_frame_info_t *video_info) /* Draw message box */ _len = strlcpy(msg, label, sizeof(msg)); - msg[_len ] = '\n'; - msg[_len+1] = '\0'; - _len += 1; + msg[ _len] = '\n'; + msg[++_len] = '\0'; strlcpy(msg + _len, str, sizeof(msg) - _len); @@ -7527,9 +7526,8 @@ static void materialui_status_bar_init( _len = strlcpy(mui->status_bar.runtime_fallback_str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME), sizeof(mui->status_bar.runtime_fallback_str)); - mui->status_bar.runtime_fallback_str[_len ] = ' '; - mui->status_bar.runtime_fallback_str[_len+1] = '\0'; - _len += 1; + mui->status_bar.runtime_fallback_str[ _len] = ' '; + mui->status_bar.runtime_fallback_str[++_len] = '\0'; strlcpy(mui->status_bar.runtime_fallback_str + _len, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED), sizeof(mui->status_bar.runtime_fallback_str) - _len); @@ -7538,9 +7536,8 @@ static void materialui_status_bar_init( msg_hash_to_str( MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), sizeof(mui->status_bar.last_played_fallback_str)); - mui->status_bar.last_played_fallback_str[_len ] = ' '; - mui->status_bar.last_played_fallback_str[_len+1] = '\0'; - _len += 1; + mui->status_bar.last_played_fallback_str[ _len] = ' '; + mui->status_bar.last_played_fallback_str[++_len] = '\0'; strlcpy(mui->status_bar.last_played_fallback_str + _len, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED), sizeof(mui->status_bar.last_played_fallback_str) - _len diff --git a/menu/drivers/ozone.c b/menu/drivers/ozone.c index ceec8b87fa..38bd94997d 100644 --- a/menu/drivers/ozone.c +++ b/menu/drivers/ozone.c @@ -4146,9 +4146,8 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone) _len = strlcpy(ozone->selection_core_name, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE), sizeof(ozone->selection_core_name)); - ozone->selection_core_name[_len ] = ' '; - ozone->selection_core_name[_len+1] = '\0'; - _len += 1; + ozone->selection_core_name[ _len] = ' '; + ozone->selection_core_name[++_len] = '\0'; strlcpy(ozone->selection_core_name + _len, core_label, sizeof(ozone->selection_core_name) - _len); if (!scroll_content_metadata) @@ -4197,18 +4196,16 @@ static void ozone_update_content_metadata(ozone_handle_t *ozone) strlcpy(ozone->selection_playtime, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME), sizeof(ozone->selection_playtime)); - ozone->selection_playtime[_len ] = ' '; - ozone->selection_playtime[_len+1] = '\0'; - _len += 1; + ozone->selection_playtime[ _len] = ' '; + ozone->selection_playtime[++_len] = '\0'; strlcpy(ozone->selection_playtime + _len, disabled_str, sizeof(ozone->selection_playtime) - _len); _len = strlcpy(ozone->selection_lastplayed, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), sizeof(ozone->selection_lastplayed)); - ozone->selection_lastplayed[_len ] = ' '; - ozone->selection_lastplayed[_len+1] = '\0'; - _len += 1; + ozone->selection_lastplayed[ _len] = ' '; + ozone->selection_lastplayed[++_len] = '\0'; strlcpy(ozone->selection_lastplayed + _len, disabled_str, sizeof(ozone->selection_lastplayed) - _len); } @@ -4888,7 +4885,7 @@ static void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) if (string_ends_with_size(path, ".lpl", strlen(path), STRLEN_CONST(".lpl"))) { - size_t len, _len; + size_t len; struct texture_image ti; char sysname[PATH_MAX_LENGTH]; char texturepath[PATH_MAX_LENGTH]; @@ -4897,22 +4894,21 @@ static void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) /* Add current node to playlist database name map */ RHMAP_SET_STR(ozone->playlist_db_node_map, path, node); - _len = fill_pathname_base( + len = fill_pathname_base( sysname, path, sizeof(sysname)); /* Manually strip the extension (and dot) from sysname */ - sysname[_len-4] = - sysname[_len-3] = - sysname[_len-2] = - sysname[_len-1] = '\0'; - _len = _len-4; + sysname[len-4] = + sysname[len-3] = + sysname[len-2] = + sysname[len-1] = '\0'; len = fill_pathname_join_special(texturepath, ozone->icons_path, sysname, sizeof(texturepath)); - texturepath[len] = '.'; - texturepath[len+1] = 'p'; - texturepath[len+2] = 'n'; - texturepath[len+3] = 'g'; - texturepath[len+4] = '\0'; + texturepath[ len] = '.'; + texturepath[++len] = 'p'; + texturepath[++len] = 'n'; + texturepath[++len] = 'g'; + texturepath[++len] = '\0'; /* If the playlist icon doesn't exist, return default */ if (!path_is_valid(texturepath)) @@ -4920,11 +4916,11 @@ static void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) len = fill_pathname_join_special( texturepath, ozone->icons_path, "default", sizeof(texturepath)); - texturepath[len] = '.'; - texturepath[len+1] = 'p'; - texturepath[len+2] = 'n'; - texturepath[len+3] = 'g'; - texturepath[len+4] = '\0'; + texturepath[ len] = '.'; + texturepath[++len] = 'p'; + texturepath[++len] = 'n'; + texturepath[++len] = 'g'; + texturepath[++len] = '\0'; } ti.width = 0; @@ -4944,20 +4940,7 @@ static void ozone_context_reset_horizontal_list(ozone_handle_t *ozone) image_texture_free(&ti); } - /* Manually append '-content.png' to end of sysname string */ - sysname[_len ] = '-'; - sysname[_len+1 ] = 'c'; - sysname[_len+2 ] = 'o'; - sysname[_len+3 ] = 'n'; - sysname[_len+4 ] = 't'; - sysname[_len+5 ] = 'e'; - sysname[_len+6 ] = 'n'; - sysname[_len+7 ] = 't'; - sysname[_len+8 ] = '.'; - sysname[_len+9 ] = 'p'; - sysname[_len+10] = 'n'; - sysname[_len+11] = 'g'; - sysname[_len+12] = '\0'; + strlcat(sysname, "-content.png", sizeof(sysname)); /* Assemble new icon path */ fill_pathname_join_special( content_texturepath, ozone->icons_path, sysname, diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 03fc0d1c2d..7cbab04173 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -3038,13 +3038,12 @@ static void rgui_update_dynamic_theme_path( { size_t len = fill_pathname_join_special(rgui->theme_dynamic_path, theme_dir, rgui->menu_title, sizeof(rgui->theme_dynamic_path)); - rgui->theme_dynamic_path[len ] = '.'; - rgui->theme_dynamic_path[len+1] = 'c'; - rgui->theme_dynamic_path[len+2] = 'f'; - rgui->theme_dynamic_path[len+3] = 'g'; - rgui->theme_dynamic_path[len+4] = '\0'; - - use_playlist_theme = path_is_valid(rgui->theme_dynamic_path); + rgui->theme_dynamic_path[ len] = '.'; + rgui->theme_dynamic_path[++len] = 'c'; + rgui->theme_dynamic_path[++len] = 'f'; + rgui->theme_dynamic_path[++len] = 'g'; + rgui->theme_dynamic_path[++len] = '\0'; + use_playlist_theme = path_is_valid(rgui->theme_dynamic_path); } if (!use_playlist_theme) @@ -4663,9 +4662,8 @@ static void rgui_render_osk( * fallback to old style 'message box' implementation */ char msg[255]; size_t _len = strlcpy(msg, input_label, sizeof(msg)); - msg[_len ] = '\n'; - msg[_len+1] = '\0'; - _len += 1; + msg[ _len] = '\n'; + msg[++_len] = '\0'; strlcpy(msg + _len, input_str, sizeof(msg) - _len); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 70b7ccd696..6cbf195884 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1132,15 +1132,15 @@ static char* xmb_path_dynamic_wallpaper(xmb_handle_t *xmb) free(tmp); } - path[len ] = '.'; - path[len+1] = 'p'; - path[len+2] = 'n'; - path[len+3] = 'g'; - path[len+4] = '\0'; + path[ len] = '.'; + path[++len] = 'p'; + path[++len] = 'n'; + path[++len] = 'g'; + path[++len] = '\0'; /* Do not update wallpaper in "Load Content" playlists */ - if ((xmb->categories_selection_ptr == 0 && depth > 4) || - (xmb->categories_selection_ptr > xmb->system_tab_end && depth > 1)) + if ( (xmb->categories_selection_ptr == 0 && depth > 4) + || (xmb->categories_selection_ptr > xmb->system_tab_end && depth > 1)) return strdup(xmb->bg_file_path); if (!path_is_valid(path)) @@ -2449,7 +2449,7 @@ static void xmb_context_reset_horizontal_list( if (string_ends_with_size(path, ".lpl", strlen(path), STRLEN_CONST(".lpl"))) { - size_t len, _len; + size_t len; struct texture_image ti; char sysname[PATH_MAX_LENGTH]; char texturepath[PATH_MAX_LENGTH]; @@ -2459,22 +2459,21 @@ static void xmb_context_reset_horizontal_list( /* Add current node to playlist database name map */ RHMAP_SET_STR(xmb->playlist_db_node_map, path, node); - _len = fill_pathname_base( + len = fill_pathname_base( sysname, path, sizeof(sysname)); /* Manually strip the extension (and dot) from sysname */ - sysname[_len-4] = - sysname[_len-3] = - sysname[_len-2] = - sysname[_len-1] = '\0'; - _len = _len-4; + sysname[len-4] = + sysname[len-3] = + sysname[len-2] = + sysname[len-1] = '\0'; len = fill_pathname_join_special( texturepath, iconpath, sysname, sizeof(texturepath)); - texturepath[len ] = '.'; - texturepath[len+1] = 'p'; - texturepath[len+2] = 'n'; - texturepath[len+3] = 'g'; - texturepath[len+4] = '\0'; + texturepath[ len] = '.'; + texturepath[++len] = 'p'; + texturepath[++len] = 'n'; + texturepath[++len] = 'g'; + texturepath[++len] = '\0'; /* If the playlist icon doesn't exist return default */ @@ -2482,11 +2481,11 @@ static void xmb_context_reset_horizontal_list( { len = fill_pathname_join_special(texturepath, iconpath, "default", sizeof(texturepath)); - texturepath[len ] = '.'; - texturepath[len+1] = 'p'; - texturepath[len+2] = 'n'; - texturepath[len+3] = 'g'; - texturepath[len+4] = '\0'; + texturepath[ len] = '.'; + texturepath[++len] = 'p'; + texturepath[++len] = 'n'; + texturepath[++len] = 'g'; + texturepath[++len] = '\0'; } ti.width = 0; @@ -2506,20 +2505,7 @@ static void xmb_context_reset_horizontal_list( image_texture_free(&ti); } - /* Manually append '-content.png' to end of sysname string */ - sysname[_len ] = '-'; - sysname[_len+1 ] = 'c'; - sysname[_len+2 ] = 'o'; - sysname[_len+3 ] = 'n'; - sysname[_len+4 ] = 't'; - sysname[_len+5 ] = 'e'; - sysname[_len+6 ] = 'n'; - sysname[_len+7 ] = 't'; - sysname[_len+8 ] = '.'; - sysname[_len+9 ] = 'p'; - sysname[_len+10] = 'n'; - sysname[_len+11] = 'g'; - sysname[_len+12] = '\0'; + strlcat(sysname, "-content.png", sizeof(sysname)); /* Assemble new icon path */ fill_pathname_join_special(content_texturepath, iconpath, sysname, sizeof(content_texturepath)); @@ -6360,9 +6346,8 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) const char *str = menu_input_dialog_get_buffer(); const char *label = menu_st->input_dialog_kb_label; size_t _len = strlcpy(msg, label, sizeof(msg)); - msg[_len ] = '\n'; - msg[_len+1] = '\0'; - _len += 1; + msg[ _len] = '\n'; + msg[++_len] = '\0'; strlcpy(msg + _len, str, sizeof(msg) - _len); diff --git a/menu/menu_contentless_cores.c b/menu/menu_contentless_cores.c index 878e155251..df67569c37 100644 --- a/menu/menu_contentless_cores.c +++ b/menu/menu_contentless_cores.c @@ -118,8 +118,8 @@ static void contentless_cores_init_info_entries( { core_info_t *core_info = core_info_get(core_info_list, i); - if (core_info && - core_info->supports_no_game) + if ( core_info + && core_info->supports_no_game) { char licenses_str[MENU_SUBLABEL_MAX_LENGTH]; contentless_core_info_entry_t *entry = @@ -127,9 +127,9 @@ static void contentless_cores_init_info_entries( size_t _len = strlcpy(licenses_str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES), sizeof(licenses_str)); - licenses_str[_len ] = ':'; - licenses_str[_len+1] = ' '; - licenses_str[_len+2] = '\0'; + licenses_str[ _len] = ':'; + licenses_str[++_len] = ' '; + licenses_str[++_len] = '\0'; /* Populate licences string */ if (core_info->licenses_list) @@ -164,10 +164,10 @@ void menu_contentless_cores_set_runtime(const char *core_id, { contentless_core_info_entry_t *info_entry = NULL; - if (!contentless_cores_state || - !contentless_cores_state->info_entries || - !runtime_info || - string_is_empty(core_id)) + if ( !contentless_cores_state + || !contentless_cores_state->info_entries + || !runtime_info + || string_is_empty(core_id)) return; info_entry = RHMAP_GET_STR(contentless_cores_state->info_entries, core_id); @@ -200,9 +200,9 @@ void menu_contentless_cores_get_info(const char *core_id, if (!info) return; - if (!contentless_cores_state || - !contentless_cores_state->info_entries || - string_is_empty(core_id)) + if ( !contentless_cores_state + || !contentless_cores_state->info_entries + || string_is_empty(core_id)) *info = NULL; *info = RHMAP_GET_STR(contentless_cores_state->info_entries, core_id); @@ -261,11 +261,11 @@ static void contentless_cores_unload_icons(contentless_cores_state_t *state) static void contentless_cores_load_icons(contentless_cores_state_t *state) { + size_t i; + char icon_path[PATH_MAX_LENGTH]; + char icon_directory[PATH_MAX_LENGTH]; bool rgba_supported = video_driver_supports_rgba(); core_info_list_t *core_info_list = NULL; - char icon_directory[PATH_MAX_LENGTH]; - char icon_path[PATH_MAX_LENGTH]; - size_t i; if (!state) return; @@ -320,25 +320,24 @@ static void contentless_cores_load_icons(contentless_cores_state_t *state) /* Icon name is the first entry in the core * info database list */ - if (core_info && - core_info->supports_no_game && - core_info->databases_list && - (core_info->databases_list->size > 0)) + if ( core_info + && core_info->supports_no_game + && core_info->databases_list + && (core_info->databases_list->size > 0)) { - size_t len; const char *icon_name = core_info->databases_list->elems[0].data; struct texture_image ti = {0}; - ti.supports_rgba = rgba_supported; - - len = fill_pathname_join_special( + size_t len = fill_pathname_join_special( icon_path, icon_directory, icon_name, sizeof(icon_path)); - icon_path[len ] = '.'; - icon_path[len+1] = 'p'; - icon_path[len+2] = 'n'; - icon_path[len+3] = 'g'; - icon_path[len+4] = '\0'; + icon_path[ len] = '.'; + icon_path[++len] = 'p'; + icon_path[++len] = 'n'; + icon_path[++len] = 'g'; + icon_path[++len] = '\0'; + + ti.supports_rgba = rgba_supported; if (!path_is_valid(icon_path)) continue; @@ -367,35 +366,26 @@ uintptr_t menu_contentless_cores_get_entry_icon(const char *core_id) { contentless_cores_state_t *state = contentless_cores_state; uintptr_t *icon = NULL; - - if (!state || - !state->icons_enabled || - !state->icons || - string_is_empty(core_id)) + if ( !state + || !state->icons_enabled + || !state->icons + || string_is_empty(core_id)) return 0; - - icon = RHMAP_GET_STR(state->icons->system, core_id); - - if (icon) + if ((icon = RHMAP_GET_STR(state->icons->system, core_id))) return *icon; - return state->icons->fallback; } void menu_contentless_cores_context_init(void) { - if (!contentless_cores_state) - return; - - contentless_cores_load_icons(contentless_cores_state); + if (contentless_cores_state) + contentless_cores_load_icons(contentless_cores_state); } void menu_contentless_cores_context_deinit(void) { - if (!contentless_cores_state) - return; - - contentless_cores_unload_icons(contentless_cores_state); + if (contentless_cores_state) + contentless_cores_unload_icons(contentless_cores_state); } void menu_contentless_cores_free(void) @@ -422,8 +412,8 @@ unsigned menu_displaylist_contentless_cores(file_list_t *list, settings_t *setti if (core_info_list) { - size_t menu_index = 0; size_t i; + size_t menu_index = 0; /* Sort cores alphabetically */ core_info_qsort(core_info_list, CORE_INFO_LIST_SORT_DISPLAY_NAME); @@ -432,29 +422,31 @@ unsigned menu_displaylist_contentless_cores(file_list_t *list, settings_t *setti for (i = 0; i < core_info_list->count; i++) { core_info_t *core_info = core_info_get(core_info_list, i); - bool core_valid = false; if (core_info) { switch (core_display_type) { case MENU_CONTENTLESS_CORES_DISPLAY_ALL: - core_valid = core_info->supports_no_game; + if (!( core_info->supports_no_game)) + continue; break; case MENU_CONTENTLESS_CORES_DISPLAY_SINGLE_PURPOSE: - core_valid = core_info->supports_no_game && - core_info->single_purpose; + if (!( core_info->supports_no_game + && core_info->single_purpose)) + continue; break; case MENU_CONTENTLESS_CORES_DISPLAY_CUSTOM: - core_valid = core_info->supports_no_game && - !core_info->is_standalone_exempt; + if (!( core_info->supports_no_game + && !core_info->is_standalone_exempt)) + continue; break; default: break; } - if (core_valid && - menu_entries_append(list, + /* Valid core if we have reached here */ + if (menu_entries_append(list, core_info->path, core_info->core_file_id.str, MENU_ENUM_LABEL_CONTENTLESS_CORE, @@ -486,8 +478,8 @@ unsigned menu_displaylist_contentless_cores(file_list_t *list, settings_t *setti contentless_cores_load_icons(contentless_cores_state); } - if ((count == 0) && - menu_entries_append(list, + if ( (count == 0) + && menu_entries_append(list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORES_AVAILABLE), msg_hash_to_str(MENU_ENUM_LABEL_NO_CORES_AVAILABLE), MENU_ENUM_LABEL_NO_CORES_AVAILABLE, diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 55be2a6cda..246226612e 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -562,10 +562,9 @@ static int menu_displaylist_parse_core_info( _len = strlcpy(tmp, msg_hash_to_str(info_list[i].msg), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; - _len += 2; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; strlcpy(tmp + _len, info_list[i].name, sizeof(tmp) - _len); if (menu_entries_append(list, tmp, "", MENU_ENUM_LABEL_CORE_INFO_ENTRY, @@ -579,9 +578,9 @@ static int menu_displaylist_parse_core_info( size_t _len = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_CATEGORIES), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; string_list_join_concat(tmp, sizeof(tmp), core_info->categories_list, ", "); if (menu_entries_append(list, tmp, "", @@ -594,9 +593,9 @@ static int menu_displaylist_parse_core_info( size_t _len = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_AUTHORS), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; string_list_join_concat(tmp, sizeof(tmp), core_info->authors_list, ", "); if (menu_entries_append(list, tmp, "", @@ -609,9 +608,9 @@ static int menu_displaylist_parse_core_info( size_t _len = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_PERMISSIONS), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; string_list_join_concat(tmp, sizeof(tmp), core_info->permissions_list, ", "); if (menu_entries_append(list, tmp, "", @@ -624,9 +623,9 @@ static int menu_displaylist_parse_core_info( size_t _len = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_LICENSES), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; string_list_join_concat(tmp, sizeof(tmp), core_info->licenses_list, ", "); if (menu_entries_append(list, tmp, "", @@ -640,9 +639,9 @@ static int menu_displaylist_parse_core_info( msg_hash_to_str( MENU_ENUM_LABEL_VALUE_CORE_INFO_SUPPORTED_EXTENSIONS), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; string_list_join_concat(tmp, sizeof(tmp), core_info->supported_extensions_list, ", "); if (menu_entries_append(list, tmp, "", @@ -655,9 +654,9 @@ static int menu_displaylist_parse_core_info( size_t _len = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_REQUIRED_HW_API), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; string_list_join_concat(tmp, sizeof(tmp), core_info->required_hw_api_list, ", "); if (menu_entries_append(list, tmp, "", @@ -693,10 +692,9 @@ static int menu_displaylist_parse_core_info( size_t _len = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_SAVESTATE_SUPPORT_LEVEL), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; - _len += 2; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; strlcpy(tmp + _len, savestate_support, sizeof(tmp) - _len); } @@ -731,9 +729,9 @@ static int menu_displaylist_parse_core_info( size_t len = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_INFO_FIRMWARE), sizeof(tmp)); - tmp[len ] = ':'; - tmp[len+1] = ' '; - tmp[len+2] = '\0'; + tmp[ len] = ':'; + tmp[++len] = ' '; + tmp[++len] = '\0'; if (menu_entries_append(list, tmp, "", MENU_ENUM_LABEL_CORE_INFO_ENTRY, MENU_SETTINGS_CORE_INFO_NONE, 0, 0, NULL)) count++; @@ -1538,13 +1536,13 @@ static unsigned menu_displaylist_parse_supported_cores(menu_displaylist_info_t * char entry_alt_text[256]; size_t _len = strlcpy(entry_alt_text, detect_core_str, sizeof(entry_alt_text)); - entry_alt_text[_len ] = ' '; + entry_alt_text[ _len] = ' '; entry_alt_text[++_len] = '('; entry_alt_text[++_len] = '\0'; _len += strlcpy(entry_alt_text + _len, pending_core_name, sizeof(entry_alt_text) - _len); - entry_alt_text[_len ] = ')'; + entry_alt_text[ _len] = ')'; entry_alt_text[++_len] = '\0'; menu_entries_prepend(info->list, pending_core_path, @@ -2329,10 +2327,9 @@ static int create_string_list_rdb_entry_string( string_list_deinitialize(&str_list); _len = strlcpy(tmp, desc, sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; - _len += 2; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; strlcpy(tmp + _len, actual_string, sizeof(tmp) - _len); menu_entries_append(list, tmp, output_label, enum_idx, @@ -2378,10 +2375,9 @@ static int create_string_list_rdb_entry_int( string_list_deinitialize(&str_list); _len = strlcpy(tmp, desc, sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; - _len += 2; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; strlcpy(tmp + _len, str, sizeof(tmp) - _len); menu_entries_append(list, tmp, output_label, enum_idx, @@ -2529,10 +2525,9 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, size_t _len = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_NAME), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; - _len += 2; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; strlcpy(tmp + _len, db_info_entry->name, sizeof(tmp) - _len); menu_entries_append(info->list, tmp, msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_NAME), @@ -2545,9 +2540,9 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, size_t _len = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_DESCRIPTION), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; strlcpy(tmp + _len, db_info_entry->description, sizeof(tmp) - _len); menu_entries_append(info->list, tmp, msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_DESCRIPTION), @@ -2560,10 +2555,9 @@ static int menu_displaylist_parse_database_entry(menu_handle_t *menu, size_t _len = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_RDB_ENTRY_GENRE), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; - _len += 2; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; strlcpy(tmp + _len, db_info_entry->genre, sizeof(tmp) - _len); menu_entries_append(info->list, tmp, msg_hash_to_str(MENU_ENUM_LABEL_RDB_ENTRY_GENRE), @@ -4783,10 +4777,9 @@ static unsigned menu_displaylist_parse_content_information( size_t _len = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_DATABASE), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; - _len += 2; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; strlcpy(tmp + _len, db_name_no_ext, sizeof(tmp) - _len); if (menu_entries_append(info_list, tmp, msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_INFO_DATABASE), @@ -4805,10 +4798,9 @@ static unsigned menu_displaylist_parse_content_information( size_t _len = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_LABEL), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; - _len += 2; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; strlcpy(tmp + _len, !string_is_empty(content_label) ? content_label : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), @@ -4823,10 +4815,9 @@ static unsigned menu_displaylist_parse_content_information( _len = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_PATH), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; - _len += 2; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; strlcpy(tmp + _len, !string_is_empty(content_path) ? content_path : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), @@ -4845,10 +4836,9 @@ static unsigned menu_displaylist_parse_content_information( size_t _len = strlcpy(tmp, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_CORE_NAME), sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\0'; - _len += 2; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\0'; strlcpy(tmp + _len, core_name, sizeof(tmp) - _len); if (menu_entries_append(info_list, tmp, msg_hash_to_str(MENU_ENUM_LABEL_CONTENT_INFO_CORE_NAME), @@ -4912,11 +4902,10 @@ static unsigned menu_displaylist_parse_content_information( const char *cheevos_hash_str = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CONTENT_INFO_CHEEVOS_HASH); size_t _len = strlcpy(tmp, cheevos_hash_str, sizeof(tmp)); - tmp[_len ] = ':'; - tmp[_len+1] = ' '; - tmp[_len+2] = '\n'; - tmp[_len+3] = '\0'; - _len += 3; + tmp[ _len] = ':'; + tmp[++_len] = ' '; + tmp[++_len] = '\n'; + tmp[++_len] = '\0'; strlcpy(tmp + _len, rcheevos_get_hash(), sizeof(tmp) - _len); if (menu_entries_append(info_list, tmp, cheevos_hash_str, MENU_ENUM_LABEL_VALUE_CONTENT_INFO_CHEEVOS_HASH, @@ -5457,12 +5446,12 @@ static int menu_displaylist_parse_input_description_list( sizeof(input_description)); if (i >= RARCH_FIRST_CUSTOM_BIND) { - input_description [_len ] = ' '; + input_description [ _len] = ' '; if ((i % 2) == 0) - input_description[_len+1] = '+'; + input_description[++_len] = '+'; else - input_description[_len+1] = '-'; - input_description [_len+2] = '\0'; + input_description[++_len] = '-'; + input_description [++_len] = '\0'; } if (string_is_empty(input_description)) @@ -6133,28 +6122,30 @@ static unsigned menu_displaylist_populate_subsystem( { /* TODO/FIXME - Localize string */ size_t _len = strlcpy(s, "Load", sizeof(s)); - s[_len ] = ' '; - s[_len+1] = '\0'; - _len = strlcat(s, subsystem->desc, sizeof(s)); - s[_len ] = ' '; - s[_len+1] = '\0'; - strlcat(s, star_char, sizeof(s)); + s[ _len] = ' '; + s[++_len] = '\0'; + _len += strlcpy(s + _len, subsystem->desc, sizeof(s) - _len); + s[ _len] = ' '; + s[++_len] = '\0'; + _len += strlcpy(s + _len, star_char, sizeof(s) - _len); +#ifdef HAVE_RGUI /* If using RGUI with sublabels disabled, add the * appropriate text to the menu entry itself... */ if (is_rgui && !menu_show_sublabels) { - strlcat(s, " [", sizeof(s)); + _len += strlcpy(s + _len, " [", sizeof(s) - _len); /* TODO/FIXME - Localize */ - _len = strlcat(s, "Current Content:", sizeof(s)); - s[_len ] = ' '; - s[_len+1] = '\0'; - _len = strlcat(s, + _len += strlcpy(s + _len, "Current Content:", sizeof(s) - _len); + s[ _len] = ' '; + s[++_len] = '\0'; + _len += strlcpy(s + _len, subsystem->roms[content_get_subsystem_rom_id()].desc, - sizeof(s)); - s[_len ] = ']'; - s[_len+1] = '\0'; + sizeof(s) - _len); + s[ _len] = ']'; + s[++_len] = '\0'; } +#endif if (menu_entries_append(list, s, @@ -6167,35 +6158,35 @@ static unsigned menu_displaylist_populate_subsystem( { /* TODO/FIXME - Localize string */ size_t _len = strlcpy(s, "Start", sizeof(s)); - s[_len ] = ' '; - s[_len+1] = '\0'; - _len = strlcat(s, subsystem->desc, sizeof(s)); - s[_len ] = ' '; - s[_len+1] = '\0'; - strlcat(s, star_char, sizeof(s)); + s[ _len] = ' '; + s[++_len] = '\0'; + _len += strlcpy(s + _len, subsystem->desc, sizeof(s) - _len); + s[ _len] = ' '; + s[++_len] = '\0'; + _len += strlcpy(s + _len, star_char, sizeof(s) - _len); /* If using RGUI with sublabels disabled, add the * appropriate text to the menu entry itself... */ if (is_rgui && !menu_show_sublabels) { - unsigned j = 0; + size_t _len2 = 0; + unsigned j = 0; char rom_buff[PATH_MAX_LENGTH]; - rom_buff[0] = '\0'; for (j = 0; j < content_get_subsystem_rom_id(); j++) { - strlcat(rom_buff, + _len2 += strlcpy(rom_buff + _len2, path_basename(content_get_subsystem_rom(j)), - sizeof(rom_buff)); + sizeof(rom_buff) - _len2); if (j != content_get_subsystem_rom_id() - 1) - strlcat(rom_buff, "|", sizeof(rom_buff)); + _len2 += strlcpy(rom_buff + _len2, "|", sizeof(rom_buff) - _len2); } if (!string_is_empty(rom_buff)) { - strlcat(s, " [", sizeof(s)); - strlcat(s, rom_buff, sizeof(s)); - strlcat(s, "]", sizeof(s)); + _len += strlcpy(s + _len, " [", sizeof(s) - _len); + _len += strlcpy(s + _len, rom_buff, sizeof(s) - _len); + _len += strlcpy(s + _len, "]", sizeof(s) - _len); } } @@ -6211,9 +6202,9 @@ static unsigned menu_displaylist_populate_subsystem( { /* TODO/FIXME - Localize */ size_t _len = strlcpy(s, "Load", sizeof(s)); - s[_len ] = ' '; - s[_len+1] = '\0'; - strlcat(s, subsystem->desc, sizeof(s)); + s[ _len] = ' '; + s[++_len] = '\0'; + _len += strlcpy(s + _len, subsystem->desc, sizeof(s) - _len); /* If using RGUI with sublabels disabled, add the * appropriate text to the menu entry itself... */ @@ -6224,12 +6215,13 @@ static unsigned menu_displaylist_populate_subsystem( * anyway), but no harm in being safe... */ if (subsystem->num_roms > 0) { - strlcat(s, " [", sizeof(s)); + _len += strlcpy(s + _len, " [", sizeof(s) - _len); /* TODO/FIXME - Localize */ - strlcat(s, "Current Content:", sizeof(s)); - strlcat(s, " ", sizeof(s)); - strlcat(s, subsystem->roms[0].desc, sizeof(s)); - strlcat(s, "]", sizeof(s)); + _len += strlcpy(s + _len, "Current Content:", sizeof(s) - _len); + _len += strlcpy(s + _len, " ", sizeof(s) - _len); + _len += strlcpy(s + _len, subsystem->roms[0].desc, + sizeof(s) - _len); + _len += strlcpy(s + _len, "]", sizeof(s) - _len); } } @@ -7777,7 +7769,6 @@ unsigned menu_displaylist_build_list( { unsigned i; - size_t _len; char cheat_label[128]; char on_string[32]; char off_string[32]; @@ -7785,9 +7776,10 @@ unsigned menu_displaylist_build_list( bool search_active = search_terms && (search_terms->size > 0); unsigned num_cheats = cheat_manager_get_size(); unsigned num_cheats_shown = 0; + size_t _len = 0; - on_string[0] = '\0'; - off_string[0] = '\0'; + on_string[0] = '\0'; + off_string[0] = '\0'; /* If a search is active, all options are * omitted apart from 'apply changes' */ @@ -7795,16 +7787,18 @@ unsigned menu_displaylist_build_list( { /* On/off key strings may be required, * so populate them... */ - on_string [0] = '.'; - on_string [1] = '\0'; - off_string[0] = '.'; - off_string[1] = '\0'; - strlcat(on_string, + on_string [ _len] = '.'; + on_string [++_len] = '\0'; + strlcpy(on_string + _len, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON), - sizeof(on_string)); - strlcat(off_string, + sizeof(on_string) - _len); + _len = 0; + off_string[ _len] = '.'; + off_string[++_len] = '\0'; + strlcpy(off_string + _len, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF), - sizeof(off_string)); + sizeof(off_string) - _len); + _len = 0; } else { @@ -11485,9 +11479,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, size_t _len = strlcpy(desc_label, msg_hash_to_str(keyptr->enum_idx), sizeof(desc_label)); - desc_label[_len ] = ' '; - desc_label[_len+1] = '\0'; - _len += 1; + desc_label[ _len] = ' '; + desc_label[++_len] = '\0'; strlcpy(desc_label + _len, descriptor, sizeof(desc_label) - _len); strlcpy(descriptor, desc_label, sizeof(descriptor)); } @@ -11538,9 +11531,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, size_t _len = strlcpy(desc_label, msg_hash_to_str(keyptr->enum_idx), sizeof(desc_label)); - desc_label[_len ] = ' '; - desc_label[_len+1] = '\0'; - _len += 1; + desc_label[ _len] = ' '; + desc_label[++_len] = '\0'; strlcpy(desc_label + _len, descriptor, sizeof(desc_label) - _len); strlcpy(descriptor, desc_label, sizeof(descriptor)); } @@ -12438,9 +12430,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, count++; _len2 = strlcpy(buf, buf_tmp, sizeof(buf)); - buf[_len2 ] = ' '; - buf[_len2+1] = '\0'; - _len2 += 1; + buf[ _len2] = ' '; + buf[++_len2] = '\0'; strlcpy(buf + _len2, val_filter, sizeof(buf) - _len2); if (menu_entries_append(info->list, buf, shdr_filter_pass, MENU_ENUM_LABEL_VIDEO_SHADER_FILTER_PASS, @@ -12448,9 +12439,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, count++; _len2 = strlcpy(buf, buf_tmp, sizeof(buf)); - buf[_len2 ] = ' '; - buf[_len2+1] = '\0'; - _len2 += 1; + buf[ _len2] = ' '; + buf[++_len2] = '\0'; strlcpy(buf + _len2, val_scale, sizeof(buf) - _len2); if (menu_entries_append(info->list, buf, shdr_scale_pass, MENU_ENUM_LABEL_VIDEO_SHADER_SCALE_PASS, diff --git a/menu/menu_driver.c b/menu/menu_driver.c index e7e74da4c1..743531e5e3 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -4539,7 +4539,7 @@ void menu_entries_get_core_title(char *s, size_t len) : ""; size_t _len = strlcpy(s, PACKAGE_VERSION, len); #if defined(_MSC_VER) - _len = strlcat(s, msvc_vercode_to_str(_MSC_VER), len); + _len += strlcpy(s + _len, msvc_vercode_to_str(_MSC_VER), len - _len); #endif if (!string_is_empty(core_version)) @@ -7561,16 +7561,18 @@ int generic_menu_entry_action( { size_t _len = strlcpy(speak_string, title_name, sizeof(speak_string)); - speak_string[_len ] = ' '; - speak_string[_len+1] = '\0'; - _len = strlcat(speak_string, - current_label, sizeof(speak_string)); + speak_string[ _len] = ' '; + speak_string[++_len] = '\0'; + _len += strlcpy(speak_string + _len, + current_label, + sizeof(speak_string) - _len); if (!string_is_equal(current_value, "...")) { - speak_string[_len ] = ' '; - speak_string[_len+1] = '\0'; - strlcat(speak_string, current_value, - sizeof(speak_string)); + speak_string[ _len] = ' '; + speak_string[++_len] = '\0'; + strlcpy(speak_string + _len, + current_value, + sizeof(speak_string) - _len); } } else @@ -7579,10 +7581,11 @@ int generic_menu_entry_action( current_label, sizeof(speak_string)); if (!string_is_equal(current_value, "...")) { - speak_string[_len ] = ' '; - speak_string[_len+1] = '\0'; - strlcat(speak_string, current_value, - sizeof(speak_string)); + speak_string[ _len] = ' '; + speak_string[++_len] = '\0'; + strlcpy(speak_string + _len, + current_value, + sizeof(speak_string) - _len); } } diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 1e62e50984..682bca5f3c 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1051,11 +1051,10 @@ static void setting_get_string_representation_int_gpu_index(rarch_setting_t *set size_t _len = snprintf(s, len, "%d", *setting->value.target.integer); if (list && (*setting->value.target.integer < (int)list->size) && !string_is_empty(list->elems[*setting->value.target.integer].data)) { - s[_len ] = ' '; - s[_len+1] = '-'; - s[_len+2] = ' '; - s[_len+3] = '\0'; - _len += 3; + s[ _len] = ' '; + s[++_len] = '-'; + s[++_len] = ' '; + s[++_len] = '\0'; strlcpy(s + _len, list->elems[*setting->value.target.integer].data, len - _len); } } @@ -9156,9 +9155,9 @@ static bool setting_append_list_input_player_options( if (!string_is_empty(buffer[user])) { - size_t _len = strlcpy(label, buffer[user], sizeof(label)); - label[_len ] = ' '; - label[_len+1] = '\0'; + size_t _len = strlcpy(label, buffer[user], sizeof(label)); + label[ _len] = ' '; + label[++_len] = '\0'; } else label[0] = '\0'; diff --git a/retroarch.c b/retroarch.c index 988c0246b6..deb43ec657 100644 --- a/retroarch.c +++ b/retroarch.c @@ -5431,21 +5431,12 @@ static void retroarch_parse_input_libretro_path(const char *path) if (!string_ends_with_size(tmp_path, "_libretro", strlen(tmp_path), STRLEN_CONST("_libretro"))) - { - tmp_path[_len ] = '_'; - tmp_path[_len+1] = 'l'; - tmp_path[_len+2] = 'i'; - tmp_path[_len+3] = 'b'; - tmp_path[_len+4] = 'r'; - tmp_path[_len+5] = 'e'; - tmp_path[_len+6] = 't'; - tmp_path[_len+7] = 'r'; - tmp_path[_len+8] = 'o'; - tmp_path[_len+9] = '\0'; - } + strlcpy(tmp_path + _len, + "_libretro", + sizeof(tmp_path) - _len); - if (!core_info_find(tmp_path, &core_info) || - string_is_empty(core_info->path)) + if ( !core_info_find(tmp_path, &core_info) + || string_is_empty(core_info->path)) goto end; core_path = core_info->path; @@ -6367,8 +6358,8 @@ bool retroarch_main_init(int argc, char *argv[]) strlcat(str_output, FILE_PATH_LOG_INFO " CPU Model Name: ", sizeof(str_output)); _len = strlcat(str_output, cpu_model, sizeof(str_output)); - str_output[_len ] = '\n'; - str_output[_len+1] = '\0'; + str_output[ _len] = '\n'; + str_output[++_len] = '\0'; } RARCH_LOG_OUTPUT("%s", str_output); diff --git a/runloop.c b/runloop.c index 72d98b1efd..4133da7ebb 100644 --- a/runloop.c +++ b/runloop.c @@ -4104,11 +4104,9 @@ static bool runloop_path_init_subsystem(runloop_state_t *runloop_st) size_t len = strlcpy(runloop_st->name.savefile, runloop_st->runtime_content_path_basename, sizeof(runloop_st->name.savefile)); - runloop_st->name.savefile[len ] = '.'; - runloop_st->name.savefile[len+1] = 's'; - runloop_st->name.savefile[len+2] = 'r'; - runloop_st->name.savefile[len+3] = 'm'; - runloop_st->name.savefile[len+4] = '\0'; + strlcpy(runloop_st->name.savefile + len, + ".srm", + sizeof(runloop_st->name.savefile) - len); } if (path_is_directory(runloop_st->name.savefile)) @@ -4572,16 +4570,16 @@ bool runloop_event_init_core( video_st->title_buf, msg_hash_to_str(MSG_PROGRAM), sizeof(video_st->title_buf)); - video_st->title_buf[len ] = ' '; - video_st->title_buf[len+1] = '\0'; - len = strlcat(video_st->title_buf, + video_st->title_buf[ len] = ' '; + video_st->title_buf[++len] = '\0'; + len += strlcpy(video_st->title_buf + len, sys_info->info.library_name, - sizeof(video_st->title_buf)); - video_st->title_buf[len ] = ' '; - video_st->title_buf[len+1] = '\0'; - strlcat(video_st->title_buf, + sizeof(video_st->title_buf) - len); + video_st->title_buf[ len] = ' '; + video_st->title_buf[++len] = '\0'; + strlcpy(video_st->title_buf + len, sys_info->info.library_version, - sizeof(video_st->title_buf)); + sizeof(video_st->title_buf) - len); strlcpy(sys_info->valid_extensions, sys_info->info.valid_extensions ? @@ -4760,11 +4758,9 @@ void runloop_path_fill_names(void) size_t len = strlcpy(runloop_st->name.ups, runloop_st->runtime_content_path_basename, sizeof(runloop_st->name.ups)); - runloop_st->name.ups[len ] = '.'; - runloop_st->name.ups[len+1] = 'u'; - runloop_st->name.ups[len+2] = 'p'; - runloop_st->name.ups[len+3] = 's'; - runloop_st->name.ups[len+4] = '\0'; + strlcpy(runloop_st->name.ups + len, + ".ups", + sizeof(runloop_st->name.ups) - len); } if (string_is_empty(runloop_st->name.bps)) @@ -4772,11 +4768,9 @@ void runloop_path_fill_names(void) size_t len = strlcpy(runloop_st->name.bps, runloop_st->runtime_content_path_basename, sizeof(runloop_st->name.bps)); - runloop_st->name.bps[len ] = '.'; - runloop_st->name.bps[len+1] = 'b'; - runloop_st->name.bps[len+2] = 'p'; - runloop_st->name.bps[len+3] = 's'; - runloop_st->name.bps[len+4] = '\0'; + strlcpy(runloop_st->name.bps + len, + ".bps", + sizeof(runloop_st->name.bps) - len); } if (string_is_empty(runloop_st->name.ips)) @@ -4784,11 +4778,9 @@ void runloop_path_fill_names(void) size_t len = strlcpy(runloop_st->name.ips, runloop_st->runtime_content_path_basename, sizeof(runloop_st->name.ips)); - runloop_st->name.ips[len ] = '.'; - runloop_st->name.ips[len+1] = 'i'; - runloop_st->name.ips[len+2] = 'p'; - runloop_st->name.ips[len+3] = 's'; - runloop_st->name.ips[len+4] = '\0'; + strlcpy(runloop_st->name.ips + len, + ".ips", + sizeof(runloop_st->name.ips) - len); } } @@ -7805,11 +7797,9 @@ void runloop_path_set_names(void) size_t len = strlcpy(runloop_st->name.savefile, runloop_st->runtime_content_path_basename, sizeof(runloop_st->name.savefile)); - runloop_st->name.savefile[len ] = '.'; - runloop_st->name.savefile[len+1] = 's'; - runloop_st->name.savefile[len+2] = 'r'; - runloop_st->name.savefile[len+3] = 'm'; - runloop_st->name.savefile[len+4] = '\0'; + strlcpy(runloop_st->name.savefile + len, + ".srm", + sizeof(runloop_st->name.savefile) - len); } if (!retroarch_override_setting_is_set( @@ -7819,13 +7809,9 @@ void runloop_path_set_names(void) runloop_st->name.savestate, runloop_st->runtime_content_path_basename, sizeof(runloop_st->name.savestate)); - runloop_st->name.savestate[len ] = '.'; - runloop_st->name.savestate[len+1] = 's'; - runloop_st->name.savestate[len+2] = 't'; - runloop_st->name.savestate[len+3] = 'a'; - runloop_st->name.savestate[len+4] = 't'; - runloop_st->name.savestate[len+5] = 'e'; - runloop_st->name.savestate[len+6] = '\0'; + strlcpy(runloop_st->name.savestate + len, + ".state", + sizeof(runloop_st->name.savestate) - len); } #ifdef HAVE_BSV_MOVIE @@ -7836,14 +7822,9 @@ void runloop_path_set_names(void) runloop_st->name.replay, runloop_st->runtime_content_path_basename, sizeof(runloop_st->name.replay)); - runloop_st->name.replay[len ] = '.'; - runloop_st->name.replay[len+1] = 'r'; - runloop_st->name.replay[len+2] = 'e'; - runloop_st->name.replay[len+3] = 'p'; - runloop_st->name.replay[len+4] = 'l'; - runloop_st->name.replay[len+5] = 'a'; - runloop_st->name.replay[len+6] = 'y'; - runloop_st->name.replay[len+7] = '\0'; + strlcpy(runloop_st->name.replay + len, + ".replay", + sizeof(runloop_st->name.replay) - len); } #endif @@ -7854,11 +7835,9 @@ void runloop_path_set_names(void) runloop_st->name.cheatfile, runloop_st->runtime_content_path_basename, sizeof(runloop_st->name.cheatfile)); - runloop_st->name.cheatfile[len ] = '.'; - runloop_st->name.cheatfile[len+1] = 'c'; - runloop_st->name.cheatfile[len+2] = 'h'; - runloop_st->name.cheatfile[len+3] = 't'; - runloop_st->name.cheatfile[len+4] = '\0'; + strlcpy(runloop_st->name.cheatfile + len, + ".cht", + sizeof(runloop_st->name.cheatfile) - len); } #endif } diff --git a/runtime_file.c b/runtime_file.c index 2da66178fd..67b63e15c3 100644 --- a/runtime_file.c +++ b/runtime_file.c @@ -779,8 +779,8 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log, struct tm time_info; runtime_log_get_last_played_time(runtime_log, &time_info); strftime_am_pm(tmp, sizeof(tmp), format_str, &time_info); - str[_len ] = ' '; - str[_len+1] = '\0'; + str[ _len] = ' '; + str[++_len] = '\0'; strlcat(str, tmp, len); return; } @@ -1038,8 +1038,8 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log, msg_hash_to_str( MENU_ENUM_LABEL_VALUE_PLAYLIST_INLINE_CORE_DISPLAY_NEVER), sizeof(tmp)); - str[_len ] = ' '; - str[_len+1] = '\0'; + str[ _len] = ' '; + str[++_len] = '\0'; strlcat(str, tmp, len); return; case PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS: diff --git a/tasks/task_content_disc.c b/tasks/task_content_disc.c index 468e92e2ac..1be59699ef 100755 --- a/tasks/task_content_disc.c +++ b/tasks/task_content_disc.c @@ -159,13 +159,11 @@ static void task_cdrom_dump_handler(retro_task_t *task) filestream_close(state->file); - _len = strlcpy(cue_filename, - state->title, sizeof(cue_filename)); - cue_filename[_len ] = '.'; - cue_filename[_len+1] = 'c'; - cue_filename[_len+2] = 'u'; - cue_filename[_len+3] = 'e'; - cue_filename[_len+4] = '\0'; + _len = strlcpy(cue_filename, + state->title, sizeof(cue_filename)); + strlcpy(cue_filename + _len, + ".cue", + sizeof(cue_filename) - _len); fill_pathname_join_special(output_file, directory_core_assets, cue_filename, sizeof(output_file)); diff --git a/tasks/task_database.c b/tasks/task_database.c index 37f55aab17..c5060aeff5 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -1082,11 +1082,11 @@ static int task_database_iterate_serial_lookup( if (!serial_buf) return 1; - strlcpy(query, "{'serial': b'", sizeof(query)); - _len = strlcat(query, serial_buf, sizeof(query)); - query[_len ] = '\''; - query[_len+1] = '}'; - query[_len+2] = '\0'; + _len = strlcpy(query, "{'serial': b'", sizeof(query)); + _len += strlcpy(query + _len, serial_buf, sizeof(query) - _len); + query[ _len] = '\''; + query[++_len] = '}'; + query[++_len] = '\0'; database_info_list_iterate_new(db_state, query); free(serial_buf); diff --git a/tasks/task_database_cue.c b/tasks/task_database_cue.c index 8a280117d0..71979ab642 100644 --- a/tasks/task_database_cue.c +++ b/tasks/task_database_cue.c @@ -519,68 +519,68 @@ int detect_gc_game(intfstream_t *fd, char *s, size_t len, const char *filename) switch (region_id) { case 'E': - s[_len ] = '-'; - s[_len+1] = 'U'; - s[_len+2] = 'S'; - s[_len+3] = 'A'; - s[_len+4] = '\0'; + s[ _len] = '-'; + s[++_len] = 'U'; + s[++_len] = 'S'; + s[++_len] = 'A'; + s[++_len] = '\0'; return true; case 'J': - s[_len ] = '-'; - s[_len+1] = 'J'; - s[_len+2] = 'P'; - s[_len+3] = 'N'; - s[_len+4] = '\0'; + s[ _len] = '-'; + s[++_len] = 'J'; + s[++_len] = 'P'; + s[++_len] = 'N'; + s[++_len] = '\0'; return true; case 'P': /** NYI: P can also be P-UKV, P-AUS **/ case 'X': /** NYI: X can also be X-UKV, X-EUU **/ - s[_len ] = '-'; - s[_len+1] = 'E'; - s[_len+2] = 'U'; - s[_len+3] = 'R'; - s[_len+4] = '\0'; + s[ _len] = '-'; + s[++_len] = 'E'; + s[++_len] = 'U'; + s[++_len] = 'R'; + s[++_len] = '\0'; return true; case 'Y': - s[_len ] = '-'; - s[_len+1] = 'F'; - s[_len+2] = 'A'; - s[_len+3] = 'H'; - s[_len+4] = '\0'; + s[ _len] = '-'; + s[++_len] = 'F'; + s[++_len] = 'A'; + s[++_len] = 'H'; + s[++_len] = '\0'; return true; case 'D': - s[_len ] = '-'; - s[_len+1] = 'N'; - s[_len+2] = 'O'; - s[_len+3] = 'E'; - s[_len+4] = '\0'; + s[ _len] = '-'; + s[++_len] = 'N'; + s[++_len] = 'O'; + s[++_len] = 'E'; + s[++_len] = '\0'; return true; case 'S': - s[_len ] = '-'; - s[_len+1] = 'E'; - s[_len+2] = 'S'; - s[_len+3] = 'P'; - s[_len+4] = '\0'; + s[ _len] = '-'; + s[++_len] = 'E'; + s[++_len] = 'S'; + s[++_len] = 'P'; + s[++_len] = '\0'; return true; case 'F': - s[_len ] = '-'; - s[_len+1] = 'F'; - s[_len+2] = 'R'; - s[_len+3] = 'A'; - s[_len+4] = '\0'; + s[ _len] = '-'; + s[++_len] = 'F'; + s[++_len] = 'R'; + s[++_len] = 'A'; + s[++_len] = '\0'; return true; case 'I': - s[_len ] = '-'; - s[_len+1] = 'I'; - s[_len+2] = 'T'; - s[_len+3] = 'A'; - s[_len+4] = '\0'; + s[ _len] = '-'; + s[++_len] = 'I'; + s[++_len] = 'T'; + s[++_len] = 'A'; + s[++_len] = '\0'; return true; case 'H': - s[_len ] = '-'; - s[_len+1] = 'H'; - s[_len+2] = 'O'; - s[_len+3] = 'L'; - s[_len+4] = '\0'; + s[ _len] = '-'; + s[++_len] = 'H'; + s[++_len] = 'O'; + s[++_len] = 'L'; + s[++_len] = '\0'; return true; default: break; @@ -653,10 +653,10 @@ int detect_scd_game(intfstream_t *fd, char *s, size_t len, const char *filename) strncpy(lgame_id, pre_game_id, index); lgame_id[index] = '\0'; _len = strlcat(s, lgame_id, len); - s[_len ] = '-'; - s[_len+1] = '5'; - s[_len+2] = '0'; - s[_len+3] = '\0'; + s[ _len] = '-'; + s[++_len] = '5'; + s[++_len] = '0'; + s[++_len] = '\0'; cue_append_multi_disc_suffix(s, filename); return true; } @@ -679,10 +679,10 @@ int detect_scd_game(intfstream_t *fd, char *s, size_t len, const char *filename) strncpy(lgame_id, &pre_game_id[3], 4); lgame_id[4] = '\0'; _len = strlcat(s, lgame_id, len); - s[_len ] = '-'; - s[_len+1] = '5'; - s[_len+2] = '0'; - s[_len+3] = '\0'; + s[ _len] = '-'; + s[++_len] = '5'; + s[++_len] = '0'; + s[++_len] = '\0'; cue_append_multi_disc_suffix(s, filename); return true; } @@ -781,10 +781,10 @@ int detect_sat_game(intfstream_t *fd, char *s, size_t len, const char *filename) } strlcat(s, lgame_id, len); _len = strlcat(s, rgame_id, len); - s[_len ] = '-'; - s[_len+1] = '5'; - s[_len+2] = '0'; - s[_len+3] = '\0'; + s[ _len] = '-'; + s[++_len] = '5'; + s[++_len] = '0'; + s[++_len] = '\0'; cue_append_multi_disc_suffix(s, filename); return true; case 'J': @@ -851,9 +851,9 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) strncpy(rgame_id, &raw_game_id[index + 1], length - 1); rgame_id[length - 1] = '\0'; _len = strlcat(s, lgame_id, len); - s[_len ] = '-'; - s[_len+1] = '\0'; - strlcat(s, rgame_id, len); + s[ _len] = '-'; + s[++_len] = '\0'; + strlcpy(s + _len, rgame_id, len - _len); cue_append_multi_disc_suffix(s, filename); return true; } @@ -869,9 +869,9 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) strncpy(rgame_id, &raw_game_id[length - 2], length - 1); rgame_id[length - 1] = '\0'; _len = strlcat(s, lgame_id, len); - s[_len ] = '-'; - s[_len+1] = '\0'; - strlcat(s, rgame_id, len); + s[ _len] = '-'; + s[++_len] = '\0'; + strlcpy(s + _len, rgame_id, len - _len); cue_append_multi_disc_suffix(s, filename); return true; } @@ -882,9 +882,9 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) strncpy(rgame_id, &raw_game_id[1], length - 1); rgame_id[length - 1] = '\0'; _len = strlcpy(pre_game_id, lgame_id, sizeof(pre_game_id)); - pre_game_id[_len ] = '-'; - pre_game_id[_len+1] = '\0'; - strlcat(pre_game_id, rgame_id, sizeof(pre_game_id)); + pre_game_id[ _len] = '-'; + pre_game_id[++_len] = '\0'; + strlcpy(pre_game_id + _len, rgame_id, sizeof(pre_game_id) - _len); total_hyphens_recalc = string_count_occurrences_single_character(pre_game_id, '-'); if (total_hyphens_recalc >= 2) @@ -899,9 +899,9 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) strncpy(rgame_id, &pre_game_id[length_recalc - 2], length_recalc - 1); rgame_id[length_recalc - 1] = '\0'; _len = strlcat(s, lgame_id, len); - s[_len ] = '-'; - s[_len+1] = '\0'; - strlcat(s, rgame_id, len); + s[ _len] = '-'; + s[++_len] = '\0'; + strlcpy(s + _len, rgame_id, len - _len); cue_append_multi_disc_suffix(s, filename); } else @@ -919,9 +919,9 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) strncpy(rgame_id, &pre_game_id[length_recalc - 2], length_recalc - 1); rgame_id[length_recalc - 1] = '\0'; _len = strlcat(s, lgame_id, len); - s[_len ] = '-'; - s[_len+1] = '\0'; - strlcat(s, rgame_id ,len); + s[ _len] = '-'; + s[++_len] = '\0'; + strlcpy(s + _len, rgame_id, len - _len); cue_append_multi_disc_suffix(s, filename); } return true; @@ -941,9 +941,9 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) strncpy(rgame_id, &raw_game_id[length - 4], length - 3); rgame_id[length - 3] = '\0'; _len = strlcat(s, lgame_id, len); - s[_len ] = '-'; - s[_len+1] = '\0'; - strlcat(s, rgame_id, len); + s[ _len] = '-'; + s[++_len] = '\0'; + strlcpy(s + _len, rgame_id, len - _len); cue_append_multi_disc_suffix(s, filename); return true; } @@ -976,9 +976,9 @@ int detect_dc_game(intfstream_t *fd, char *s, size_t len, const char *filename) strncpy(rgame_id, &raw_game_id[length - 2], length - 1); rgame_id[length - 1] = '\0'; _len = strlcat(s, lgame_id, len); - s[_len ] = '-'; - s[_len+1] = '\0'; - strlcat(s, rgame_id, len); + s[ _len] = '-'; + s[++_len] = '\0'; + strlcpy(s + _len, rgame_id, len - _len); cue_append_multi_disc_suffix(s, filename); return true; } diff --git a/tasks/task_http.c b/tasks/task_http.c index 2feacb3092..e2c0619ff1 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -378,9 +378,8 @@ void* task_push_http_transfer_file(const char* url, bool mute, s = url; len = strlcpy(tmp, msg_hash_to_str(MSG_DOWNLOADING), sizeof(tmp)); - tmp[len ] = ' '; - tmp[len+1] = '\0'; - len += 1; + tmp[ len] = ' '; + tmp[++len] = '\0'; if (string_ends_with_size(s, ".index", strlen(s), STRLEN_CONST(".index"))) diff --git a/tasks/task_save.c b/tasks/task_save.c index 1f658d48c2..08bcf1f67f 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -824,8 +824,8 @@ static void task_save_handler(retro_task_t *task) size_t _len = strlcpy(err, msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO), err_size - 1); - err[_len ] = ' '; - err[_len+1] = '\0'; + err[ _len] = ' '; + err[++_len] = '\0'; strlcat(err, state->path, err_size - 1); } diff --git a/tasks/task_screenshot.c b/tasks/task_screenshot.c index e3ff55aa42..f32d363913 100644 --- a/tasks/task_screenshot.c +++ b/tasks/task_screenshot.c @@ -273,11 +273,9 @@ static bool screenshot_dump( { size_t len = strlcpy(state->filename, name_base, sizeof(state->filename)); - state->filename[len ] = '.'; - state->filename[len+1] = 'p'; - state->filename[len+2] = 'n'; - state->filename[len+3] = 'g'; - state->filename[len+4] = '\0'; + strlcpy(state->filename + len, + ".png", + sizeof(state->filename) - len); } else { @@ -331,18 +329,16 @@ static bool screenshot_dump( } else { - size_t len = strlcpy( - state->shotname, path_basename_nocompression(name_base), + size_t len = strlcpy(state->shotname, + path_basename_nocompression(name_base), sizeof(state->shotname)); - state->shotname[len ] = '.'; - state->shotname[len+1] = 'p'; - state->shotname[len+2] = 'n'; - state->shotname[len+3] = 'g'; - state->shotname[len+4] = '\0'; + strlcpy(state->shotname + len, + ".png", + sizeof(state->shotname) - len); } - if ( string_is_empty(new_screenshot_dir) || - settings->bools.screenshots_in_content_dir) + if ( string_is_empty(new_screenshot_dir) + || settings->bools.screenshots_in_content_dir) fill_pathname_basedir(new_screenshot_dir, name_base, sizeof(new_screenshot_dir)); diff --git a/tasks/task_translation.c b/tasks/task_translation.c index ec79ebd794..d2e69c4943 100644 --- a/tasks/task_translation.c +++ b/tasks/task_translation.c @@ -1029,14 +1029,12 @@ bool run_translation_service(settings_t *settings, bool paused) RARCH_LOG("Request size: %d\n", bmp64_length); #endif { - size_t _len; char new_ai_service_url[PATH_MAX_LENGTH]; char separator = '?'; unsigned ai_service_source_lang = settings->uints.ai_service_source_lang; unsigned ai_service_target_lang = settings->uints.ai_service_target_lang; const char *ai_service_url = settings->arrays.ai_service_url; - - _len = strlcpy(new_ai_service_url, + size_t _len = strlcpy(new_ai_service_url, ai_service_url, sizeof(new_ai_service_url)); /* if query already exists in url, then use &'s instead */ @@ -1051,14 +1049,14 @@ bool run_translation_service(settings_t *settings, bool paused) if (!string_is_empty(lang_source)) { - new_ai_service_url[_len ] = separator; - new_ai_service_url[_len+1] = '\0'; - strlcat( - new_ai_service_url, "source_lang=", - sizeof(new_ai_service_url)); - _len = strlcat( - new_ai_service_url, lang_source, - sizeof(new_ai_service_url)); + new_ai_service_url[ _len] = separator; + new_ai_service_url[++_len] = '\0'; + _len += strlcpy(new_ai_service_url + _len, + "source_lang=", + sizeof(new_ai_service_url) - _len); + _len += strlcpy(new_ai_service_url + _len, + lang_source, + sizeof(new_ai_service_url) - _len); separator = '&'; } } @@ -1071,52 +1069,56 @@ bool run_translation_service(settings_t *settings, bool paused) if (!string_is_empty(lang_target)) { - new_ai_service_url[_len ] = separator; - new_ai_service_url[_len+1] = '\0'; - strlcat( - new_ai_service_url, "target_lang=", - sizeof(new_ai_service_url)); - _len = strlcat( - new_ai_service_url, lang_target, - sizeof(new_ai_service_url)); + new_ai_service_url[ _len] = separator; + new_ai_service_url[++_len] = '\0'; + _len += strlcpy(new_ai_service_url + _len, + "target_lang=", + sizeof(new_ai_service_url) - _len); + _len += strlcpy(new_ai_service_url + _len, + lang_target, + sizeof(new_ai_service_url) - _len); separator = '&'; } } /* mode */ { - unsigned ai_service_mode = settings->uints.ai_service_mode; + unsigned ai_service_mode = settings->uints.ai_service_mode; /*"image" is included for backwards compatability with * vgtranslate < 1.04 */ - new_ai_service_url[_len ] = separator; - new_ai_service_url[_len+1] = '\0'; - strlcat( - new_ai_service_url, "output=", - sizeof(new_ai_service_url)); + new_ai_service_url[ _len] = separator; + new_ai_service_url[++_len] = '\0'; + _len += strlcpy(new_ai_service_url + _len, + "output=", + sizeof(new_ai_service_url) - _len); switch (ai_service_mode) { case 2: - strlcat(new_ai_service_url, "text", - sizeof(new_ai_service_url)); + _len += strlcpy(new_ai_service_url + _len, + "text", + sizeof(new_ai_service_url) - _len); break; case 1: case 3: - strlcat(new_ai_service_url, "sound,wav", - sizeof(new_ai_service_url)); + _len += strlcpy(new_ai_service_url + _len, + "sound,wav", + sizeof(new_ai_service_url) - _len); if (ai_service_mode == 1) break; /* fall-through intentional for ai_service_mode == 3 */ case 0: - strlcat(new_ai_service_url, "image,png", - sizeof(new_ai_service_url)); + _len += strlcpy(new_ai_service_url + _len, + "image,png", + sizeof(new_ai_service_url) - _len); #ifdef HAVE_GFX_WIDGETS if ( video_st->poke && video_st->poke->load_texture && video_st->poke->unload_texture) - strlcat(new_ai_service_url, ",png-a", - sizeof(new_ai_service_url)); + _len += strlcpy(new_ai_service_url + _len, + ",png-a", + sizeof(new_ai_service_url) - _len); #endif break; default: diff --git a/ui/drivers/qt/qt_playlist.cpp b/ui/drivers/qt/qt_playlist.cpp index 434467bec9..736781e9ee 100644 --- a/ui/drivers/qt/qt_playlist.cpp +++ b/ui/drivers/qt/qt_playlist.cpp @@ -1410,7 +1410,7 @@ QString MainWindow::getPlaylistDefaultCore(QString plName) { size_t len; playlist_config_t playlist_config; - char playlistPath[PATH_MAX_LENGTH]; + char playlist_path[PATH_MAX_LENGTH]; QByteArray plNameByteArray = plName.toUtf8(); const char *plNameCString = plNameByteArray.data(); playlist_t *cachedPlaylist = playlist_get_cached(); @@ -1429,19 +1429,17 @@ QString MainWindow::getPlaylistDefaultCore(QString plName) return corePath; /* Get playlist path */ - len = fill_pathname_join_special( - playlistPath, settings->paths.directory_playlist, - plNameCString, sizeof(playlistPath)); - playlistPath[len ] = '.'; - playlistPath[len+1] = 'l'; - playlistPath[len+2] = 'p'; - playlistPath[len+3] = 'l'; - playlistPath[len+4] = '\0'; + len = fill_pathname_join_special( + playlist_path, settings->paths.directory_playlist, + plNameCString, sizeof(playlist_path)); + strlcpy(playlist_path + len, + ".lpl", + sizeof(playlist_path) - len); /* Load playlist, if required */ if (cachedPlaylist) { - if (string_is_equal(playlistPath, + if (string_is_equal(playlist_path, playlist_get_conf_path(cachedPlaylist))) { playlist = cachedPlaylist; @@ -1451,7 +1449,7 @@ QString MainWindow::getPlaylistDefaultCore(QString plName) if (loadPlaylist) { - playlist_config_set_path(&playlist_config, playlistPath); + playlist_config_set_path(&playlist_config, playlist_path); playlist = playlist_init(&playlist_config); }