Skip to content

Commit 5f27ef1

Browse files
committed
Fixes to align with naming conventions
1 parent 2d900bd commit 5f27ef1

File tree

6 files changed

+110
-110
lines changed

6 files changed

+110
-110
lines changed

TESTS/mbed_platform/error_handling/main.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ using utest::v1::Case;
2727
*/
2828
void test_system_errors()
2929
{
30-
MbedErrorStatus error = MAKE_ERROR(MODULE_APPLICATION, ERROR_CODE_UNKNOWN);
30+
mbed_error_status_t error = MAKE_ERROR(MODULE_APPLICATION, ERROR_CODE_UNKNOWN);
3131
SET_WARNING(error, "Error Unknown", 0xAABBCCDD );
32-
MbedErrorStatus lastError = get_last_error();
32+
mbed_error_status_t lastError = get_last_error();
3333
printf("\nlastError = 0x%08X", lastError );
3434
TEST_ASSERT_EQUAL_UINT(error, lastError);
3535

@@ -57,9 +57,9 @@ void test_system_errors()
5757
*/
5858
void test_custom_errors()
5959
{
60-
MbedErrorStatus error = MAKE_CUSTOM_ERROR(MODULE_APPLICATION, ERROR_CODE_UNKNOWN);
60+
mbed_error_status_t error = MAKE_CUSTOM_ERROR(MODULE_APPLICATION, ERROR_CODE_UNKNOWN);
6161
SET_WARNING(error, "Custom Error Unknown", 0x1234 );
62-
MbedErrorStatus lastError = get_last_error();
62+
mbed_error_status_t lastError = get_last_error();
6363
printf("\nlastError = 0x%08X", lastError );
6464
TEST_ASSERT_EQUAL_UINT(error, lastError);
6565

@@ -82,7 +82,7 @@ void test_custom_errors()
8282
void test_posix_errors()
8383
{
8484
SET_WARNING(ERROR_EPERM, "Posix Error Eperm", 0x1234 );
85-
MbedErrorStatus lastError = get_last_error();
85+
mbed_error_status_t lastError = get_last_error();
8686
printf("\nlastError = 0x%08X", lastError );
8787
TEST_ASSERT_EQUAL_UINT(ERROR_EPERM, lastError);
8888

@@ -113,7 +113,7 @@ void test_first_and_last_error_capture()
113113
SET_WARNING(ERROR_MUTEX_UNLOCK_FAILED, "Mutex unlock failed", 0x99AA );
114114
SET_WARNING(ERROR_SEMAPHORE_UNLOCK_FAILED, "Semaphore unlock failed", 0xBBCC );
115115

116-
MbedErrorStatus error = get_last_error();
116+
mbed_error_status_t error = get_last_error();
117117
printf("\nlastError = 0x%08X", error );
118118
TEST_ASSERT_EQUAL_UINT(ERROR_SEMAPHORE_UNLOCK_FAILED, error);
119119

@@ -149,13 +149,13 @@ void test_error_count_and_reset()
149149
void test_error_encoding()
150150
{
151151
SET_WARNING(ERROR_OUT_OF_RESOURCES, "System type error", 0x1100 );
152-
MbedErrorStatus lastError = get_last_error();
152+
mbed_error_status_t lastError = get_last_error();
153153
printf("\nlastError = 0x%08X", lastError );
154154
TEST_ASSERT_EQUAL_UINT(ERROR_TYPE_SYSTEM, GET_MBED_ERROR_TYPE(lastError));
155155
TEST_ASSERT_EQUAL_UINT(MODULE_UNKNOWN, GET_MBED_ERROR_MODULE(lastError));
156156
TEST_ASSERT_EQUAL_UINT(ERROR_CODE_OUT_OF_RESOURCES, GET_MBED_ERROR_CODE(lastError));
157157

158-
MbedErrorStatus error = MAKE_CUSTOM_ERROR(MODULE_PLATFORM, ERROR_CODE_CREATE_FAILED);
158+
mbed_error_status_t error = MAKE_CUSTOM_ERROR(MODULE_PLATFORM, ERROR_CODE_CREATE_FAILED);
159159
SET_WARNING(error, "Custom Error Type", 0x2233);
160160
lastError = get_last_error();
161161
printf("\nlastError = 0x%08X", lastError );
@@ -202,11 +202,11 @@ void test_error_value()
202202
mbed_error_ctx error_ctx = {0};
203203

204204
SET_WARNING(ERROR_OUT_OF_RESOURCES, "System type error", error_value );
205-
MbedErrorStatus status = get_last_error_log_info( &error_ctx );
205+
mbed_error_status_t status = get_last_error_log_info( &error_ctx );
206206
TEST_ASSERT(status == ERROR_SUCCESS);
207207
TEST_ASSERT_EQUAL_UINT(error_value, error_ctx.error_value);
208208

209-
MbedErrorStatus error = MAKE_CUSTOM_ERROR(MODULE_PLATFORM, ERROR_CODE_CREATE_FAILED);
209+
mbed_error_status_t error = MAKE_CUSTOM_ERROR(MODULE_PLATFORM, ERROR_CODE_CREATE_FAILED);
210210
error_value = 0xABCD;
211211
SET_WARNING(error, "Custom Error Type", error_value);
212212
status = get_last_error_log_info( &error_ctx );
@@ -228,7 +228,7 @@ void test_error_context_capture()
228228
mbed_error_ctx error_ctx = {0};
229229

230230
SET_WARNING(ERROR_INVALID_ARGUMENT, "System type error", error_value );
231-
MbedErrorStatus status = get_last_error_log_info( &error_ctx );
231+
mbed_error_status_t status = get_last_error_log_info( &error_ctx );
232232
TEST_ASSERT(status == ERROR_SUCCESS);
233233
TEST_ASSERT_EQUAL_UINT(error_value, error_ctx.error_value);
234234
TEST_ASSERT_EQUAL_UINT(osThreadGetId(), error_ctx.thread_id);
@@ -258,7 +258,7 @@ void test_error_logging()
258258
SET_WARNING(ERROR_INVALID_SIZE, "Invalid size error", 2 );
259259
SET_WARNING(ERROR_INVALID_FORMAT, "Invalid format error", 3 );
260260

261-
MbedErrorStatus status = get_error_log_info( 0, &error_ctx );
261+
mbed_error_status_t status = get_error_log_info( 0, &error_ctx );
262262
TEST_ASSERT_EQUAL_UINT(ERROR_INVALID_ARGUMENT, error_ctx.error_status);
263263
TEST_ASSERT_EQUAL_UINT(1, error_ctx.error_value);
264264

@@ -319,7 +319,7 @@ void test_error_logging()
319319
#define NUM_TEST_THREADS 10
320320

321321
//Error logger threads
322-
void err_thread_func(MbedErrorStatus *error_status)
322+
void err_thread_func(mbed_error_status_t *error_status)
323323
{
324324
//printf("\nError Status = 0x%08X\n",*error_status);
325325
SET_WARNING(*error_status, "Error from Multi-Threaded error logging test", *error_status );
@@ -333,7 +333,7 @@ void test_error_logging_multithread()
333333
mbed_error_ctx error_ctx = {0};
334334
int i=0;
335335
Thread errThread[NUM_TEST_THREADS];
336-
MbedErrorStatus error_status[NUM_TEST_THREADS] = {
336+
mbed_error_status_t error_status[NUM_TEST_THREADS] = {
337337
ERROR_INVALID_ARGUMENT, ERROR_INVALID_DATA_DETECTED, ERROR_INVALID_FORMAT, ERROR_INVALID_SIZE, ERROR_INVALID_OPERATION,
338338
ERROR_ITEM_NOT_FOUND, ERROR_ACCESS_DENIED, ERROR_FAILED_OPERATION, ERROR_OPERATION_PROHIBITED, ERROR_OPERATION_ABORTED
339339
};
@@ -350,7 +350,7 @@ void test_error_logging_multithread()
350350
i = get_error_log_count()-1;
351351
//printf("\nError log count = %d\n", i+1);
352352
for(;i>=0;--i) {
353-
MbedErrorStatus status = get_error_log_info( i, &error_ctx );
353+
mbed_error_status_t status = get_error_log_info( i, &error_ctx );
354354
if(status != ERROR_SUCCESS) {
355355
TEST_FAIL();
356356
}

platform/mbed_error.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static uint8_t error_in_progress = 0;
3030
static int error_count = 0;
3131
static mbed_error_ctx first_error_ctx = {0};
3232
static mbed_error_ctx last_error_ctx = {0};
33-
static MbedErrorHook error_hook = NULL;
33+
static mbed_error_hook_t error_hook = NULL;
3434

3535
//Helper function to halt the system
3636
static void mbed_halt_system(void)
@@ -66,7 +66,7 @@ WEAK void error(const char* format, ...) {
6666
}
6767

6868
//Set an error status with the error handling system
69-
MbedErrorStatus handle_error(MbedErrorStatus error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
69+
mbed_error_status_t handle_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
7070
{
7171
mbed_error_ctx current_error_ctx;
7272

@@ -136,14 +136,14 @@ MbedErrorStatus handle_error(MbedErrorStatus error_status, const char *error_msg
136136
}
137137

138138
//Return the first error
139-
MbedErrorStatus get_first_error(void)
139+
mbed_error_status_t get_first_error(void)
140140
{
141141
//return the first error recorded
142142
return first_error_ctx.error_status;
143143
}
144144

145145
//Return the last error
146-
MbedErrorStatus get_last_error(void)
146+
mbed_error_status_t get_last_error(void)
147147
{
148148
//return the last error recorded
149149
return last_error_ctx.error_status;
@@ -157,13 +157,13 @@ int get_error_count(void)
157157
}
158158

159159
//Sets a fatal error
160-
MbedErrorStatus set_warning(MbedErrorStatus error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
160+
mbed_error_status_t set_warning(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
161161
{
162162
return handle_error(error_status, error_msg, error_value, filename, line_number);
163163
}
164164

165165
//Sets a fatal error
166-
MbedErrorStatus set_error(MbedErrorStatus error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
166+
mbed_error_status_t set_error(mbed_error_status_t error_status, const char *error_msg, unsigned int error_value, const char *filename, int line_number)
167167
{
168168
//set the error reported and then halt the system
169169
if( ERROR_SUCCESS != handle_error(error_status, error_msg, error_value, filename, line_number) )
@@ -174,7 +174,7 @@ MbedErrorStatus set_error(MbedErrorStatus error_status, const char *error_msg, u
174174
}
175175

176176
//Register an application defined callback with error handling
177-
MbedErrorStatus set_error_hook(MbedErrorHook error_hook_in)
177+
mbed_error_status_t set_error_hook(mbed_error_hook_t error_hook_in)
178178
{
179179
//register the new hook/callback
180180
if( error_hook_in != NULL ) {
@@ -186,21 +186,21 @@ MbedErrorStatus set_error_hook(MbedErrorHook error_hook_in)
186186
}
187187

188188
//Retrieve the first error context from error log
189-
MbedErrorStatus get_first_error_log_info (mbed_error_ctx *error_info)
189+
mbed_error_status_t get_first_error_log_info (mbed_error_ctx *error_info)
190190
{
191191
memcpy(error_info, &first_error_ctx, sizeof(first_error_ctx));
192192
return ERROR_SUCCESS;
193193
}
194194

195195
//Retrieve the last error context from error log
196-
MbedErrorStatus get_last_error_log_info (mbed_error_ctx *error_info)
196+
mbed_error_status_t get_last_error_log_info (mbed_error_ctx *error_info)
197197
{
198198
memcpy(error_info, &last_error_ctx, sizeof(mbed_error_ctx));
199199
return ERROR_SUCCESS;
200200
}
201201

202-
//Makes an MbedErrorStatus value
203-
MbedErrorStatus make_mbed_error(MbedErrorType error_type, MbedModuleType entity, MbedErrorCode error_code)
202+
//Makes an mbed_error_status_t value
203+
mbed_error_status_t make_mbed_error(mbed_error_type_t error_type, mbed_module_type_t entity, mbed_error_code_t error_code)
204204
{
205205
switch(error_type)
206206
{
@@ -232,9 +232,9 @@ MbedErrorStatus make_mbed_error(MbedErrorType error_type, MbedModuleType entity,
232232
* @return 0 or ERROR_SUCCESS on success.
233233
*
234234
*/
235-
MbedErrorStatus clear_all_errors(void)
235+
mbed_error_status_t clear_all_errors(void)
236236
{
237-
MbedErrorStatus status = ERROR_SUCCESS;
237+
mbed_error_status_t status = ERROR_SUCCESS;
238238

239239
//Make sure we dont multiple clients resetting
240240
core_util_critical_section_enter();
@@ -252,7 +252,7 @@ MbedErrorStatus clear_all_errors(void)
252252

253253
#ifndef MBED_CONF_ERROR_LOG_DISABLED
254254
//Retrieve the error context from error log at the specified index
255-
MbedErrorStatus get_error_log_info (int index, mbed_error_ctx *error_info)
255+
mbed_error_status_t get_error_log_info (int index, mbed_error_ctx *error_info)
256256
{
257257
return mbed_log_get_error(index, error_info);
258258
}
@@ -263,9 +263,9 @@ int get_error_log_count(void)
263263
return mbed_log_get_error_log_count();
264264
}
265265

266-
MbedErrorStatus save_error_log(const char *path)
266+
mbed_error_status_t save_error_log(const char *path)
267267
{
268-
MbedErrorStatus ret = ERROR_SUCCESS;
268+
mbed_error_status_t ret = ERROR_SUCCESS;
269269
mbed_error_ctx ctx = {0};
270270
int log_count = mbed_log_get_error_log_count();
271271
FILE *error_log_file = NULL;

0 commit comments

Comments
 (0)