Merge pull request #10395 from kjbracey-arm/mbed_error_warnings

mbed_error: Avoid negative left shift
pull/10414/head
Martin Kojtal 2019-04-16 08:23:45 +01:00 committed by GitHub
commit 237bf04507
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -50,14 +50,17 @@ extern "C" {
#endif
#define MBED_ERROR_STATUS_CODE_MASK (0x0000FFFF)
#define MBED_ERROR_STATUS_CODE_UNSHIFTED_MASK (0x0000FFFF)
#define MBED_ERROR_STATUS_CODE_POS (0)
#define MBED_ERROR_STATUS_CODE_FIELD_SIZE (16)
#define MBED_ERROR_STATUS_MODULE_MASK (0x00FF0000)
#define MBED_ERROR_STATUS_MODULE_UNSHIFTED_MASK (0x000000FF)
#define MBED_ERROR_STATUS_MODULE_POS (16)
#define MBED_ERROR_STATUS_MODULE_FIELD_SIZE (8)
#define MBED_ERROR_STATUS_TYPE_MASK (0x60000000)
#define MBED_ERROR_STATUS_TYPE_UNSHIFTED_MASK (0x00000003)
#define MBED_ERROR_STATUS_TYPE_POS (29)
#define MBED_ERROR_STATUS_TYPE_FIELD_SIZE (2)
@ -65,11 +68,11 @@ extern "C" {
//|31(1 bit) Always Negative|30-29(2 bits) |28-24 | 23-16(8 bits) | 15-0(16 bits) |
//|-1 |TYPE |(unused/reserved) | MODULE TYPE | ERROR CODE |
#define MAKE_MBED_ERROR(type, module, error_code) (mbed_error_status_t) \
((0x80000000) | \
(MBED_ERROR_STATUS_CODE_MASK & (error_code << MBED_ERROR_STATUS_CODE_POS)) | \
(MBED_ERROR_STATUS_MODULE_MASK & (module << MBED_ERROR_STATUS_MODULE_POS)) | \
(MBED_ERROR_STATUS_TYPE_MASK & (type << MBED_ERROR_STATUS_TYPE_POS)))
#define MAKE_MBED_ERROR(type, module, error_code) (mbed_error_status_t) \
((0x80000000) | \
((mbed_error_status_t) (error_code & MBED_ERROR_STATUS_CODE_UNSHIFTED_MASK) << MBED_ERROR_STATUS_CODE_POS) | \
((mbed_error_status_t) (module & MBED_ERROR_STATUS_MODULE_UNSHIFTED_MASK) << MBED_ERROR_STATUS_MODULE_POS) | \
((mbed_error_status_t) (type & MBED_ERROR_STATUS_TYPE_UNSHIFTED_MASK) << MBED_ERROR_STATUS_TYPE_POS))
#define MBED_GET_ERROR_TYPE( error_status ) ((error_status & MBED_ERROR_STATUS_TYPE_MASK) >> MBED_ERROR_STATUS_TYPE_POS)
#define MBED_GET_ERROR_MODULE( error_status ) ((error_status & MBED_ERROR_STATUS_MODULE_MASK) >> MBED_ERROR_STATUS_MODULE_POS)
@ -83,7 +86,7 @@ extern "C" {
*
\verbatim
| 31 Always Negative | 30-29(2 bits) | 28-24 | 23-16(8 bits) | 15-0(16 bits) |
| -1 | TYPE | (unused/reserved) | MODULE TYPE | ERROR CODE |
| -1 | TYPE | (unused/reserved) | MODULE TYPE | ERROR CODE |
\endverbatim
*
* The error status value range for each error type is as follows:\n