From fdc7ef62f7d26e9892c8399938cdba7208f03f9b Mon Sep 17 00:00:00 2001 From: hexkyz Date: Fri, 26 Jun 2020 18:36:30 +0100 Subject: [PATCH] fusee: handle case where saving a fatal report fails (thanks @HookedBehemoth) --- fusee/fusee-primary/src/panic.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fusee/fusee-primary/src/panic.c b/fusee/fusee-primary/src/panic.c index e7b206f33..ff7f7064b 100644 --- a/fusee/fusee-primary/src/panic.c +++ b/fusee/fusee-primary/src/panic.c @@ -90,12 +90,15 @@ static void _check_and_display_atmosphere_fatal_error(void) { char filepath[0x40]; snprintf(filepath, sizeof(filepath) - 1, "/atmosphere/fatal_errors/report_%016llx.bin", ctx.report_identifier); filepath[sizeof(filepath)-1] = 0; - write_to_file(&ctx, sizeof(ctx), filepath); - print(SCREEN_LOG_LEVEL_ERROR | SCREEN_LOG_LEVEL_NO_PREFIX,"Report saved to %s\n", filepath); + if (write_to_file(&ctx, sizeof(ctx), filepath) != sizeof(ctx)) { + print(SCREEN_LOG_LEVEL_ERROR | SCREEN_LOG_LEVEL_NO_PREFIX, "Failed to save report to the SD card!\n"); + } else { + print(SCREEN_LOG_LEVEL_ERROR | SCREEN_LOG_LEVEL_NO_PREFIX, "Report saved to %s\n", filepath); + } } /* Display error. */ - print(SCREEN_LOG_LEVEL_ERROR | SCREEN_LOG_LEVEL_NO_PREFIX,"\nPress POWER to reboot\n"); + print(SCREEN_LOG_LEVEL_ERROR | SCREEN_LOG_LEVEL_NO_PREFIX, "\nPress POWER to reboot\n"); } /* Wait for button and reboot. */