Skip to contentSkip to conversation

stackleak: Remove unnecessary ‘0’ values from ret

PATCH In review Li zeming 4 participants 4 messages Oct 17, 2023 – Nov 1, 2023

lore
Share & tools
lore

Li zeming

author
#0 lore raw

PATCH 1/1 stackleak: Remove unnecessary ‘0’ values from ret

ret is assigned first, so it does not need to initialize the assignment.

---
 kernel/stackleak.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/stackleak.c +1 -1
index 34c9d81eea940..3faf863593846 100644
@@ -24,7 +24,7 @@ static DEFINE_STATIC_KEY_FALSE(stack_erasing_bypass);
 static int stack_erasing_sysctl(struct ctl_table *table, int write,
 			void __user *buffer, size_t *lenp, loff_t *ppos)
 {
-	int ret = 0;
+	int ret;
 	int state = !static_branch_unlikely(&stack_erasing_bypass);
 	int prev_state = state;
 
Signature · 1 line
2.18.2
#1 lore raw

Re: [PATCH] stackleak: Remove unnecessary '0' values from ret

Quoted 3 lines · Li zeming

ret is assigned first, so it does not need to initialize the assignment.

Does this actually need to change? It's not harmful, and deleting the assignment doesn't save any lines of code.

That said, I don't have strong feelings either way, and Kees is the de-facto-yet-undocumented maintainer for this code, so I will leave it to him to decide whether to apply.

Mark.

Quoted 20 lines
---
 kernel/stackleak.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/stackleak.c +1 -1
index 34c9d81eea940..3faf863593846 100644
@@ -24,7 +24,7 @@ static DEFINE_STATIC_KEY_FALSE(stack_erasing_bypass);
 static int stack_erasing_sysctl(struct ctl_table *table, int write,
 			void __user *buffer, size_t *lenp, loff_t *ppos)
 {
-	int ret = 0;
+	int ret;
 	int state = !static_branch_unlikely(&stack_erasing_bypass);
 	int prev_state = state;
 
Signature · 1 line
2.18.2
#2 lore raw

Re: [PATCH] stackleak: Remove unnecessary '0' values from ret

Quoted 7 lines · Mark Rutland
Quoted 3 lines · Li zeming

ret is assigned first, so it does not need to initialize the assignment.

Does this actually need to change? It's not harmful, and deleting the assignment doesn't save any lines of code.

I prefer explicit initialization. Any unused initialization will be optimized away by the compiler during Dead Store Elimination, so all removing the initialization does is make the code more fragile in the future.

Quoted 3 lines

That said, I don't have strong feelings either way, and Kees is the de-facto-yet-undocumented maintainer for this code, so I will leave it to him to decide whether to apply.

Oh, hm, good point. I will add a MAINTAINER entry for it. Thanks!

-Kees

Signature · 1 line
Kees Cook
#3 lore raw

Re: [PATCH] stackleak: Remove unnecessary '0' values from ret

Quoted 6 lines · Kees Cook
Quoted 5 lines · Mark Rutland
Quoted 3 lines · Li zeming

ret is assigned first, so it does not need to initialize the assignment.

Quoted 8 lines
Quoted 2 lines

Does this actually need to change? It's not harmful, and deleting the assignment doesn't save any lines of code.

I prefer explicit initialization. Any unused initialization will be optimized away by the compiler during Dead Store Elimination, so all removing the initialization does is make the code more fragile in the future.

Also, be careful with those submissions, and do not take the claim in the commit message at face value. Several of them introduce uninitialize variable errors. I had two submissions for the watchdog subsystem, and both of them were wrong.

Guenter