nyx: emu/emmc tools: homogenize return values

This commit is contained in:
CTCaer
2026-02-22 04:24:01 +02:00
parent 520bc8cbfb
commit 0b707ac1ae
2 changed files with 72 additions and 75 deletions

View File

@@ -380,7 +380,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
}
sd_sector_off = sector_start + (0x2000 * active_part);
if (active_part == 2)
@@ -424,7 +424,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
}
}
// Check if we are continuing a previous raw eMMC or USER partition backup in progress.
@@ -447,7 +447,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
}
// Increase maxSplitParts to accommodate previously backed up parts.
@@ -485,7 +485,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
if (!(btn_wait() & BTN_POWER))
{
lv_obj_del(warn_mbox_bg);
return 0;
return 1;
}
lv_obj_del(warn_mbox_bg);
}
@@ -502,7 +502,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
}
u8 *buf = (u8 *)MIXD_BUF_ALIGNED;
@@ -553,7 +553,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
strcpy(gui->txt_buf, "\n#FFDD00 Please try again...#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
case VERIF_STATUS_ABORT:
verification = 0;
break;
@@ -580,7 +580,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
}
// More parts to backup that do not currently fit the sd card free space or fatal error.
@@ -596,7 +596,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
partial_sd_full_unmount = true;
return 1;
return 0;
}
}
@@ -615,7 +615,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
}
bytesWritten = 0;
@@ -663,7 +663,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
free(clmt);
f_unlink(outFilename);
return 0;
return 1;
}
else
{
@@ -686,7 +686,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
free(clmt);
f_unlink(outFilename);
return 0;
return 1;
}
manual_system_maintenance(false);
@@ -725,7 +725,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
free(clmt);
f_unlink(outFilename);
return 0;
return 1;
}
}
lv_bar_set_value(gui->bar, 100);
@@ -745,7 +745,7 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
}
lv_bar_set_value(gui->bar, 100);
lv_label_set_text(gui->label_pct, " "SYMBOL_DOT" 100%");
@@ -764,12 +764,12 @@ static int _dump_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_part,
partial_sd_full_unmount = true;
}
return 1;
return 0;
}
void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui)
{
int res = 0;
int res = 1;
u32 timer = 0;
char *txt_buf = (char *)malloc(SZ_16K);
@@ -844,7 +844,7 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui)
res = _dump_emmc_part(gui, sdPath, i, &emmc_storage, &bootPart);
if (!res)
if (res)
strcpy(txt_buf, "#FFDD00 Failed!#\n");
else
strcpy(txt_buf, "Done!\n");
@@ -884,7 +884,7 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui)
emmcsn_path_impl(sdPath, "/partitions", part->name, &emmc_storage);
res = _dump_emmc_part(gui, sdPath, 0, &emmc_storage, part);
// If a part failed, don't continue.
if (!res)
if (res)
{
strcpy(txt_buf, "#FFDD00 Failed!#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
@@ -927,7 +927,7 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui)
res = _dump_emmc_part(gui, sdPath, 2, &emmc_storage, &rawPart);
if (!res)
if (res)
strcpy(txt_buf, "#FFDD00 Failed!#\n");
else
strcpy(txt_buf, "Done!\n");
@@ -941,9 +941,9 @@ void dump_emmc_selected(emmcPartType_t dumpType, emmc_tool_gui_t *gui)
timer = get_tmr_s() - timer;
emmc_end();
if (res && n_cfg.verification && !gui->raw_emummc)
if (!res && n_cfg.verification && !gui->raw_emummc)
s_printf(txt_buf, "Time taken: %dm %ds.\n#96FF00 Finished and verified!#", timer / 60, timer % 60);
else if (res)
else if (!res)
s_printf(txt_buf, "Time taken: %dm %ds.\nFinished!", timer / 60, timer % 60);
else
s_printf(txt_buf, "Time taken: %dm %ds.", timer / 60, timer % 60);
@@ -1027,13 +1027,13 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
}
else if (f_stat(outFilename, &fno))
{
if (!gui->raw_emummc)
{
s_printf(gui->txt_buf, "\n#FFDD00 Error (%d) file not found#\n#FFDD00 %s.#\n\n", res, outFilename);
s_printf(gui->txt_buf, "\n#FFDD00 Error file not found#\n#FFDD00 %s.#\n\n", outFilename);
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
@@ -1056,7 +1056,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
}
}
else
@@ -1069,7 +1069,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
}
check_4MB_aligned = false;
@@ -1097,7 +1097,7 @@ static int _restore_emmc_part(emmc_tool_gui_t *gui, char *sd_path, int active_pa
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
}
lv_obj_del(warn_mbox_bg);
@@ -1143,7 +1143,7 @@ multipart_not_allowed:
manual_system_maintenance(true);
}
return -1;
return 2;
}
else if (!use_multipart && (((u32)((u64)f_size(&fp) >> (u64)9)) != totalSectors)) // Check total restore size vs emmc size.
{
@@ -1155,7 +1155,7 @@ multipart_not_allowed:
f_close(&fp);
return 0;
return 1;
}
else if (!gui->raw_emummc)
{
@@ -1174,7 +1174,7 @@ multipart_not_allowed:
f_close(&fp);
return 0;
return 1;
}
lv_obj_del(warn_mbox_bg);
}
@@ -1216,7 +1216,7 @@ multipart_not_allowed:
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
}
sd_sector_off = sector_start + (0x2000 * active_part);
}
@@ -1246,7 +1246,7 @@ multipart_not_allowed:
strcpy(gui->txt_buf, "\n#FFDD00 Please try again...#\n");
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
case VERIF_STATUS_ABORT:
verification = 0;
break;
@@ -1275,7 +1275,7 @@ multipart_not_allowed:
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
}
fileSize = (u64)f_size(&fp);
bytesWritten = 0;
@@ -1299,7 +1299,7 @@ multipart_not_allowed:
f_close(&fp);
free(clmt);
return 0;
return 1;
}
if (!gui->raw_emummc)
res = !sdmmc_storage_write(storage, lba_curr, num, buf);
@@ -1328,7 +1328,7 @@ multipart_not_allowed:
f_close(&fp);
free(clmt);
return 0;
return 1;
}
else
{
@@ -1373,7 +1373,7 @@ multipart_not_allowed:
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, gui->txt_buf);
manual_system_maintenance(true);
return 0;
return 1;
}
lv_bar_set_value(gui->bar, 100);
lv_label_set_text(gui->label_pct, " "SYMBOL_DOT" 100%");
@@ -1397,7 +1397,7 @@ multipart_not_allowed:
save_emummc_cfg(part_idx, sector_start, sdPath);
}
return 1;
return 0;
}
void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui)
@@ -1512,15 +1512,14 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui)
emmcsn_path_impl(sdPath, "/restore/emummc", bootPart.name, &emmc_storage);
res = _restore_emmc_part(gui, sdPath, i, &emmc_storage, &bootPart, false);
if (!res)
if (res == 1)
strcpy(txt_buf, "#FFDD00 Failed!#\n");
else if (res > 0)
else if (!res)
strcpy(txt_buf, "Done!\n");
if (res >= 0)
if (res <= 1)
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
else
res = 0;
manual_system_maintenance(true);
}
}
@@ -1548,15 +1547,14 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui)
emmcsn_path_impl(sdPath, "/restore/partitions", part->name, &emmc_storage);
res = _restore_emmc_part(gui, sdPath, 0, &emmc_storage, part, false);
if (!res)
if (res == 1)
strcpy(txt_buf, "#FFDD00 Failed!#\n");
else if (res > 0)
else if (!res)
strcpy(txt_buf, "Done!\n");
if (res >= 0)
if (res <= 1)
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
else
res = 0;
manual_system_maintenance(true);
}
emmc_gpt_free(&gpt);
@@ -1587,15 +1585,14 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui)
emmcsn_path_impl(sdPath, "/restore/emummc", rawPart.name, &emmc_storage);
res = _restore_emmc_part(gui, sdPath, 2, &emmc_storage, &rawPart, true);
if (!res)
if (res == 1)
strcpy(txt_buf, "#FFDD00 Failed!#\n");
else if (res > 0)
else if (!res)
strcpy(txt_buf, "Done!\n");
if (res >= 0)
if (res <= 1)
lv_label_ins_text(gui->label_log, LV_LABEL_POS_LAST, txt_buf);
else
res = 0;
manual_system_maintenance(true);
}
}
@@ -1603,9 +1600,9 @@ void restore_emmc_selected(emmcPartType_t restoreType, emmc_tool_gui_t *gui)
timer = get_tmr_s() - timer;
emmc_end();
if (res && n_cfg.verification && !gui->raw_emummc)
if (!res && n_cfg.verification && !gui->raw_emummc)
s_printf(txt_buf, "Time taken: %dm %ds.\n#96FF00 Finished and verified!#", timer / 60, timer % 60);
else if (res)
else if (!res)
s_printf(txt_buf, "Time taken: %dm %ds.\nFinished!", timer / 60, timer % 60);
else
s_printf(txt_buf, "Time taken: %dm %ds.", timer / 60, timer % 60);