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

[BUG] Violation of MISRA 2012 Rule 5.5: Identifiers shall be distinct from macro names #1058

Closed
markhermeling opened this issue May 14, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@markhermeling
Copy link

Describe the bug
in include/semphr.h, line 675:
#define xSemaphoreTakeFromISR( xSemaphore, pxHigherPriorityTaskWoken ) xQueueReceiveFromISR( ( QueueHandle_t ) ( xSemaphore ), NULL, ( pxHigherPriorityTaskWoken ) )

In the same file, line 26:
#ifdef xSemaphoreTakeFromISR
#hard_undef xSemaphoreTakeFromISR
BaseType_t xSemaphoreTakeFromISR( SemaphoreHandle_t xSemaphore, BaseType_t * const pxHigherPriorityTaskWoken )

The macro and the function have the same name, which is a violation of rule 5.5

The same happens to xSemaphoreGive at line 460 and 23

Target

  • UP and SMP configurations of the Coverity example

Host

  • Linux

To Reproduce
Run codesonar analyze -preset misra2012 on the Coverity example

Expected behavior
Either add a deviation, or change the code to have none distinct names for the macro and the function

Screenshots
SARIF file attached

MISRA-violation-5.5.sarif.zip

@markhermeling markhermeling added the bug Something isn't working label May 14, 2024
@RichardBarry
Copy link
Contributor

Hi, thanks for this. I would be grateful if you can post links to the referenced lines as line 26 in semphr.h appears to be a comment.

@kar-rahul-aws
Copy link
Member

Hi @markhermeling
Thanks for reporting the issue.
We only see the function prototypes in the comments as pointed out by @RichardBarry .
This would likely not cause an issue, since the macro definitions are proper in the source include file.
Could you please provide more information on the lines( which are not comments ) which have similar issue.

Thanks.

@markhermeling
Copy link
Author

Ah, I see what is going on. Let me retract this bug. This configuration of FreeRTOS used a #define for xSemaphoreTakeFromISR, where the CodeSonar model for FreeRTOS is expecting a function and the two are clashing.

This is not a problem in FreeRTOS, sorry for the noice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants