Skip to content

Commit 6130744

Browse files
author
Cruz Monrreal
authored
Merge pull request #7404 from SenRamakri/sen_FixErrorReportLinkForRelease
Do not print error reports in release builds
2 parents dc946b3 + b6179d2 commit 6130744

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

platform/mbed_error.c

Lines changed: 9 additions & 2 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,7 +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-
print_error_report(&last_error_ctx, "Fatal Run-time error");
86+
ERROR_REPORT(&last_error_ctx, "Fatal Run-time error");
8287
error_in_progress = 1;
8388

8489
#ifndef NDEBUG
@@ -200,7 +205,7 @@ WEAK mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char
200205
}
201206

202207
//On fatal errors print the error context/report
203-
print_error_report(&last_error_ctx, error_msg);
208+
ERROR_REPORT(&last_error_ctx, error_msg);
204209
mbed_halt_system();
205210

206211
return MBED_ERROR_FAILED_OPERATION;
@@ -302,6 +307,7 @@ static void print_threads_info(osRtxThread_t *threads)
302307
}
303308
#endif
304309

310+
#ifndef NDEBUG
305311
static void print_error_report(mbed_error_ctx *ctx, const char *error_msg)
306312
{
307313
uint32_t error_code = MBED_GET_ERROR_CODE(ctx->error_status);
@@ -386,6 +392,7 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg)
386392

387393
mbed_error_printf("\n-- MbedOS Error Info --\n");
388394
}
395+
#endif //ifndef NDEBUG
389396

390397
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED
391398
//Retrieve the error context from error log at the specified index

0 commit comments

Comments
 (0)