Re: [PATCH] readline_simple: Fix compiler warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, May 12, 2021 at 07:44:40AM +0200, Sascha Hauer wrote:
> char is an unsigned type.

That's incorrect. In the C standard it is explicitly undefined whether char
is signed or unsigned. gcc implements this differently depending on the
architecture. I think ARM and x86 differ here.

Michael

> To test the getchar() return value against
> negative values we have to use a signed type. Use int instead.
> 
> Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
> ---
>  lib/readline_simple.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/readline_simple.c b/lib/readline_simple.c
> index fcdbca41a9..2e52bfc2a0 100644
> --- a/lib/readline_simple.c
> +++ b/lib/readline_simple.c
> @@ -44,7 +44,7 @@ int readline (const char *prompt, char *line, int len)
>  	int	n = 0;				/* buffer index		*/
>  	int	plen = 0;			/* prompt length	*/
>  	int	col;				/* output column cnt	*/
> -	char	c;
> +	int	c;
>  
>  	/* print prompt */
>  	if (prompt) {
> -- 
> 2.29.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@xxxxxxxxxxxxxxxxxxx
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux