Skip to content

Commit fe32af1

Browse files
SenRamakriadbridge
authored andcommitted
Remove printf completely and fix the optimization check
1 parent 72209e8 commit fe32af1

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

platform/mbed_error.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,24 +210,16 @@ mbed_error_status_t mbed_error_initialize(void)
210210
//Read report_error_ctx and check if CRC is correct, and with valid status code
211211
if ((report_error_ctx->crc_error_ctx == crc_val) && (report_error_ctx->is_error_processed == 0)) {
212212
is_reboot_error_valid = true;
213-
//Report the error info
214-
#ifndef NDEBUG
215-
printf("\n== The system has been rebooted due to a fatal error. ==\n");
216-
#endif
217213

218214
//Call the mbed_error_reboot_callback, this enables applications to do some handling before we do the handling
219215
mbed_error_reboot_callback(report_error_ctx);
220216

221217
//We let the callback reset the error info, so check if its still valid and do the rest only if its still valid.
222-
if (report_error_ctx->error_reboot_count < 0) {
218+
if (report_error_ctx->error_reboot_count > 0) {
223219

224220
//Enforce max-reboot only if auto reboot is enabled
225221
#if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED
226222
if (report_error_ctx->error_reboot_count >= MBED_CONF_PLATFORM_ERROR_REBOOT_MAX) {
227-
//We have rebooted more than enough, hold the system here.
228-
#ifndef NDEBUG
229-
printf("\n== Reboot count(=%ld) exceeded maximum, system halting ==\n", report_error_ctx->error_reboot_count);
230-
#endif
231223
mbed_halt_system();
232224
}
233225
#endif
@@ -299,6 +291,11 @@ WEAK MBED_NORETURN mbed_error_status_t mbed_error(mbed_error_status_t error_stat
299291
core_util_critical_section_exit();
300292
//We need not call delete_mbed_crc(crc_obj) here as we are going to reset the system anyway, and calling delete while handling a fatal error may cause nested exception
301293
#if MBED_CONF_PLATFORM_FATAL_ERROR_AUTO_REBOOT_ENABLED && (MBED_CONF_PLATFORM_ERROR_REBOOT_MAX > 0)
294+
mbed_error_printf("\n= System will be rebooted due to a fatal error =\n");
295+
if (report_error_ctx->error_reboot_count >= MBED_CONF_PLATFORM_ERROR_REBOOT_MAX) {
296+
//We have rebooted more than enough, hold the system here.
297+
mbed_error_printf("= Reboot count(=%ld) reached maximum, system will halt after rebooting =\n", report_error_ctx->error_reboot_count);
298+
}
302299
system_reset();//do a system reset to get the system rebooted
303300
#endif
304301
#endif

0 commit comments

Comments
 (0)