Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test case for MISRA 10.1 #1307

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Improve test case for MISRA 10.1
Test case for false positive on MISRA rule 10.1.
  • Loading branch information
whoopsmith committed Jul 13, 2018
commit c59c321cf9898be8f1ca260ce11261292905eb13
20 changes: 20 additions & 0 deletions addons/test/misra-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,26 @@ void misra_9_5() {
int x[] = {[0]=23}; // 9.5
}

#define BANK_SIZE 8u

typedef struct
{
uint8_t byte[BANK_SIZE];
} byte_bank_t;

static inline uint8_t GET_BYTE_BITS(const byte_bank_t * ctrl, uint8_t num,
uint8_t bitmask, uint8_t shift)
{
uint8_t retval = 0;

if (num < BANK_SIZE)
{
retval = ((ctrl->byte)[num] & bitmask) >> shift; // no-warning
}

return retval;
}

void misra_10_1() {
int32_t i;
i = 3 << 1; // 10.1
Expand Down