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

MISRA C Compliance #152

Closed
AndreyVV-100 opened this issue Oct 30, 2023 · 3 comments
Closed

MISRA C Compliance #152

AndreyVV-100 opened this issue Oct 30, 2023 · 3 comments

Comments

@AndreyVV-100
Copy link

Hi! Сontinuing the issue #147 , our tool gave some new reports. Are this lines violation of rules?

  1. Violation of Rule MISRA C 2012 10.3

int32_t value = 0U;

According to MISRA C 2012 standard paragraph 8.10 "The essential type model", in this example value is of Essentially Signed type category, and the constant 0U is of Essentially Unsigned type category. Assigning the value to an object with different essential type category is prohibited by the rule 10.3.

  1. Violation of Rule MISRA C 2012 20.12

assert( isOpenBracket_( mode ) );

In standard header file assert.h macro assert is defined as follows:

#  define assert(expr)              \
  ((void) sizeof ((expr) ? 1 : 0), __extension__ ({      \
      if (expr)                \
        ; /* empty */              \
      else                \
        __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION);  \
    }))
# endif

So in this example macro parameter isOpenBracket_ (which is also macro) is itself subject for further macro replacement (#expr), supplied as expr parameter.

@manvensh
Copy link

Hi @AndreyVV-100
Thanks a lot for your efforts. Let me discuss with the team about this and get back to you.

Regards,

@chinglee-iot
Copy link
Member

We address this issue in PR #157. I use the coverity 2023.06.1 to check the MISRA deviations and this issue is not reported. It would be great if you can help to verify this patch in your environment. Thank you for reporting this issue.

@AndreyVV-100
Copy link
Author

@chinglee-iot We checked this PR in our environment and there is no warning now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants