Skip to content

Commit 2e28dd9

Browse files
committed
Change set_error/set_error_fatal to warning/error, add itm support and other changes
1 parent 7c6c718 commit 2e28dd9

File tree

17 files changed

+383
-313
lines changed

17 files changed

+383
-313
lines changed

TESTS/mbed_platform/error_handling/main.cpp

Lines changed: 80 additions & 80 deletions
Large diffs are not rendered by default.

features/FEATURE_LWIP/lwip-interface/lwip-sys/arch/lwip_sys_arch.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,15 @@ u32_t sys_now(void) {
123123
*---------------------------------------------------------------------------*/
124124
err_t sys_mbox_new(sys_mbox_t *mbox, int queue_sz) {
125125
if (queue_sz > MB_SIZE)
126-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_NETWORK_STACK, ERROR_CODE_INVALID_SIZE), "sys_mbox_new size error\n", queue_sz);
126+
SET_ERROR(MAKE_ERROR(MODULE_NETWORK_STACK, ERROR_CODE_INVALID_SIZE), "sys_mbox_new size error\n", queue_sz);
127127

128128
memset(mbox, 0, sizeof(*mbox));
129129

130130
mbox->attr.cb_mem = &mbox->data;
131131
mbox->attr.cb_size = sizeof(mbox->data);
132132
mbox->id = osEventFlagsNew(&mbox->attr);
133133
if (mbox->id == NULL)
134-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_NETWORK_STACK, ERROR_CODE_CREATE_FAILED), "sys_mbox_new create error\n", mbox->id);
134+
SET_ERROR(MAKE_ERROR(MODULE_NETWORK_STACK, ERROR_CODE_CREATE_FAILED), "sys_mbox_new create error\n", mbox->id);
135135

136136
osEventFlagsSet(mbox->id, SYS_MBOX_POST_EVENT);
137137

@@ -150,7 +150,7 @@ err_t sys_mbox_new(sys_mbox_t *mbox, int queue_sz) {
150150
*---------------------------------------------------------------------------*/
151151
void sys_mbox_free(sys_mbox_t *mbox) {
152152
if (mbox->post_idx != mbox->fetch_idx)
153-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_NETWORK_STACK, ERROR_CODE_FREE_FAILED), "sys_mbox_free error\n", mbox->post_idx);
153+
SET_ERROR(MAKE_ERROR(MODULE_NETWORK_STACK, ERROR_CODE_FREE_FAILED), "sys_mbox_free error\n", mbox->post_idx);
154154
}
155155

156156
/*---------------------------------------------------------------------------*
@@ -309,7 +309,7 @@ err_t sys_sem_new(sys_sem_t *sem, u8_t count) {
309309
sem->attr.cb_size = sizeof(sem->data);
310310
sem->id = osSemaphoreNew(UINT16_MAX, count, &sem->attr);
311311
if (sem->id == NULL)
312-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_NETWORK_STACK, ERROR_CODE_CREATE_FAILED), "sys_sem_new create error\n", sem->id);
312+
SET_ERROR(MAKE_ERROR(MODULE_NETWORK_STACK, ERROR_CODE_CREATE_FAILED), "sys_sem_new create error\n", sem->id);
313313

314314
return ERR_OK;
315315
}
@@ -388,14 +388,14 @@ err_t sys_mutex_new(sys_mutex_t *mutex) {
388388
* @param mutex the mutex to lock */
389389
void sys_mutex_lock(sys_mutex_t *mutex) {
390390
if (osMutexAcquire(mutex->id, osWaitForever) != osOK)
391-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_NETWORK_STACK, ERROR_CODE_MUTEX_LOCK_FAILED), "sys_mutex_lock error\n", mutex->id);
391+
SET_ERROR(MAKE_ERROR(MODULE_NETWORK_STACK, ERROR_CODE_MUTEX_LOCK_FAILED), "sys_mutex_lock error\n", mutex->id);
392392
}
393393

394394
/** Unlock a mutex
395395
* @param mutex the mutex to unlock */
396396
void sys_mutex_unlock(sys_mutex_t *mutex) {
397397
if (osMutexRelease(mutex->id) != osOK)
398-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_NETWORK_STACK, ERROR_CODE_MUTEX_UNLOCK_FAILED), "sys_mutex_unlock error\n", mutex->id);
398+
SET_ERROR(MAKE_ERROR(MODULE_NETWORK_STACK, ERROR_CODE_MUTEX_UNLOCK_FAILED), "sys_mutex_unlock error\n", mutex->id);
399399
}
400400

401401
/** Delete a mutex
@@ -418,7 +418,7 @@ void sys_init(void) {
418418
lwip_sys_mutex_attr.cb_size = sizeof(lwip_sys_mutex_data);
419419
lwip_sys_mutex = osMutexNew(&lwip_sys_mutex_attr);
420420
if (lwip_sys_mutex == NULL)
421-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_NETWORK_STACK, ERROR_CODE_INITIALIZATION_FAILED), "sys_init error\n", lwip_sys_mutex);
421+
SET_ERROR(MAKE_ERROR(MODULE_NETWORK_STACK, ERROR_CODE_INITIALIZATION_FAILED), "sys_init error\n", lwip_sys_mutex);
422422
}
423423

424424
/*---------------------------------------------------------------------------*
@@ -452,7 +452,7 @@ u32_t sys_jiffies(void) {
452452
*---------------------------------------------------------------------------*/
453453
sys_prot_t sys_arch_protect(void) {
454454
if (osMutexAcquire(lwip_sys_mutex, osWaitForever) != osOK)
455-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_NETWORK_STACK, ERROR_CODE_MUTEX_LOCK_FAILED), "sys_arch_protect error\n", lwip_sys_mutex);
455+
SET_ERROR(MAKE_ERROR(MODULE_NETWORK_STACK, ERROR_CODE_MUTEX_LOCK_FAILED), "sys_arch_protect error\n", lwip_sys_mutex);
456456
return (sys_prot_t) 1;
457457
}
458458

@@ -469,7 +469,7 @@ sys_prot_t sys_arch_protect(void) {
469469
*---------------------------------------------------------------------------*/
470470
void sys_arch_unprotect(sys_prot_t p) {
471471
if (osMutexRelease(lwip_sys_mutex) != osOK)
472-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_NETWORK_STACK, ERROR_CODE_MUTEX_LOCK_FAILED), "sys_arch_unprotect error\n", lwip_sys_mutex);
472+
SET_ERROR(MAKE_ERROR(MODULE_NETWORK_STACK, ERROR_CODE_MUTEX_LOCK_FAILED), "sys_arch_unprotect error\n", lwip_sys_mutex);
473473
}
474474

475475
u32_t sys_now(void) {
@@ -508,7 +508,7 @@ sys_thread_t sys_thread_new(const char *pcName,
508508
LWIP_DEBUGF(SYS_DEBUG, ("New Thread: %s\n", pcName));
509509

510510
if (thread_pool_index >= SYS_THREAD_POOL_N)
511-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_NETWORK_STACK, ERROR_CODE_THREAD_CREATE_FAILED), "sys_thread_new number error\n", thread_pool_index);
511+
SET_ERROR(MAKE_ERROR(MODULE_NETWORK_STACK, ERROR_CODE_THREAD_CREATE_FAILED), "sys_thread_new number error\n", thread_pool_index);
512512
sys_thread_t t = (sys_thread_t)&thread_pool[thread_pool_index];
513513
thread_pool_index++;
514514

@@ -520,11 +520,11 @@ sys_thread_t sys_thread_new(const char *pcName,
520520
t->attr.stack_size = stacksize;
521521
t->attr.stack_mem = malloc(stacksize);
522522
if (t->attr.stack_mem == NULL) {
523-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_NETWORK_STACK, ERROR_CODE_OUT_OF_MEMORY), "Error allocating the stack memory", t);
523+
SET_ERROR(MAKE_ERROR(MODULE_NETWORK_STACK, ERROR_CODE_OUT_OF_MEMORY), "Error allocating the stack memory", t);
524524
}
525525
t->id = osThreadNew((osThreadFunc_t)thread, arg, &t->attr);
526526
if (t->id == NULL)
527-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_NETWORK_STACK, ERROR_CODE_THREAD_CREATE_FAILED), "sys_thread_new create error\n", t->id);
527+
SET_ERROR(MAKE_ERROR(MODULE_NETWORK_STACK, ERROR_CODE_THREAD_CREATE_FAILED), "sys_thread_new create error\n", t->id);
528528

529529
return t;
530530
}

features/filesystem/bd/ReadOnlyBlockDevice.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,13 @@ int ReadOnlyBlockDevice::read(void *buffer, bd_addr_t addr, bd_size_t size)
5757

5858
int ReadOnlyBlockDevice::program(const void *buffer, bd_addr_t addr, bd_size_t size)
5959
{
60-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_BLOCK_DEVICE, ERROR_CODE_WRITE_PROTECTED), "ReadOnlyBlockDevice::program() not allowed", addr);
60+
SET_ERROR(MAKE_ERROR(MODULE_BLOCK_DEVICE, ERROR_CODE_WRITE_PROTECTED), "ReadOnlyBlockDevice::program() not allowed", addr);
6161
return ERROR_WRITE_PROTECTED;
6262
}
6363

6464
int ReadOnlyBlockDevice::erase(bd_addr_t addr, bd_size_t size)
6565
{
66-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_BLOCK_DEVICE, ERROR_CODE_WRITE_PROTECTED), "ReadOnlyBlockDevice::erase() not allowed", addr);
66+
SET_ERROR(MAKE_ERROR(MODULE_BLOCK_DEVICE, ERROR_CODE_WRITE_PROTECTED), "ReadOnlyBlockDevice::erase() not allowed", addr);
6767
return ERROR_WRITE_PROTECTED;
6868
}
6969

hal/mbed_pinmap_common.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void pinmap_pinout(PinName pin, const PinMap *map) {
2929
}
3030
map++;
3131
}
32-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_PLATFORM, ERROR_CODE_PINMAP_INVALID), "could not pinout", pin);
32+
SET_ERROR(MAKE_ERROR(MODULE_PLATFORM, ERROR_CODE_PINMAP_INVALID), "could not pinout", pin);
3333
}
3434

3535
uint32_t pinmap_merge(uint32_t a, uint32_t b) {
@@ -44,7 +44,7 @@ uint32_t pinmap_merge(uint32_t a, uint32_t b) {
4444
return a;
4545

4646
// mis-match error case
47-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_PLATFORM, ERROR_CODE_PINMAP_INVALID), "pinmap mis-match", a);
47+
SET_ERROR(MAKE_ERROR(MODULE_PLATFORM, ERROR_CODE_PINMAP_INVALID), "pinmap mis-match", a);
4848
return (uint32_t)NC;
4949
}
5050

@@ -64,7 +64,7 @@ uint32_t pinmap_peripheral(PinName pin, const PinMap* map) {
6464
return (uint32_t)NC;
6565
peripheral = pinmap_find_peripheral(pin, map);
6666
if ((uint32_t)NC == peripheral) // no mapping available
67-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_PLATFORM, ERROR_CODE_PINMAP_INVALID), "pinmap not found for peripheral", peripheral);
67+
SET_ERROR(MAKE_ERROR(MODULE_PLATFORM, ERROR_CODE_PINMAP_INVALID), "pinmap not found for peripheral", peripheral);
6868
return peripheral;
6969
}
7070

@@ -84,6 +84,6 @@ uint32_t pinmap_function(PinName pin, const PinMap* map) {
8484
return (uint32_t)NC;
8585
function = pinmap_find_function(pin, map);
8686
if ((uint32_t)NC == function) // no mapping available
87-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_PLATFORM, ERROR_CODE_PINMAP_INVALID), "pinmap not found for function", function);
87+
SET_ERROR(MAKE_ERROR(MODULE_PLATFORM, ERROR_CODE_PINMAP_INVALID), "pinmap not found for function", function);
8888
return function;
8989
}

hal/mbed_sleep_manager.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void sleep_manager_lock_deep_sleep_internal(void)
161161
core_util_critical_section_enter();
162162
if (deep_sleep_lock == USHRT_MAX) {
163163
core_util_critical_section_exit();
164-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_HAL, ERROR_CODE_OVERFLOW), "DeepSleepLock overflow (> USHRT_MAX)", deep_sleep_lock);
164+
SET_ERROR(MAKE_ERROR(MODULE_HAL, ERROR_CODE_OVERFLOW), "DeepSleepLock overflow (> USHRT_MAX)", deep_sleep_lock);
165165
}
166166
core_util_atomic_incr_u16(&deep_sleep_lock, 1);
167167
core_util_critical_section_exit();
@@ -172,7 +172,7 @@ void sleep_manager_unlock_deep_sleep_internal(void)
172172
core_util_critical_section_enter();
173173
if (deep_sleep_lock == 0) {
174174
core_util_critical_section_exit();
175-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_HAL, ERROR_CODE_UNDERFLOW), "DeepSleepLock underflow (< 0)", deep_sleep_lock);
175+
SET_ERROR(MAKE_ERROR(MODULE_HAL, ERROR_CODE_UNDERFLOW), "DeepSleepLock underflow (< 0)", deep_sleep_lock);
176176
}
177177
core_util_atomic_decr_u16(&deep_sleep_lock, 1);
178178
core_util_critical_section_exit();

platform/DeepSleepLock.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class DeepSleepLock {
6969
sleep_manager_lock_deep_sleep();
7070
}
7171
if (0 == count) {
72-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_PLATFORM, ERROR_CODE_OVERFLOW), "DeepSleepLock overflow (> USHRT_MAX)", count);
72+
SET_ERROR(MAKE_ERROR(MODULE_PLATFORM, ERROR_CODE_OVERFLOW), "DeepSleepLock overflow (> USHRT_MAX)", count);
7373
}
7474
}
7575

@@ -83,7 +83,7 @@ class DeepSleepLock {
8383
}
8484
if (count == USHRT_MAX) {
8585
core_util_critical_section_exit();
86-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_PLATFORM, ERROR_CODE_UNDERFLOW), "DeepSleepLock underflow (< 0)", count);
86+
SET_ERROR(MAKE_ERROR(MODULE_PLATFORM, ERROR_CODE_UNDERFLOW), "DeepSleepLock underflow (< 0)", count);
8787
}
8888
}
8989
};

platform/Stream.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Stream::Stream(const char *name) : FileLike(name), _file(NULL) {
2929
if (_file) {
3030
mbed_set_unbuffered_stream(_file);
3131
} else {
32-
SET_ERROR_FATAL(MAKE_ERROR(ENTITY_PLATFORM, ERROR_CODE_OPEN_FAILED), "Stream obj failure", _file);
32+
SET_ERROR(MAKE_ERROR(MODULE_PLATFORM, ERROR_CODE_OPEN_FAILED), "Stream obj failure", _file);
3333
}
3434
}
3535

platform/mbed_error.c

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@
2323
#include "platform/mbed_error_log.h"
2424
#include "platform/mbed_error_report.h"
2525
#include "platform/mbed_interface.h"
26+
2627
#if DEVICE_STDIO_MESSAGES
2728
#include <stdio.h>
2829
#endif
2930

3031
static uint8_t error_in_progress = 0;
3132
static int error_count = 0;
3233
static mbed_error_ctx first_error_ctx = {0};
33-
static mbed_error_ctx current_error_ctx = {0};
34+
static mbed_error_ctx last_error_ctx = {0};
3435
static MbedErrorHook error_hook = NULL;
3536

3637
//Helper function to get the current SP
@@ -83,18 +84,24 @@ WEAK void error(const char* format, ...) {
8384
}
8485

8586
//Set an error status with the error handling system
86-
MbedErrorStatus set_error(MbedErrorStatus error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
87+
MbedErrorStatus handle_error(MbedErrorStatus error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
8788
{
89+
mbed_error_ctx current_error_ctx;
90+
8891
//Error status should always be < 0
8992
if(error_status >= 0) {
90-
return ERROR_INVALID_ARGUMENT;
93+
//This is a weird situation, someone called set_error with invalid error code.
94+
//We will still handle the situation but change the error code to ERROR_INVALID_ARGUMENT, atleast the context will have info on who called it
95+
error_status = ERROR_INVALID_ARGUMENT;
9196
}
9297

9398
//Use critsect here, as we don't want processing more than one error at the same time
9499
core_util_critical_section_enter();
95100

96101
//Increment error count
97102
error_count++;
103+
//Use critsect here, as we don't want processing more than one error at the same time
104+
core_util_critical_section_exit();
98105

99106
//Clear the context capturing buffer
100107
memset(&current_error_ctx, sizeof(mbed_error_ctx), 0);
@@ -125,16 +132,13 @@ MbedErrorStatus set_error(MbedErrorStatus error_status, const char *error_msg, u
125132
current_error_ctx.thread_stack_mem = (uint32_t)current_thread->stack_mem;
126133
current_error_ctx.thread_current_sp = get_current_sp();
127134

128-
//Call the error hook if available
129-
if(error_hook != NULL) {
130-
error_hook(&current_error_ctx);
131-
}
132-
133135
#ifndef MBED_CONF_ERROR_LOG_DISABLED
134136
//Log the error with error log
135137
mbed_log_put_error(&current_error_ctx);
136138
#endif
137139

140+
//Use critsect here, as we don't want processing more than one error at the same time
141+
core_util_critical_section_enter();
138142
//Report the error
139143
mbed_report_error(&current_error_ctx, (char *)error_msg);
140144

@@ -143,9 +147,17 @@ MbedErrorStatus set_error(MbedErrorStatus error_status, const char *error_msg, u
143147
memcpy(&first_error_ctx, &current_error_ctx, sizeof(mbed_error_ctx));
144148
}
145149

150+
//copy this error to last error
151+
memcpy(&last_error_ctx, &current_error_ctx, sizeof(mbed_error_ctx));
152+
146153
//Use critsect here, as we don't want processing more than one error at the same time
147154
core_util_critical_section_exit();
148-
155+
156+
//Call the error hook if available
157+
if(error_hook != NULL) {
158+
error_hook(&last_error_ctx);
159+
}
160+
149161
return ERROR_SUCCESS;
150162
}
151163

@@ -160,7 +172,7 @@ MbedErrorStatus get_first_error(void)
160172
MbedErrorStatus get_last_error(void)
161173
{
162174
//return the last error recorded
163-
return current_error_ctx.error_status;
175+
return last_error_ctx.error_status;
164176
}
165177

166178
//Gets the current error count
@@ -171,10 +183,16 @@ int get_error_count(void)
171183
}
172184

173185
//Sets a fatal error
174-
MbedErrorStatus set_error_fatal(MbedErrorStatus error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
186+
MbedErrorStatus set_warning(MbedErrorStatus error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
187+
{
188+
return handle_error(error_status, error_msg, error_value, filename, line_number);
189+
}
190+
191+
//Sets a fatal error
192+
MbedErrorStatus set_error(MbedErrorStatus error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
175193
{
176194
//set the error reported and then halt the system
177-
if( ERROR_SUCCESS != set_error(error_status, error_msg, error_value, filename, line_number) )
195+
if( ERROR_SUCCESS != handle_error(error_status, error_msg, error_value, filename, line_number) )
178196
return ERROR_FAILED_OPERATION;
179197
mbed_halt_system();
180198

@@ -203,12 +221,12 @@ MbedErrorStatus get_first_error_log_info (mbed_error_ctx *error_info)
203221
//Retrieve the last error context from error log
204222
MbedErrorStatus get_last_error_log_info (mbed_error_ctx *error_info)
205223
{
206-
memcpy(error_info, &current_error_ctx, sizeof(mbed_error_ctx));
224+
memcpy(error_info, &last_error_ctx, sizeof(mbed_error_ctx));
207225
return ERROR_SUCCESS;
208226
}
209227

210228
//Makes an MbedErrorStatus value
211-
MbedErrorStatus make_mbed_error(MbedErrorType error_type, MbedEntityType entity, MbedErrorCode error_code)
229+
MbedErrorStatus make_mbed_error(MbedErrorType error_type, MbedModuleType entity, MbedErrorCode error_code)
212230
{
213231
switch(error_type)
214232
{
@@ -232,7 +250,7 @@ MbedErrorStatus make_mbed_error(MbedErrorType error_type, MbedEntityType entity,
232250
}
233251

234252
//If we are passed incorrect values return a generic system error
235-
return MAKE_MBED_ERROR(ERROR_TYPE_SYSTEM, ENTITY_UNKNOWN, ERROR_CODE_UNKNOWN);
253+
return MAKE_MBED_ERROR(ERROR_TYPE_SYSTEM, MODULE_UNKNOWN, ERROR_CODE_UNKNOWN);
236254
}
237255

238256
/**
@@ -245,7 +263,7 @@ MbedErrorStatus clear_all_errors(void)
245263
MbedErrorStatus status = ERROR_SUCCESS;
246264

247265
//Clear the error and context capturing buffer
248-
memset(&current_error_ctx, sizeof(mbed_error_ctx), 0);
266+
memset(&last_error_ctx, sizeof(mbed_error_ctx), 0);
249267
//reset error count to 0
250268
error_count = 0;
251269
#ifndef MBED_CONF_ERROR_LOG_DISABLED
@@ -276,13 +294,13 @@ MbedErrorStatus save_error_log(const char *path)
276294

277295
//Ensure path is valid
278296
if(path==NULL) {
279-
ret = MAKE_ERROR(ENTITY_PLATFORM, ERROR_CODE_INVALID_ARGUMENT);
297+
ret = MAKE_ERROR(MODULE_PLATFORM, ERROR_CODE_INVALID_ARGUMENT);
280298
goto exit;
281299
}
282300

283301
//Open the file for saving the error log info
284302
if((error_log_file = fopen( path, "w" ) ) == NULL){
285-
ret = MAKE_ERROR(ENTITY_PLATFORM, ERROR_CODE_OPEN_FAILED);
303+
ret = MAKE_ERROR(MODULE_PLATFORM, ERROR_CODE_OPEN_FAILED);
286304
goto exit;
287305
}
288306

@@ -292,16 +310,16 @@ MbedErrorStatus save_error_log(const char *path)
292310
(unsigned int)first_error_ctx.thread_id,
293311
(unsigned int)first_error_ctx.error_address,
294312
(unsigned int)first_error_ctx.error_value) <= 0) {
295-
ret = MAKE_ERROR(ENTITY_PLATFORM, ERROR_CODE_WRITE_FAILED);
313+
ret = MAKE_ERROR(MODULE_PLATFORM, ERROR_CODE_WRITE_FAILED);
296314
goto exit;
297315
}
298316

299317
if(fprintf(error_log_file, "\nLast Error: Status:0x%x ThreadId:0x%x Address:0x%x Value:0x%x\n",
300-
(unsigned int)current_error_ctx.error_status,
301-
(unsigned int)current_error_ctx.thread_id,
302-
(unsigned int)current_error_ctx.error_address,
303-
(unsigned int)current_error_ctx.error_value) <= 0) {
304-
ret = MAKE_ERROR(ENTITY_PLATFORM, ERROR_CODE_WRITE_FAILED);
318+
(unsigned int)last_error_ctx.error_status,
319+
(unsigned int)last_error_ctx.thread_id,
320+
(unsigned int)last_error_ctx.error_address,
321+
(unsigned int)last_error_ctx.error_value) <= 0) {
322+
ret = MAKE_ERROR(MODULE_PLATFORM, ERROR_CODE_WRITE_FAILED);
305323
goto exit;
306324
}
307325

@@ -315,7 +333,7 @@ MbedErrorStatus save_error_log(const char *path)
315333
(unsigned int)ctx.thread_id,
316334
(unsigned int)ctx.error_address,
317335
(unsigned int)ctx.error_value) <= 0) {
318-
ret = MAKE_ERROR(ENTITY_PLATFORM, ERROR_CODE_WRITE_FAILED);
336+
ret = MAKE_ERROR(MODULE_PLATFORM, ERROR_CODE_WRITE_FAILED);
319337
goto exit;
320338
}
321339
}

0 commit comments

Comments
 (0)