Cart_Reader.ino: New variants of print_Error

Tagged with noreturn so the compiler knows about the effect of
forceReset=true.
Ideally, print_Error should lose its forceReset argument so that:
- print_Error never resets
- print_FatalError always resets (and hosts the code doing so)
so the compiler is more accurately aware of the execution flow.
This commit is contained in:
Vincent Pelletier 2022-10-29 01:31:43 +00:00
parent 34981fdb8e
commit 133e3feda9

View File

@ -490,7 +490,7 @@ byte sdBuffer[512];
// soft reset Arduino: jumps to 0 // soft reset Arduino: jumps to 0
// using the watchdog timer would be more elegant but some Mega2560 bootloaders are buggy with it // using the watchdog timer would be more elegant but some Mega2560 bootloaders are buggy with it
void (*resetArduino)(void) = 0; void (*resetArduino)(void) __attribute__ ((noreturn)) = 0;
// Progressbar // Progressbar
void draw_progressbar(uint32_t processedsize, uint32_t totalsize); void draw_progressbar(uint32_t processedsize, uint32_t totalsize);
@ -2005,6 +2005,22 @@ void print_Error(byte errorMessage, boolean forceReset) {
} }
} }
void print_FatalError(const __FlashStringHelper* errorMessage) __attribute__ ((noreturn));
void print_FatalError(const __FlashStringHelper* errorMessage) {
print_Error(errorMessage, true);
// Redundant as print_Error already calls it, but makes gcc understand that
// this in fact does not return.
resetArduino();
}
void print_FatalError(byte errorMessage) __attribute__ ((noreturn));
void print_FatalError(byte errorMessage){
print_Error(errorMessage, true);
// Redundant as print_Error already calls it, but makes gcc understand that
// this in fact does not return.
resetArduino();
}
void wait() { void wait() {
// Switch status LED off // Switch status LED off
statusLED(false); statusLED(false);