[PATCH] hexdump-conv.c: Fix gcc 12 compiler warning

Sebastian Huber sebastian.huber at embedded-brains.de
Tue May 10 11:52:32 UTC 2022


On 10/05/2022 13:27, Matthew Joyce wrote:
> From: Matt Joyce <matthew.joyce at embedded-brains.de>
> 
> Fixed newly generated compiler warning introduced in the switch to gcc 12.
> gcc 12 adds the new warning -Warray-compare, which warns agains potentially
> dubious comparisons between operands of array type.
> ---
>   cpukit/libmisc/shell/hexdump-conv.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/cpukit/libmisc/shell/hexdump-conv.c b/cpukit/libmisc/shell/hexdump-conv.c
> index aa16f9b169..0dee76a595 100644
> --- a/cpukit/libmisc/shell/hexdump-conv.c
> +++ b/cpukit/libmisc/shell/hexdump-conv.c
> @@ -117,7 +117,7 @@ retry:
>   		if (clen == 0)
>   			clen = 1;
>   		else if (clen == (size_t)-1 || (clen == (size_t)-2 &&
> -		    buf == peekbuf)) {
> +		    &buf[0] == &peekbuf[0])) {
>   			memset(&pr->mbstate, 0, sizeof(pr->mbstate));
>   			wc = *p;
>   			clen = 1;

This looks like a bug. We have

	char buf[10];
	char peekbuf[MB_LEN_MAX];

So, buf == peekbuf is never true.

Maybe check the FreeBSD history of src/usr.bin/hexdump/conv.c if there 
are some bug fixes since 2006.

-- 
embedded brains GmbH
Herr Sebastian HUBER
Dornierstr. 4
82178 Puchheim
Germany
email: sebastian.huber at embedded-brains.de
phone: +49-89-18 94 741 - 16
fax:   +49-89-18 94 741 - 08

Registergericht: Amtsgericht München
Registernummer: HRB 157899
Vertretungsberechtigte Geschäftsführer: Peter Rasmussen, Thomas Dörfler
Unsere Datenschutzerklärung finden Sie hier:
https://embedded-brains.de/datenschutzerklaerung/


More information about the devel mailing list