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] [day] [month] [year] [list]
Message-ID: <ZTEtVdE-nPGM1iLv@alley>
Date:   Thu, 19 Oct 2023 15:21:25 +0200
From:   Petr Mladek <pmladek@...e.com>
To:     Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
Cc:     rostedt@...dmis.org, andriy.shevchenko@...ux.intel.com,
        linux@...musvillemoes.dk, senozhatsky@...omium.org,
        linux-kernel@...r.kernel.org, Abaci Robot <abaci@...ux.alibaba.com>
Subject: Re: [PATCH] lib/vsprintf: Remove redundant code

On Wed 2023-10-18 14:48:17, Jiapeng Chong wrote:
> When variable needcolon is assigned a value of false, it must be
> assigned a value of true later on, which is redundant code.
> 
> lib/vsprintf.c:1411:4: warning: Value stored to 'needcolon' is never read.
> 
> Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=6909
> Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
> ---
>  lib/vsprintf.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index afb88b24fa74..9a9086885da8 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -1406,10 +1406,9 @@ char *ip6_compressed_string(char *p, const char *addr)
>  			i += longest - 1;
>  			continue;
>  		}
> -		if (needcolon) {
> +		if (needcolon)
>  			*p++ = ':';
> -			needcolon = false;
> -		}
> +
>  		/* hex u16 without leading 0s */
>  		word = ntohs(in6.s6_addr16[i]);
>  		hi = word >> 8;

I am against this change. The assignment should be there from the
logical POV. IMHO, it helps people to verify that the code works
as expected. The removal might even cause regression when the logic
gets modified in the future.

Anyway, this is a slow path. The code readability is more important
then the speed. Let compiler do these micro optimizations.

Best Regards,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ