diff --git a/gfx/gfx_widgets.c b/gfx/gfx_widgets.c index 0b7940757f..916e5c8ffc 100644 --- a/gfx/gfx_widgets.c +++ b/gfx/gfx_widgets.c @@ -1025,9 +1025,9 @@ static void gfx_widgets_draw_task_msg( if (msg->task_finished) { if (msg->task_error) - strlcpy(task_percentage, "Task failed", sizeof(task_percentage)); + strcpy_literal(task_percentage, "Task failed"); else - strlcpy(task_percentage, " ", sizeof(task_percentage)); + strcpy_literal(task_percentage, " "); } else if (msg->task_progress >= 0 && msg->task_progress <= 100) snprintf(task_percentage, sizeof(task_percentage), diff --git a/gfx/widgets/gfx_widget_load_content_animation.c b/gfx/widgets/gfx_widget_load_content_animation.c index 3fba4ec6f9..ba4719db70 100644 --- a/gfx/widgets/gfx_widget_load_content_animation.c +++ b/gfx/widgets/gfx_widget_load_content_animation.c @@ -437,8 +437,7 @@ bool gfx_widget_start_load_content_animation(void) sizeof(state->system_name)); /* Otherwise, just use 'RetroArch' as a fallback */ else - strlcpy(state->system_name, "RetroArch", - sizeof(state->system_name)); + strcpy_literal(state->system_name, "RetroArch"); } /* > Content name has been determined @@ -503,8 +502,7 @@ bool gfx_widget_start_load_content_animation(void) state->icon_file[0] = '\0'; icon_path[0] = '\0'; - strlcpy(state->icon_file, "retroarch.png", - sizeof(state->icon_file)); + strcpy_literal(state->icon_file, "retroarch.png"); fill_pathname_join(icon_path, state->icon_directory, state->icon_file, diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index ea0d1c51e4..3dd53c987c 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -1010,7 +1010,7 @@ void fill_pathname_expand_special(char *out_path, retro_assert(src_size < size); out_path += src_size; - size -= src_size; + size -= src_size; } in_path += 2; @@ -1100,8 +1100,7 @@ void fill_pathname_abbreviate_special(char *out_path, if (!PATH_CHAR_IS_SLASH(*in_path)) { - retro_assert(strlcpy(out_path, - PATH_DEFAULT_SLASH(), size) < size); + strcpy_literal(out_path, PATH_DEFAULT_SLASH()); out_path++; size--; } diff --git a/libretro-common/media/media_detect_cd.c b/libretro-common/media/media_detect_cd.c index 9014d7f64b..6985fc7268 100644 --- a/libretro-common/media/media_detect_cd.c +++ b/libretro-common/media/media_detect_cd.c @@ -352,7 +352,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ * but I have not seen any real examples of them. */ info->system_id = MEDIA_CD_SYSTEM_MEGA_CD; - strlcpy(info->system, "Sega CD / Mega CD", sizeof(info->system)); + strcpy_literal(info->system, "Sega CD / Mega CD"); title_pos = buf + offset + 0x150; @@ -362,7 +362,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->title, sizeof(info->title)); } else - strlcpy(info->title, "N/A", sizeof(info->title)); + strcpy_literal(info->title, "N/A"); serial_pos = buf + offset + 0x183; @@ -372,7 +372,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->serial, sizeof(info->serial)); } else - strlcpy(info->serial, "N/A", sizeof(info->serial)); + strcpy_literal(info->serial, "N/A"); } else if (!memcmp(buf + offset, "SEGA SEGASATURN", STRLEN_CONST("SEGA SEGASATURN"))) @@ -387,7 +387,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ info->system_id = MEDIA_CD_SYSTEM_SATURN; - strlcpy(info->system, "Sega Saturn", sizeof(info->system)); + strcpy_literal(info->system, "Sega Saturn"); title_pos = buf + offset + 0x60; @@ -397,7 +397,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->title, sizeof(info->title)); } else - strlcpy(info->title, "N/A", sizeof(info->title)); + strcpy_literal(info->title, "N/A"); serial_pos = buf + offset + 0x20; @@ -407,7 +407,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->serial, sizeof(info->serial)); } else - strlcpy(info->serial, "N/A", sizeof(info->serial)); + strcpy_literal(info->serial, "N/A"); version_pos = buf + offset + 0x2a; @@ -417,7 +417,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->version, sizeof(info->version)); } else - strlcpy(info->version, "N/A", sizeof(info->version)); + strcpy_literal(info->version, "N/A"); release_date_pos = buf + offset + 0x30; @@ -427,7 +427,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->release_date, sizeof(info->release_date)); } else - strlcpy(info->release_date, "N/A", sizeof(info->release_date)); + strcpy_literal(info->release_date, "N/A"); } else if (!memcmp(buf + offset, "SEGA SEGAKATANA", STRLEN_CONST("SEGA SEGAKATANA"))) { @@ -441,7 +441,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ info->system_id = MEDIA_CD_SYSTEM_DREAMCAST; - strlcpy(info->system, "Sega Dreamcast", sizeof(info->system)); + strcpy_literal(info->system, "Sega Dreamcast"); title_pos = buf + offset + 0x80; @@ -451,7 +451,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->title, sizeof(info->title)); } else - strlcpy(info->title, "N/A", sizeof(info->title)); + strcpy_literal(info->title, "N/A"); serial_pos = buf + offset + 0x40; @@ -461,7 +461,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->serial, sizeof(info->serial)); } else - strlcpy(info->serial, "N/A", sizeof(info->serial)); + strcpy_literal(info->serial, "N/A"); version_pos = buf + offset + 0x4a; @@ -471,7 +471,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->version, sizeof(info->version)); } else - strlcpy(info->version, "N/A", sizeof(info->version)); + strcpy_literal(info->version, "N/A"); release_date_pos = buf + offset + 0x50; @@ -481,7 +481,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->release_date, sizeof(info->release_date)); } else - strlcpy(info->release_date, "N/A", sizeof(info->release_date)); + strcpy_literal(info->release_date, "N/A"); } /* Primary Volume Descriptor fields of ISO9660 */ else if (!memcmp(buf + offset + (16 * sector_size), "\1CD001\1\0PLAYSTATION", 19)) @@ -493,7 +493,7 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ info->system_id = MEDIA_CD_SYSTEM_PSX; - strlcpy(info->system, "Sony PlayStation", sizeof(info->system)); + strcpy_literal(info->system, "Sony PlayStation"); title_pos = buf + offset + (16 * sector_size) + 40; @@ -503,19 +503,19 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_ media_zero_trailing_spaces(info->title, sizeof(info->title)); } else - strlcpy(info->title, "N/A", sizeof(info->title)); + strcpy_literal(info->title, "N/A"); } else if (!memcmp(buf + offset, "\x01\x5a\x5a\x5a\x5a\x5a\x01\x00\x00\x00\x00\x00", 12)) { info->system_id = MEDIA_CD_SYSTEM_3DO; - strlcpy(info->system, "3DO", sizeof(info->system)); + strcpy_literal(info->system, "3DO"); } else if (!memcmp(buf + offset + 0x950, "PC Engine CD-ROM SYSTEM", 23)) { info->system_id = MEDIA_CD_SYSTEM_PC_ENGINE_CD; - strlcpy(info->system, "TurboGrafx-CD / PC-Engine CD", sizeof(info->system)); + strcpy_literal(info->system, "TurboGrafx-CD / PC-Engine CD"); } free(buf); diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index f46c9cd978..6dc332f8b5 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -412,7 +412,7 @@ static void menu_action_setting_disp_set_label_menu_file_core( char *s2, size_t len2) { const char *alt = NULL; - strlcpy(s, "(CORE)", len); + strcpy_literal(s, "(CORE)"); menu_entries_get_at_offset(list, i, NULL, NULL, NULL, NULL, &alt); @@ -463,12 +463,12 @@ static void menu_action_setting_disp_set_label_core_updater_entry( /* Highlight locked cores */ if (core_info.inf->is_locked) { - strlcpy(s, "[#!]", len); + strcpy_literal(s, "[#!]"); *w = (unsigned)STRLEN_CONST("[#!]"); } else { - strlcpy(s, "[#]", len); + strcpy_literal(s, "[#]"); *w = (unsigned)STRLEN_CONST("[#]"); } } @@ -506,7 +506,7 @@ static void menu_action_setting_disp_set_label_core_manager_entry( if (core_info_find(&core_info) && core_info.inf->is_locked) { - strlcpy(s, "[!]", len); + strcpy_literal(s, "[!]"); *w = (unsigned)STRLEN_CONST("[!]"); } } @@ -571,7 +571,7 @@ static void menu_action_setting_disp_set_label_input_desc( descriptor = runloop_get_system_info()->input_desc_btn[user_idx][remap_idx]; - strlcpy(s, "---", len); + strcpy_literal(s, "---"); if (!string_is_empty(descriptor)) { @@ -622,7 +622,7 @@ static void menu_action_setting_disp_set_label_input_desc_kbd( strlcpy(s, desc, len); } else - strlcpy(s, "---", len); + strcpy_literal(s, "---"); *w = 19; strlcpy(s2, path, len2); @@ -885,7 +885,7 @@ static void menu_action_setting_disp_set_label_menu_video_resolution( { #ifdef GEKKO if (width == 0 || height == 0) - strlcpy(s, "DEFAULT", len); + strcpy_literal(s, "DEFAULT"); else #endif snprintf(s, len, "%ux%u", width, height); @@ -1130,10 +1130,10 @@ static void menu_action_setting_disp_set_label_core_option_create( *s = '\0'; *w = 19; - strlcpy(s, "", len); + strcpy_literal(s, ""); if (!string_is_empty(path_get(RARCH_PATH_BASENAME))) - strlcpy(s, path_basename(path_get(RARCH_PATH_BASENAME)), len); + strlcpy(s, path_basename(path_get(RARCH_PATH_BASENAME)), len); strlcpy(s2, path, len2); } diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 663b3bf9d1..d4c5f2fe90 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -4574,7 +4574,7 @@ static int action_ok_download_generic(const char *path, path = "shaders_cg.zip"; break; case MENU_ENUM_LABEL_CB_CORE_THUMBNAILS_DOWNLOAD: - strlcpy(s, "http://thumbnailpacks.libretro.com", sizeof(s)); + strcpy_literal(s, "http://thumbnailpacks.libretro.com"); break; default: strlcpy(s, network_buildbot_url, sizeof(s)); @@ -4898,8 +4898,8 @@ static int action_ok_add_to_favorites(const char *path, if (string_is_empty(core_path) || string_is_empty(core_name)) { - strlcpy(core_path, "DETECT", sizeof(core_path)); - strlcpy(core_name, "DETECT", sizeof(core_name)); + strcpy_literal(core_path, "DETECT"); + strcpy_literal(core_name, "DETECT"); } /* > crc32 + db_name */ @@ -6341,7 +6341,7 @@ static int action_ok_video_resolution(const char *path, video_driver_set_video_mode(width, height, true); #ifdef GEKKO if (width == 0 || height == 0) - strlcpy(msg, "Applying: DEFAULT", sizeof(msg)); + strcpy_literal(msg, "Applying: DEFAULT"); else #endif snprintf(msg, sizeof(msg), diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 322cb573f3..f38523bdf0 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4204,10 +4204,13 @@ static int menu_displaylist_parse_input_description_kbd_list(menu_displaylist_in /* TODO/FIXME: Localise 'Keyboard' */ if (key_id == RETROK_FIRST) - strlcpy(input_description, "---", sizeof(input_description)); + strcpy_literal(input_description, "---"); else - snprintf(input_description, sizeof(input_description), - "Keyboard %s", key_label); + { + strcpy_literal(input_description, "Keyboard "); + strlcat(input_description, key_label, + sizeof(input_description)); + } /* Add menu entry */ if (menu_entries_append_enum(info->list, @@ -8866,7 +8869,7 @@ unsigned menu_displaylist_netplay_refresh_rooms(file_list_t *list) if (*netplay_room_list[i].country) { - strlcpy(country, "(", sizeof(country)); + strcpy_literal(country, "("); strlcat(country, netplay_room_list[i].country, sizeof(country)); strlcat(country, ")", sizeof(country)); @@ -9299,7 +9302,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, title[0] = '\0'; - strlcpy(title, "Title: ", sizeof(title)); + strcpy_literal(title, "Title: "); strlcat(title, cd_info.title, sizeof(title)); if (menu_entries_append_enum(info->list, @@ -9316,7 +9319,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, system[0] = '\0'; - strlcpy(system, "System: ", sizeof(system)); + strcpy_literal(system, "System: "); strlcat(system, cd_info.system, sizeof(system)); if (menu_entries_append_enum(info->list, @@ -9368,7 +9371,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, release_date[0] = '\0'; - strlcpy(release_date, "Release Date: ", sizeof(release_date)); + strcpy_literal(release_date, "Release Date: "); strlcat(release_date, cd_info.release_date, sizeof(release_date)); if (menu_entries_append_enum(info->list, @@ -9537,7 +9540,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, fgets(current_profile, PATH_MAX_LENGTH, profile); pclose(profile); - strlcpy(text, "Current profile : ", sizeof(text)); + strcpy_literal(text, "Current profile : "); strlcat(text, current_profile, sizeof(text)); #else u32 currentClock = 0; @@ -9599,7 +9602,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); - strlcpy(text, "Current profile : ", sizeof(text)); + strcpy_literal(text, "Current profile : "); strlcat(text, current_profile, sizeof(text)); if (menu_entries_append_enum(info->list, text, "", 0, MENU_INFO_MESSAGE, 0, 0)) @@ -11921,7 +11924,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, strlcat(ext_names, FILE_PATH_CORE_BACKUP_EXTENSION_NO_DOT, sizeof(ext_names)); } else - strlcpy(ext_names, FILE_PATH_CORE_BACKUP_EXTENSION_NO_DOT, sizeof(ext_names)); + strcpy_literal(ext_names, FILE_PATH_CORE_BACKUP_EXTENSION_NO_DOT); info->exts = strdup(ext_names); } diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 946da4877d..071d40f291 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1142,7 +1142,7 @@ int setting_generic_action_start_default(rarch_setting_t *setting) static void setting_get_string_representation_default(rarch_setting_t *setting, char *s, size_t len) { - strlcpy(s, "...", len); + strcpy_literal(s, "..."); } /** @@ -2767,10 +2767,10 @@ static void setting_get_string_representation_streaming_mode( switch (*setting->value.target.unsigned_integer) { case STREAMING_MODE_TWITCH: - strlcpy(s, "Twitch", len); + strcpy_literal(s, "Twitch"); break; case STREAMING_MODE_YOUTUBE: - strlcpy(s, "YouTube", len); + strcpy_literal(s, "YouTube"); break; case STREAMING_MODE_LOCAL: strlcpy(s, "Local", len); @@ -2892,12 +2892,12 @@ static void setting_get_string_representation_cheevos_password( return; if (!string_is_empty(setting->value.target.string)) - strlcpy(s, "********", len); + strcpy_literal(s, "********"); else { settings_t *settings = config_get_ptr(); if (settings->arrays.cheevos_token[0]) - strlcpy(s, "********", len); + strcpy_literal(s, "********"); else *setting->value.target.string = '\0'; } @@ -2918,13 +2918,13 @@ static void setting_get_string_representation_uint_keyboard_gamepad_mapping_type strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NONE), len); break; case 1: - strlcpy(s, "iPega PG-9017", len); + strcpy_literal(s, "iPega PG-9017"); break; case 2: - strlcpy(s, "8-bitty", len); + strcpy_literal(s, "8-bitty"); break; case 3: - strlcpy(s, "SNES30 8bitdo", len); + strcpy_literal(s, "SNES30 8bitdo"); break; } } @@ -3414,13 +3414,13 @@ static void setting_get_string_representation_uint_menu_timedate_date_separator( switch (*setting->value.target.unsigned_integer) { case MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN: - strlcpy(s, "'-'", len); + strcpy_literal(s, "'-'"); break; case MENU_TIMEDATE_DATE_SEPARATOR_SLASH: - strlcpy(s, "'/'", len); + strcpy_literal(s, "'/'"); break; case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD: - strlcpy(s, "'.'", len); + strcpy_literal(s, "'.'"); break; } } @@ -3963,13 +3963,13 @@ static void setting_get_string_representation_uint_menu_xmb_animation_horizontal switch (*setting->value.target.unsigned_integer) { case 0: - strlcpy(s, "Easing Out Quad", len); + strcpy_literal(s, "Easing Out Quad"); break; case 1: - strlcpy(s, "Easing In Sine", len); + strcpy_literal(s, "Easing In Sine"); break; case 2: - strlcpy(s, "Easing Out Bounce", len); + strcpy_literal(s, "Easing Out Bounce"); break; } } @@ -4071,13 +4071,13 @@ static void setting_get_string_representation_uint_xmb_layout( switch (*setting->value.target.unsigned_integer) { case 0: - strlcpy(s, "Auto", len); + strcpy_literal(s, "Auto"); break; case 1: - strlcpy(s, "Console", len); + strcpy_literal(s, "Console"); break; case 2: - strlcpy(s, "Handheld", len); + strcpy_literal(s, "Handheld"); break; } } diff --git a/retroarch.c b/retroarch.c index bb60adccd0..4f8661a899 100644 --- a/retroarch.c +++ b/retroarch.c @@ -8220,7 +8220,7 @@ static bool menu_shader_manager_save_preset_internal( } else { - strlcpy(fullname, "retroarch", sizeof(fullname)); + strcpy_literal(fullname, "retroarch"); strlcat(fullname, video_shader_get_preset_extension(type), sizeof(fullname)); } @@ -8331,7 +8331,7 @@ static bool menu_shader_manager_operate_auto_preset( switch (type) { case SHADER_PRESET_GLOBAL: - strlcpy(file, "global", sizeof(file)); + strcpy_literal(file, "global"); break; case SHADER_PRESET_CORE: fill_pathname_join(file, core_name, core_name, sizeof(file));