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

kernel: added parentheses verifying the lack of ambiguities #72149

Conversation

DeHess
Copy link
Collaborator

@DeHess DeHess commented Apr 30, 2024

Fix coding guideline MISRA C:2012 Rule 12.1 in kernel:

The precedence of operators within expressions should be made explicit.

This PR is part of the enhancement issue #48002 which port the coding guideline fixes done by BUGSENG on the https://github.com/zephyrproject-rtos/zephyr/tree/v2.7-auditable-branch back to main

The commit in this PR is a subset of the original auditable-branch commit:
29155bd

added parentheses verifying lack of ambiguities

Signed-off-by: Hess Nathan <nhess@baumer.com>
@DeHess DeHess changed the title coding guidelines: comply with MISRA Rule 12.1. kernel: added parentheses verifying the lack of ambiguities (MISRA Rule 12.1) Apr 30, 2024
@DeHess DeHess changed the title kernel: added parentheses verifying the lack of ambiguities (MISRA Rule 12.1) kernel: added parentheses verifying the lack of ambiguities Apr 30, 2024
@nashif nashif merged commit 6d417d5 into zephyrproject-rtos:main May 12, 2024
32 checks passed
total_size = size + CONFIG_MMU_PAGE_SIZE * 2;
total_size = size + (CONFIG_MMU_PAGE_SIZE * 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is explicitly marked as exception in the rule description: https://wiki.sei.cmu.edu/confluence/display/c/EXP00-C.+Use+parentheses+for+precedence+of+operation

x

it's the literal example.

Why are doing these?

if (thread == NULL || ko->type != K_OBJ_THREAD ||
(ko->flags & K_OBJ_FLAG_INITIALIZED) == 0) {
if ((thread == NULL) || (ko->type != K_OBJ_THREAD) ||
((ko->flags & K_OBJ_FLAG_INITIALIZED) == 0)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this changed the indentation

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

Successfully merging this pull request may close these issues.

7 participants