Re: [PATCH] lib/vsprintf: Remove redundant code

From: Andy Shevchenko
Date: Wed Oct 18 2023 - 08:56:25 EST


On Wed, Oct 18, 2023 at 02:48:17PM +0800, 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.

...

> @@ -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;

Logically you may remove then the assignment to true as well.

But I would double check if it's not a continue missing somewhere or so.

--
With Best Regards,
Andy Shevchenko