1
0
Fork 0
mirror of https://github.com/CTCaer/hekate.git synced 2024-11-22 18:06:40 +00:00

Simplify string ops with already compiled-in functions

This commit is contained in:
CTCaer 2019-12-04 15:56:53 +02:00
parent 74452074f6
commit 29a51124fd
14 changed files with 54 additions and 63 deletions

View file

@ -227,8 +227,7 @@ static void _config_autoboot_list(void *ent)
else
boot_text[(i - 1) * 512] = '*';
memcpy(boot_text + (i - 1) * 512 + 1, ini_sec->name, strlen(ini_sec->name) + 1);
boot_text[strlen(ini_sec->name) + (i - 1) * 512 + 1] = 0;
strcpy(boot_text + (i - 1) * 512 + 1, ini_sec->name);
ments[i].caption = &boot_text[(i - 1) * 512];
}
ments[i].type = ini_sec->type;
@ -335,8 +334,7 @@ void config_autoboot()
else
boot_text[(i - 4) * 512] = '*';
memcpy(boot_text + (i - 4) * 512 + 1, ini_sec->name, strlen(ini_sec->name) + 1);
boot_text[strlen(ini_sec->name) + (i - 4) * 512 + 1] = 0;
strcpy(boot_text + (i - 4) * 512 + 1, ini_sec->name);
ments[i].caption = &boot_text[(i - 4) * 512];
}
ments[i].type = ini_sec->type;
@ -421,7 +419,7 @@ void config_bootdelay()
else
delay_text[i * 32] = '*';
delay_text[i * 32 + 1] = i + '0';
memcpy(delay_text + i * 32 + 2, " seconds", 9);
strcpy(delay_text + i * 32 + 2, " seconds");
ments[i + 2].type = MENT_DATA;
ments[i + 2].caption = delay_text + i * 32;
@ -468,9 +466,9 @@ void config_verification()
ments[1].type = MENT_CHGLINE;
memcpy(vr_text, " Disable (Fastest - Unsafe)", 28);
memcpy(vr_text + 64, " Sparse (Fast - Safe)", 23);
memcpy(vr_text + 128, " Full (Slow - Safe)", 23);
strcpy(vr_text, " Disable (Fastest - Unsafe)");
strcpy(vr_text + 64, " Sparse (Fast - Safe)");
strcpy(vr_text + 128, " Full (Slow - Safe)");
for (u32 i = 0; i < 3; i++)
{
@ -530,10 +528,10 @@ void config_backlight()
if (i < 10)
{
bri_text[i * 32 + 1] = i + '0';
memcpy(bri_text + i * 32 + 2, "0%", 3);
strcpy(bri_text + i * 32 + 2, "0%");
}
else
memcpy(bri_text + i * 32 + 1, "100%", 5);
strcpy(bri_text + i * 32 + 1, "100%");
ments[i + 1].type = MENT_DATA;
ments[i + 1].caption = bri_text + i * 32;

View file

@ -78,7 +78,7 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir)
char *filename = (char *)malloc(256);
memcpy(filename, ini_path, pathlen + 1);
strcpy(filename, ini_path);
// Get all ini filenames.
if (is_dir)
@ -89,7 +89,7 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir)
free(filename);
return 0;
}
memcpy(filename + pathlen, "/", 2);
strcpy(filename + pathlen, "/");
pathlen++;
}
@ -100,7 +100,7 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir)
{
if (filelist[k * 256])
{
memcpy(filename + pathlen, &filelist[k * 256], strlen(&filelist[k * 256]) + 1);
strcpy(filename + pathlen, &filelist[k * 256]);
k++;
}
else

View file

@ -185,7 +185,7 @@ static int _dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t
FIL partialIdxFp;
char partialIdxFilename[12];
memcpy(partialIdxFilename, "partial.idx", 12);
strcpy(partialIdxFilename, "partial.idx");
gfx_con.fntsz = 8;
gfx_printf("\nSD Card free space: %d MiB, Total backup size %d MiB\n\n",
@ -203,7 +203,7 @@ static int _dump_emmc_part(char *sd_path, sdmmc_storage_t *storage, emmc_part_t
{
isSmallSdCard = true;
gfx_printf("%k\nSD card free space is smaller than total backup size.%k\n", 0xFFFFBA00, 0xFFCCCCCC);
gfx_printf("%k\nSD card free space is smaller than backup size.%k\n", 0xFFFFBA00, 0xFFCCCCCC);
if (!maxSplitParts)
{
@ -518,7 +518,7 @@ static void _dump_emmc_selected(emmcPartType_t dumpType)
bootPart.lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1;
for (i = 0; i < 2; i++)
{
memcpy(bootPart.name, "BOOT", 5);
strcpy(bootPart.name, "BOOT");
bootPart.name[4] = (u8)('0' + i);
bootPart.name[5] = 0;
@ -874,7 +874,7 @@ static void _restore_emmc_selected(emmcPartType_t restoreType)
bootPart.lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1;
for (i = 0; i < 2; i++)
{
memcpy(bootPart.name, "BOOT", 4);
strcpy(bootPart.name, "BOOT");
bootPart.name[4] = (u8)('0' + i);
bootPart.name[5] = 0;

View file

@ -201,40 +201,33 @@ void print_mmc_info()
gfx_printf("%kExtended CSD V1.%d:%k\n",
0xFF00DDFF, storage.ext_csd.ext_struct, 0xFFCCCCCC);
card_type = storage.ext_csd.card_type;
u8 card_type_support[96];
u8 pos_type = 0;
char card_type_support[96];
card_type_support[0] = 0;
if (card_type & EXT_CSD_CARD_TYPE_HS_26)
{
memcpy(card_type_support, "HS26", 4);
strcat(card_type_support, "HS26");
speed = (26 << 16) | 26;
pos_type += 4;
}
if (card_type & EXT_CSD_CARD_TYPE_HS_52)
{
memcpy(card_type_support + pos_type, ", HS52", 6);
strcat(card_type_support, ", HS52");
speed = (52 << 16) | 52;
pos_type += 6;
}
if (card_type & EXT_CSD_CARD_TYPE_DDR_1_8V)
{
memcpy(card_type_support + pos_type, ", DDR52_1.8V", 12);
strcat(card_type_support, ", DDR52_1.8V");
speed = (52 << 16) | 104;
pos_type += 12;
}
if (card_type & EXT_CSD_CARD_TYPE_HS200_1_8V)
{
memcpy(card_type_support + pos_type, ", HS200_1.8V", 12);
strcat(card_type_support, ", HS200_1.8V");
speed = (200 << 16) | 200;
pos_type += 12;
}
if (card_type & EXT_CSD_CARD_TYPE_HS400_1_8V)
{
memcpy(card_type_support + pos_type, ", HS400_1.8V", 12);
strcat(card_type_support, ", HS400_1.8V");
speed = (200 << 16) | 400;
pos_type += 12;
}
card_type_support[pos_type] = 0;
gfx_printf(
" Spec Version: %02X\n"

View file

@ -480,13 +480,13 @@ void _fix_sd_attr(u32 type)
switch (type)
{
case 0:
memcpy(path, "/", 2);
memcpy(label, "SD Card", 8);
strcpy(path, "/");
strcpy(label, "SD Card");
break;
case 1:
default:
memcpy(path, "/Nintendo", 10);
memcpy(label, "Nintendo folder", 16);
strcpy(path, "/Nintendo");
strcpy(label, "Nintendo folder");
break;
}

View file

@ -65,13 +65,13 @@ static int _config_kip1(launch_ctxt_t *ctxt, const char *value)
if (!memcmp(value + strlen(value) - 1, "*", 1))
{
char *dir = (char *)malloc(256);
memcpy(dir, value, strlen(value) + 1);
strcpy(dir, value);
u32 dirlen = 0;
dir[strlen(dir) - 2] = 0;
char *filelist = dirlist(dir, "*.kip*", false);
memcpy(dir + strlen(dir), "/", 2);
strcat(dir, "/");
dirlen = strlen(dir);
u32 i = 0;
@ -82,7 +82,7 @@ static int _config_kip1(launch_ctxt_t *ctxt, const char *value)
if (!filelist[i * 256])
break;
memcpy(dir + dirlen, &filelist[i * 256], strlen(&filelist[i * 256]) + 1);
strcpy(dir + dirlen, &filelist[i * 256]);
merge_kip_t *mkip1 = (merge_kip_t *)malloc(sizeof(merge_kip_t));
mkip1->kip1 = sd_file_read(dir, &size);

View file

@ -271,10 +271,10 @@ void secmon_exo_check_panic()
// Save context to the SD card.
char filepath[0x40];
f_mkdir("atmosphere/fatal_errors");
memcpy(filepath, "/atmosphere/fatal_errors/report_", 33);
strcpy(filepath, "/atmosphere/fatal_errors/report_");
itoa((u32)((u64)rpt->report_identifier >> 32), filepath + strlen(filepath), 16);
itoa((u32)(rpt->report_identifier), filepath + strlen(filepath), 16);
memcpy(filepath + strlen(filepath), ".bin", 5);
strcat(filepath, ".bin");
sd_save_to_file((void *)rpt, sizeof(atm_fatal_error_ctx), filepath);

View file

@ -42,7 +42,7 @@ char *dirlist(const char *directory, const char *pattern, bool includeHiddenFile
break;
if (!(fno.fattrib & AM_DIR) && (fno.fname[0] != '.') && (includeHiddenFiles || !(fno.fattrib & AM_HID)))
{
memcpy(dir_entries + (k * 256), fno.fname, strlen(fno.fname) + 1);
strcpy(dir_entries + (k * 256), fno.fname);
k++;
if (k > (max_entries - 1))
break;
@ -56,7 +56,7 @@ char *dirlist(const char *directory, const char *pattern, bool includeHiddenFile
{
if (!(fno.fattrib & AM_DIR) && (fno.fname[0] != '.') && (includeHiddenFiles || !(fno.fattrib & AM_HID)))
{
memcpy(dir_entries + (k * 256), fno.fname, strlen(fno.fname) + 1);
strcpy(dir_entries + (k * 256), fno.fname);
k++;
if (k > (max_entries - 1))
break;
@ -81,9 +81,9 @@ char *dirlist(const char *directory, const char *pattern, bool includeHiddenFile
{
if (strcmp(&dir_entries[i * 256], &dir_entries[j * 256]) > 0)
{
memcpy(temp, &dir_entries[i * 256], strlen(&dir_entries[i * 256]) + 1);
memcpy(&dir_entries[i * 256], &dir_entries[j * 256], strlen(&dir_entries[j * 256]) + 1);
memcpy(&dir_entries[j * 256], temp, strlen(temp) + 1);
strcpy(temp, &dir_entries[i * 256]);
strcpy(&dir_entries[i * 256], &dir_entries[j * 256]);
strcpy(&dir_entries[j * 256], temp);
}
}
}

View file

@ -78,7 +78,7 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir)
char *filename = (char *)malloc(256);
memcpy(filename, ini_path, pathlen + 1);
strcpy(filename, ini_path);
// Get all ini filenames.
if (is_dir)
@ -89,7 +89,7 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir)
free(filename);
return 0;
}
memcpy(filename + pathlen, "/", 2);
strcpy(filename + pathlen, "/");
pathlen++;
}
@ -100,7 +100,7 @@ int ini_parse(link_t *dst, char *ini_path, bool is_dir)
{
if (filelist[k * 256])
{
memcpy(filename + pathlen, &filelist[k * 256], strlen(&filelist[k * 256]) + 1);
strcpy(filename + pathlen, &filelist[k * 256]);
k++;
}
else

View file

@ -363,7 +363,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, sdmmc_storage_t
FIL partialIdxFp;
char partialIdxFilename[12];
memcpy(partialIdxFilename, "partial.idx", 12);
strcpy(partialIdxFilename, "partial.idx");
s_printf(gui->txt_buf, "#96FF00 SD Card free space:# %d MiB\n#96FF00 Total backup size:# %d MiB\n\n",
sd_fs.free_clst * sd_fs.csize >> SECTORS_TO_MIB_COEFF,
@ -769,7 +769,7 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui)
bootPart.lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1;
for (i = 0; i < 2; i++)
{
memcpy(bootPart.name, "BOOT", 5);
strcpy(bootPart.name, "BOOT");
bootPart.name[4] = (u8)('0' + i);
bootPart.name[5] = 0;
@ -1349,7 +1349,7 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui)
bootPart.lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1;
for (i = 0; i < 2; i++)
{
memcpy(bootPart.name, "BOOT", 4);
strcpy(bootPart.name, "BOOT");
bootPart.name[4] = (u8)('0' + i);
bootPart.name[5] = 0;

View file

@ -368,7 +368,7 @@ void dump_emummc_file(emmc_tool_gui_t *gui)
bootPart.lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1;
for (i = 0; i < 2; i++)
{
memcpy(bootPart.name, "BOOT", 5);
strcpy(bootPart.name, "BOOT");
bootPart.name[4] = (u8)('0' + i);
bootPart.name[5] = 0;
@ -623,7 +623,7 @@ void dump_emummc_raw(emmc_tool_gui_t *gui, int part_idx, u32 sector_start)
bootPart.lba_end = (BOOT_PART_SIZE / NX_EMMC_BLOCKSIZE) - 1;
for (i = 0; i < 2; i++)
{
memcpy(bootPart.name, "BOOT", 5);
strcpy(bootPart.name, "BOOT");
bootPart.name[4] = (u8)('0' + i);
bootPart.name[5] = 0;

View file

@ -278,13 +278,13 @@ static lv_res_t _create_window_fuses_info_status(lv_obj_t *btn)
s_printf(dram_man, "Samsung %s", (!dram_id) ? "4GB" : "6GB");
break;
case 1:
memcpy(dram_man, "Hynix 4GB", 10);
strcpy(dram_man, "Hynix 4GB");
break;
case 2:
memcpy(dram_man, "Micron 4GB", 11);
strcpy(dram_man, "Micron 4GB");
break;
default:
memcpy(dram_man, "Unknown", 8);
strcpy(dram_man, "Unknown");
break;
}

View file

@ -277,9 +277,9 @@ static lv_res_t _create_window_unset_abit_tool(lv_obj_t *btn)
u32 total = 0;
if (!nintendo_folder)
memcpy(path, "", 1);
path[0] = 0;
else
memcpy(path, "Nintendo", 9);
strcpy(path, "Nintendo");
u32 ufidx = 0;
@ -288,7 +288,7 @@ static lv_res_t _create_window_unset_abit_tool(lv_obj_t *btn)
// Also fix the emuMMC Nintendo folders.
if (nintendo_folder)
{
memcpy(path, "emuMMC", 7);
strcpy(path, "emuMMC");
_fix_attributes(&ufidx, lb_val, path, &total, nintendo_folder, nintendo_folder);
}

View file

@ -47,7 +47,7 @@ char *dirlist(const char *directory, const char *pattern, bool includeHiddenFile
{
if ((fno.fname[0] != '.') && (includeHiddenFiles || !(fno.fattrib & AM_HID)))
{
memcpy(dir_entries + (k * 256), fno.fname, strlen(fno.fname) + 1);
strcpy(dir_entries + (k * 256), fno.fname);
k++;
if (k > (max_entries - 1))
break;
@ -62,7 +62,7 @@ char *dirlist(const char *directory, const char *pattern, bool includeHiddenFile
{
if (!(fno.fattrib & AM_DIR) && (fno.fname[0] != '.') && (includeHiddenFiles || !(fno.fattrib & AM_HID)))
{
memcpy(dir_entries + (k * 256), fno.fname, strlen(fno.fname) + 1);
strcpy(dir_entries + (k * 256), fno.fname);
k++;
if (k > (max_entries - 1))
break;
@ -87,9 +87,9 @@ char *dirlist(const char *directory, const char *pattern, bool includeHiddenFile
{
if (strcmp(&dir_entries[i * 256], &dir_entries[j * 256]) > 0)
{
memcpy(temp, &dir_entries[i * 256], strlen(&dir_entries[i * 256]) + 1);
memcpy(&dir_entries[i * 256], &dir_entries[j * 256], strlen(&dir_entries[j * 256]) + 1);
memcpy(&dir_entries[j * 256], temp, strlen(temp) + 1);
strcpy(temp, &dir_entries[i * 256]);
strcpy(&dir_entries[i * 256], &dir_entries[j * 256]);
strcpy(&dir_entries[j * 256], temp);
}
}
}