mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH RESEND] taskstats: remove unneeded dead assignment
@ 2021-12-27 13:10 Lukas Bulwahn
  2021-12-28 19:39 ` Nick Desaulniers
  0 siblings, 1 reply; 2+ messages in thread
From: Lukas Bulwahn @ 2021-12-27 13:10 UTC (permalink / raw)
  To: Balbir Singh
  Cc: Tom Rix, Nathan Chancellor, Nick Desaulniers, clang-built-linux,
	kernel-janitors, linux-kernel, Lukas Bulwahn

make clang-analyzer on x86_64 defconfig caught my attention with:

  kernel/taskstats.c:120:2: warning: Value stored to 'rc' is never read \
  [clang-analyzer-deadcode.DeadStores]
          rc = 0;
          ^

Commit d94a041519f3 ("taskstats: free skb, avoid returns in
send_cpu_listeners") made send_cpu_listeners() not return a value and
hence, the rc variable remained only to be used within the loop where
it is always assigned before read and it does not need any other
initialisation.

So, simply remove this unneeded dead initializing assignment.

As compilers will detect this unneeded assignment and optimize this anyway,
the resulting object code is identical before and after this change.

No functional change. No change to object code.

Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>
---
applies cleanly on current master and next-20201105
Resend: still applies cleanly on next-20211224

Balbir, please pick this minor non-urgent clean-up patch.

 kernel/taskstats.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/taskstats.c b/kernel/taskstats.c
index a2802b6ff4bb..bd18a7bf5276 100644
--- a/kernel/taskstats.c
+++ b/kernel/taskstats.c
@@ -117,7 +117,6 @@ static void send_cpu_listeners(struct sk_buff *skb,
 
 	genlmsg_end(skb, reply);
 
-	rc = 0;
 	down_read(&listeners->sem);
 	list_for_each_entry(s, &listeners->list, list) {
 		skb_next = NULL;
-- 
2.17.1


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

* Re: [PATCH RESEND] taskstats: remove unneeded dead assignment
  2021-12-27 13:10 [PATCH RESEND] taskstats: remove unneeded dead assignment Lukas Bulwahn
@ 2021-12-28 19:39 ` Nick Desaulniers
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2021-12-28 19:39 UTC (permalink / raw)
  To: Lukas Bulwahn
  Cc: Balbir Singh, Tom Rix, Nathan Chancellor, clang-built-linux,
	kernel-janitors, linux-kernel

On Mon, Dec 27, 2021 at 5:10 AM Lukas Bulwahn <lukas.bulwahn@gmail.com> wrote:
>
> make clang-analyzer on x86_64 defconfig caught my attention with:
>
>   kernel/taskstats.c:120:2: warning: Value stored to 'rc' is never read \
>   [clang-analyzer-deadcode.DeadStores]
>           rc = 0;
>           ^
>
> Commit d94a041519f3 ("taskstats: free skb, avoid returns in
> send_cpu_listeners") made send_cpu_listeners() not return a value and
> hence, the rc variable remained only to be used within the loop where
> it is always assigned before read and it does not need any other
> initialisation.
>
> So, simply remove this unneeded dead initializing assignment.
>
> As compilers will detect this unneeded assignment and optimize this anyway,
> the resulting object code is identical before and after this change.
>
> No functional change. No change to object code.
>
> Signed-off-by: Lukas Bulwahn <lukas.bulwahn@gmail.com>

I was going to ask "what happens when the list is empty?" but `rc` is
only used in a loop where that's not the case. Thanks for the patch!

It looks like
commit d94a041519f3 ("[PATCH] taskstats: free skb, avoid returns in
send_cpu_listeners")
from v2.6.18-rc4
is what changed send_cpu_listeners not to use rc outside of the loop.

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
> applies cleanly on current master and next-20201105
> Resend: still applies cleanly on next-20211224
>
> Balbir, please pick this minor non-urgent clean-up patch.
>
>  kernel/taskstats.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/kernel/taskstats.c b/kernel/taskstats.c
> index a2802b6ff4bb..bd18a7bf5276 100644
> --- a/kernel/taskstats.c
> +++ b/kernel/taskstats.c
> @@ -117,7 +117,6 @@ static void send_cpu_listeners(struct sk_buff *skb,
>
>         genlmsg_end(skb, reply);
>
> -       rc = 0;
>         down_read(&listeners->sem);
>         list_for_each_entry(s, &listeners->list, list) {
>                 skb_next = NULL;
> --
> 2.17.1
>


-- 
Thanks,
~Nick Desaulniers

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

end of thread, other threads:[~2021-12-28 19:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-27 13:10 [PATCH RESEND] taskstats: remove unneeded dead assignment Lukas Bulwahn
2021-12-28 19:39 ` Nick Desaulniers

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

all inboxes | Powered by JetHome®