lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201106095004.GA3269193@ubuntu-m3-large-x86>
Date:   Fri, 6 Nov 2020 02:50:04 -0700
From:   Nathan Chancellor <natechancellor@...il.com>
To:     Lukas Bulwahn <lukas.bulwahn@...il.com>
Cc:     Balbir Singh <bsingharora@...il.com>, Tom Rix <trix@...hat.com>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        clang-built-linux@...glegroups.com,
        kernel-janitors@...r.kernel.org, linux-safety@...ts.elisa.tech,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] taskstats: remove unneeded dead assignment

On Fri, Nov 06, 2020 at 07:22:10AM +0100, Lukas Bulwahn 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@...il.com>

Question below.

Reviewed-by: Nathan Chancellor <natechancellor@...il.com>

> ---
> applies cleanly on current master and next-20201105
> 
> 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) {

Would it be worth moving the scope of rc into the for loop, now that it
is only used there? Looks like it used to be used in the main function
scope before commit 053c095a82cf ("netlink: make nlmsg_end() and
genlmsg_end() void") but if this is removed, it is only used to check
the return of genlmsg_unicast within the list_for_each_entry loop. Not
sure that buys us anything but I know you have done it in patches
before so I thought it was worth considering.

>  		skb_next = NULL;
> -- 
> 2.17.1
> 

Cheers,
Nathan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ