public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] stackleak: Remove unnecessary ‘0’ values from ret
@ 2023-10-17  6:08 Li zeming
  2023-10-17 10:14 ` [PATCH] stackleak: Remove unnecessary '0' " Mark Rutland
  0 siblings, 1 reply; 4+ messages in thread
From: Li zeming @ 2023-10-17  6:08 UTC (permalink / raw)
  To: gor, mark.rutland, hca; +Cc: linux-kernel, Li zeming

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

Signed-off-by: Li zeming <zeming@nfschina.com>
---
 kernel/stackleak.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/stackleak.c b/kernel/stackleak.c
index 34c9d81eea940..3faf863593846 100644
--- a/kernel/stackleak.c
+++ b/kernel/stackleak.c
@@ -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;
 
-- 
2.18.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] stackleak: Remove unnecessary '0' values from ret
  2023-10-17  6:08 [PATCH] stackleak: Remove unnecessary ‘0’ values from ret Li zeming
@ 2023-10-17 10:14 ` Mark Rutland
  2023-10-19  0:39   ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Rutland @ 2023-10-17 10:14 UTC (permalink / raw)
  To: Li zeming; +Cc: gor, hca, linux-kernel, Kees Cook

On Tue, Oct 17, 2023 at 02:08:24PM +0800, Li zeming wrote:
> ret is assigned first, so it does not need to initialize the assignment.
> 
> Signed-off-by: Li zeming <zeming@nfschina.com>

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.

> ---
>  kernel/stackleak.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/stackleak.c b/kernel/stackleak.c
> index 34c9d81eea940..3faf863593846 100644
> --- a/kernel/stackleak.c
> +++ b/kernel/stackleak.c
> @@ -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;
>  
> -- 
> 2.18.2
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] stackleak: Remove unnecessary '0' values from ret
  2023-10-17 10:14 ` [PATCH] stackleak: Remove unnecessary '0' " Mark Rutland
@ 2023-10-19  0:39   ` Kees Cook
  2023-11-01  4:03     ` Guenter Roeck
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2023-10-19  0:39 UTC (permalink / raw)
  To: Mark Rutland; +Cc: Li zeming, gor, hca, linux-kernel

On Tue, Oct 17, 2023 at 11:14:43AM +0100, Mark Rutland wrote:
> On Tue, Oct 17, 2023 at 02:08:24PM +0800, Li zeming wrote:
> > ret is assigned first, so it does not need to initialize the assignment.
> > 
> > Signed-off-by: Li zeming <zeming@nfschina.com>
> 
> 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.

> 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

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] stackleak: Remove unnecessary '0' values from ret
  2023-10-19  0:39   ` Kees Cook
@ 2023-11-01  4:03     ` Guenter Roeck
  0 siblings, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2023-11-01  4:03 UTC (permalink / raw)
  To: Kees Cook; +Cc: Mark Rutland, Li zeming, gor, hca, linux-kernel

On Wed, Oct 18, 2023 at 05:39:21PM -0700, Kees Cook wrote:
> On Tue, Oct 17, 2023 at 11:14:43AM +0100, Mark Rutland wrote:
> > On Tue, Oct 17, 2023 at 02:08:24PM +0800, Li zeming wrote:
> > > ret is assigned first, so it does not need to initialize the assignment.
> > > 
> > > Signed-off-by: Li zeming <zeming@nfschina.com>
> > 
> > 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-01  4:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-17  6:08 [PATCH] stackleak: Remove unnecessary ‘0’ values from ret Li zeming
2023-10-17 10:14 ` [PATCH] stackleak: Remove unnecessary '0' " Mark Rutland
2023-10-19  0:39   ` Kees Cook
2023-11-01  4:03     ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox