Skip to content

Commit b6179d2

Browse files
committed
Remove error reporting for release builds
1 parent a29eee4 commit b6179d2

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

platform/mbed_error.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
} \
4646
}
4747

48+
#ifndef NDEBUG
49+
#define ERROR_REPORT(ctx, error_msg) print_error_report(ctx, error_msg)
50+
#else
51+
#define ERROR_REPORT(ctx, error_msg) ((void) 0)
52+
#endif
4853

4954
static uint8_t error_in_progress = 0;
5055
static int error_count = 0;
@@ -78,9 +83,7 @@ WEAK void error(const char *format, ...)
7883

7984
//Call handle_error/print_error_report permanently setting error_in_progress flag
8085
handle_error(MBED_ERROR_UNKNOWN, 0, NULL, 0);
81-
#ifndef NDEBUG
82-
print_error_report(&last_error_ctx, "Fatal Run-time error");
83-
#endif
86+
ERROR_REPORT(&last_error_ctx, "Fatal Run-time error");
8487
error_in_progress = 1;
8588

8689
#ifndef NDEBUG
@@ -201,10 +204,8 @@ WEAK mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char
201204
return MBED_ERROR_FAILED_OPERATION;
202205
}
203206

204-
#ifndef NDEBUG
205207
//On fatal errors print the error context/report
206-
print_error_report(&last_error_ctx, error_msg);
207-
#endif
208+
ERROR_REPORT(&last_error_ctx, error_msg);
208209
mbed_halt_system();
209210

210211
return MBED_ERROR_FAILED_OPERATION;
@@ -306,6 +307,7 @@ static void print_threads_info(osRtxThread_t *threads)
306307
}
307308
#endif
308309

310+
#ifndef NDEBUG
309311
static void print_error_report(mbed_error_ctx *ctx, const char *error_msg)
310312
{
311313
uint32_t error_code = MBED_GET_ERROR_CODE(ctx->error_status);
@@ -390,6 +392,7 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg)
390392

391393
mbed_error_printf("\n-- MbedOS Error Info --\n");
392394
}
395+
#endif //ifndef NDEBUG
393396

394397
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED
395398
//Retrieve the error context from error log at the specified index

0 commit comments

Comments
 (0)