33
33
#define GET_CURRENT_SP (sp ) \
34
34
{ \
35
35
/*If in Handler mode we are always using MSP*/ \
36
- if ( __get_IPSR () != 0U ) { \
36
+ if ( __get_IPSR () != 0U ) { \
37
37
sp = __get_MSP (); \
38
38
} else { \
39
39
/*Look into CONTROL.SPSEL value*/ \
@@ -95,7 +95,7 @@ static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsign
95
95
mbed_error_ctx current_error_ctx ;
96
96
97
97
//Error status should always be < 0
98
- if (error_status >= 0 ) {
98
+ if (error_status >= 0 ) {
99
99
//This is a weird situation, someone called mbed_error with invalid error code.
100
100
//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
101
101
error_status = MBED_ERROR_INVALID_ARGUMENT ;
@@ -141,7 +141,7 @@ static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsign
141
141
#endif
142
142
143
143
//Capture the fist system error and store it
144
- if (error_count == 1 ) { //first error
144
+ if (error_count == 1 ) { //first error
145
145
memcpy (& first_error_ctx , & current_error_ctx , sizeof (mbed_error_ctx ));
146
146
}
147
147
@@ -154,7 +154,7 @@ static mbed_error_status_t handle_error(mbed_error_status_t error_status, unsign
154
154
#endif
155
155
156
156
//Call the error hook if available
157
- if (error_hook != NULL ) {
157
+ if (error_hook != NULL ) {
158
158
error_hook (& last_error_ctx );
159
159
}
160
160
@@ -194,7 +194,7 @@ mbed_error_status_t mbed_warning(mbed_error_status_t error_status, const char *e
194
194
WEAK mbed_error_status_t mbed_error (mbed_error_status_t error_status , const char * error_msg , unsigned int error_value , const char * filename , int line_number )
195
195
{
196
196
//set the error reported and then halt the system
197
- if ( MBED_SUCCESS != handle_error (error_status , error_value , filename , line_number ) )
197
+ if ( MBED_SUCCESS != handle_error (error_status , error_value , filename , line_number ))
198
198
return MBED_ERROR_FAILED_OPERATION ;
199
199
200
200
//On fatal errors print the error context/report
@@ -208,7 +208,7 @@ WEAK mbed_error_status_t mbed_error(mbed_error_status_t error_status, const char
208
208
mbed_error_status_t mbed_set_error_hook (mbed_error_hook_t error_hook_in )
209
209
{
210
210
//register the new hook/callback
211
- if ( error_hook_in != NULL ) {
211
+ if ( error_hook_in != NULL ) {
212
212
error_hook = error_hook_in ;
213
213
return MBED_SUCCESS ;
214
214
}
@@ -236,17 +236,17 @@ mbed_error_status_t mbed_make_error(mbed_error_type_t error_type, mbed_module_ty
236
236
switch (error_type )
237
237
{
238
238
case MBED_ERROR_TYPE_POSIX :
239
- if (error_code >= MBED_POSIX_ERROR_BASE && error_code <= MBED_SYSTEM_ERROR_BASE )
239
+ if (error_code >= MBED_POSIX_ERROR_BASE && error_code <= MBED_SYSTEM_ERROR_BASE )
240
240
return - error_code ;
241
241
break ;
242
242
243
243
case MBED_ERROR_TYPE_SYSTEM :
244
- if (error_code >= MBED_SYSTEM_ERROR_BASE && error_code <= MBED_CUSTOM_ERROR_BASE )
244
+ if (error_code >= MBED_SYSTEM_ERROR_BASE && error_code <= MBED_CUSTOM_ERROR_BASE )
245
245
return MAKE_MBED_ERROR (MBED_ERROR_TYPE_SYSTEM , entity , error_code );
246
246
break ;
247
247
248
248
case MBED_ERROR_TYPE_CUSTOM :
249
- if (error_code >= MBED_CUSTOM_ERROR_BASE )
249
+ if (error_code >= MBED_CUSTOM_ERROR_BASE )
250
250
return MAKE_MBED_ERROR (MBED_ERROR_TYPE_CUSTOM , entity , error_code );
251
251
break ;
252
252
@@ -291,7 +291,7 @@ static void print_thread(osRtxThread_t *thread)
291
291
/* Prints thread info from a list */
292
292
static void print_threads_info (osRtxThread_t * threads )
293
293
{
294
- while (threads != NULL ) {
294
+ while (threads != NULL ) {
295
295
print_thread ( threads );
296
296
threads = threads -> thread_next ;
297
297
}
@@ -347,7 +347,7 @@ static void print_error_report(mbed_error_ctx *ctx, const char *error_msg)
347
347
mbed_error_printf ("\nLocation: 0x%X" , ctx -> error_address );
348
348
349
349
#if MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED && !defined(NDEBUG )
350
- if ((NULL != ctx -> error_filename [0 ]) && (ctx -> error_line_number != 0 )) {
350
+ if ((NULL != ctx -> error_filename [0 ]) && (ctx -> error_line_number != 0 )) {
351
351
//for string, we must pass address of a ptr which has the address of the string
352
352
mbed_error_printf ("\nFile:%s+%d" , ctx -> error_filename , ctx -> error_line_number );
353
353
}
@@ -404,19 +404,19 @@ mbed_error_status_t mbed_save_error_hist(const char *path)
404
404
FILE * error_log_file = NULL ;
405
405
406
406
//Ensure path is valid
407
- if (path == NULL ) {
407
+ if (path == NULL ) {
408
408
ret = MBED_MAKE_ERROR (MBED_MODULE_PLATFORM , MBED_ERROR_CODE_INVALID_ARGUMENT );
409
409
goto exit ;
410
410
}
411
411
412
412
//Open the file for saving the error log info
413
- if ((error_log_file = fopen ( path , "w" ) ) == NULL ){
413
+ if ((error_log_file = fopen ( path , "w" )) == NULL ){
414
414
ret = MBED_MAKE_ERROR (MBED_MODULE_PLATFORM , MBED_ERROR_CODE_OPEN_FAILED );
415
415
goto exit ;
416
416
}
417
417
418
418
//First store the first and last errors
419
- if (fprintf (error_log_file , "\nFirst Error: Status:0x%x ThreadId:0x%x Address:0x%x Value:0x%x\n" ,
419
+ if (fprintf (error_log_file , "\nFirst Error: Status:0x%x ThreadId:0x%x Address:0x%x Value:0x%x\n" ,
420
420
(unsigned int )first_error_ctx .error_status ,
421
421
(unsigned int )first_error_ctx .thread_id ,
422
422
(unsigned int )first_error_ctx .error_address ,
@@ -425,7 +425,7 @@ mbed_error_status_t mbed_save_error_hist(const char *path)
425
425
goto exit ;
426
426
}
427
427
428
- if (fprintf (error_log_file , "\nLast Error: Status:0x%x ThreadId:0x%x Address:0x%x Value:0x%x\n" ,
428
+ if (fprintf (error_log_file , "\nLast Error: Status:0x%x ThreadId:0x%x Address:0x%x Value:0x%x\n" ,
429
429
(unsigned int )last_error_ctx .error_status ,
430
430
(unsigned int )last_error_ctx .thread_id ,
431
431
(unsigned int )last_error_ctx .error_address ,
@@ -435,10 +435,10 @@ mbed_error_status_t mbed_save_error_hist(const char *path)
435
435
}
436
436
437
437
//Update with error log info
438
- while (-- log_count >= 0 ) {
438
+ while (-- log_count >= 0 ) {
439
439
mbed_error_hist_get (log_count , & ctx );
440
440
//first line of file will be error log count
441
- if (fprintf (error_log_file , "\n%d: Status:0x%x ThreadId:0x%x Address:0x%x Value:0x%x\n" ,
441
+ if (fprintf (error_log_file , "\n%d: Status:0x%x ThreadId:0x%x Address:0x%x Value:0x%x\n" ,
442
442
log_count ,
443
443
(unsigned int )ctx .error_status ,
444
444
(unsigned int )ctx .thread_id ,
0 commit comments