Skip to content

Conversation

@tychofrei02
Copy link
Contributor

Avoided increments/decrements with side effects.

This corresponds to following coding guideline:

A full expression containing an increment (++) or decrement (–) operator should have no other potential side effects other than that caused by the increment or decrement operator

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:
671153b

@MaureenHelm
Copy link
Member

@andyross @nordic-krch please take a look

andyross
andyross previously approved these changes Jun 14, 2024
Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

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

OK with the changes, nothing seems awful. I will say that the "*ptr++" pattern is so pervasive in cbprintf in particular that it might be worth abstracting it into something like

#define CONSUME(p) ({ char c = *(p); (p)++; c; })

...for clarity, and to avoid all the extra lines. But that's a @nordic-krch decision to make

nashif
nashif previously approved these changes Jun 14, 2024
nordic-krch
nordic-krch previously approved these changes Jun 17, 2024
@aescolar aescolar added this to the v4.0.0 milestone Jun 17, 2024
@aescolar
Copy link
Member

@tychofrei02 note a rebase is needed

- moved ++/-- before or after the value use

Signed-off-by: frei tycho <[email protected]>
@tychofrei02 tychofrei02 dismissed stale reviews from nordic-krch, nashif, and andyross via b62dbd7 June 20, 2024 09:05
@tychofrei02 tychofrei02 force-pushed the misra_rule_13_3_auditable_to_main_in_lib/os branch from cf8db95 to b62dbd7 Compare June 20, 2024 09:05
Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

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

refresh +1

@nashif nashif modified the milestones: v4.0.0, v3.7.0 Jun 21, 2024
@nashif nashif merged commit f17a67f into zephyrproject-rtos:main Jun 21, 2024
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