-
Notifications
You must be signed in to change notification settings - Fork 7.7k
arch: x86: avoided increments/decrements with side effects #72372
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
arch: x86: avoided increments/decrements with side effects #72372
Conversation
5f5791d
to
df92f43
Compare
Can you clarify why these changes fall afoul of that rule? What side effects are being prevented here? Mostly this looks like churn just designed around removing "++" operators, which seems not in keeping with the actual rule? (And also sorta Sisyphean anyway -- you'll never get this operator out of the fingers of developers committing new code.) |
Basically my read is that rule is designed to disallow code like |
df92f43
to
c51f06c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @andyross - most changes here don't seem to have any risk of "side effects". Please provide some justification for each modification, since right now there doesn't seem to be much value in this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like there were some cases added with real rule violations, or else I missed them earlier. I flagged the specific ones that don't make sense to me.
arch/x86/core/intel64/cpu.c
Outdated
@@ -206,7 +206,7 @@ FUNC_NORETURN void z_x86_cpu_init(struct x86_cpuboot *cpuboot) | |||
#endif | |||
|
|||
/* Enter kernel, never return */ | |||
cpuboot->ready++; | |||
cpuboot->ready += 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No value is used after increment here.
arch/x86/core/intel64/irq.c
Outdated
for (i = 0; i < VECTORS_PER_PRIORITY; ++i, ++vector) { | ||
const int end_vector = vector + (int) VECTORS_PER_PRIORITY; | ||
|
||
for (; vector < end_vector; ++vector) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No value is used after increment here; the comma operator doesn't inspect the value of its two subexpressions.
arch/x86/zefi/zefi.c
Outdated
@@ -194,7 +195,7 @@ uintptr_t __abi efi_entry(void *img_handle, struct efi_system_table *sys_tab) | |||
* to drain before we start banging on the same UART from the | |||
* OS. | |||
*/ | |||
for (volatile int i = 0; i < 50000000; i++) { | |||
for (volatile int i = 0; i < 50000000; i += 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No value is used after increment here.
- moved ++/-- before or after the value use Signed-off-by: frei tycho <tfrei@baumer.com>
c51f06c
to
d23d7bc
Compare
Fair enough, I removed those changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Avoided increments/decrements with side effects.
Avoided more than one increment/decrement in for-loop.
This corresponds to following coding guideline:
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