ubi-utils updates for gcc-4.3.x

Artem Bityutskiy dedekind at infradead.org
Mon Dec 8 06:00:52 EST 2008


Hi,

thanks for the patch.

On Mon, 2008-12-08 at 01:02 -0700, Tom Rini wrote:
> gcc-4.3.x introduces a number of new warnings (and we use -Werror) for
> things like not checking scanf return values and not using explicit
> formatting.  Finally, it caught that we were overflowing our own buffer
> in unubi.c, so increate the variable size as we want to declare and
> clear PATH_MAX + 1, then use only PATH_MAX of the variable.
> 
> Signed-off-by: Tom Rini <trini at embeddedalley.com>
> 
> diff --git a/ubi-utils/new-utils/src/ubiformat.c b/ubi-utils/new-utils/src/ubiformat.c
> index 05caed9..9c3e0fb 100644
> --- a/ubi-utils/new-utils/src/ubiformat.c
> +++ b/ubi-utils/new-utils/src/ubiformat.c
> @@ -225,7 +225,8 @@ static int want_exit(void)
>  
>  	while (1) {
>  		normsg_cont("continue? (yes/no)  ");
> -		scanf("%3s", buf);
> +		if (!scanf("%3s", buf))
> +			return 1;

>From man scanf:

RETURN VALUE
These  functions  return  the  number  of input items successfully
matched and assigned, which can be fewer than provided for, or even zero
in the event of an early matching failure.

The value EOF is returned if the end of input is reached before either
the first successful conversion or a matching failure occurs.  EOF is
also returned  if a read error occurs, in which case the error indicator
for the stream (see ferror(3)) is set, and errno is set indicate the
error.

On this basis, I would say you should test for EOF, not for 0.

> +		if (!scanf("%3s", buf))
> +			return 0;

Similarly.

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)




More information about the linux-mtd mailing list