Re: [PATCH 2/3] fsck.c: use xmalloc, warn & err and new usage

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

 



On Wed, Jan 19, 2011 at 09:58:02AM +0100, Sami Kerola wrote:
> ---
>  fsck/fsck.c |  180 +++++++++++++++++++++++++++++------------------------------
>  1 files changed, 88 insertions(+), 92 deletions(-)

 Applied with small changes

> @@ -241,22 +241,28 @@ static int is_irrotational_disk(dev_t disk)
>  			"/sys/dev/block/%d:%d/queue/rotational",
>  			major(disk), minor(disk));
>  
> -	if (rc < 0 || rc + 1 > sizeof(path))
> +	if (rc < 0 || (unsigned int) (rc + 1) > sizeof(path))
>  		return 0;
>  
>  	f = fopen(path, "r");
>  	if (!f)
>  		return 0;
>  
> -	rc = fscanf(f, "%u", &x);
> +	rc = fscanf(f, "%d", &x);
> +	if (rc != 1) {
> +		if (ferror(f))
> +			warn(_("failed to read: %s"), path);
> +		else
> +			warnx(_("parse error: %s"), path);
> +	}
>  	fclose(f);
>  
> -	return rc == 1 ? !x : 0;
> +	return (rc == 1 ? 1 : 0);
    ^^^^^^^^^^^^^^^^^^^^^^^^

  I think that we don't want to ignore the value ('x') from the
  /sys/.../queue/rotational file.

[...]
>  			case 'V':
> -				verbose++;
> +				verbose = 1;
>  				break;

 The original code was correct.

    Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux