Skip to content

Commit 321548c

Browse files
committed
platform: error: fix bogus usage of memset()
Code had mixed up order of 'c' and 'n' arguments to memset(). Fix this. Spotted-by: kjbracey-arm & a GCC profile without "-fno-builtin" Related GCC warnings: ---8<---8<---- [Warning] mbed_error.c@123,5: 'memset' used with constant zero length parameter; this could be due to transposed parameters [-Wmemset-transposed-args] [Warning] mbed_error.c@282,5: 'memset' used with constant zero length parameter; this could be due to transposed parameters [-Wmemset-transposed-args]
1 parent acb59c4 commit 321548c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

platform/mbed_error.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsign
120120
error_count++;
121121

122122
//Clear the context capturing buffer
123-
memset(&current_error_ctx, sizeof(mbed_error_ctx), 0);
123+
memset(&current_error_ctx, 0, sizeof(mbed_error_ctx));
124124
//Capture error information
125125
current_error_ctx.error_status = error_status;
126126
current_error_ctx.error_address = (uint32_t)caller;
@@ -279,7 +279,7 @@ mbed_error_status_t mbed_clear_all_errors(void)
279279
//Make sure we dont multiple clients resetting
280280
core_util_critical_section_enter();
281281
//Clear the error and context capturing buffer
282-
memset(&last_error_ctx, sizeof(mbed_error_ctx), 0);
282+
memset(&last_error_ctx, 0, sizeof(mbed_error_ctx));
283283
//reset error count to 0
284284
error_count = 0;
285285
#if MBED_CONF_PLATFORM_ERROR_HIST_ENABLED

0 commit comments

Comments
 (0)