Re: [PATCH 1/7] zramctl: print all devices as a default action

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

 



On 08/03/2014 04:17 PM, Sami Kerola wrote:
> diff --git a/sys-utils/zramctl.c b/sys-utils/zramctl.c
> index a26cd8e..04744fd 100644
> --- a/sys-utils/zramctl.c
> +++ b/sys-utils/zramctl.c
> @@ -193,18 +193,18 @@ static int zram_set_strparm(struct zram *z, const char *attr, const char *str)
>  }
>  
>  
> -static int zram_used(struct zram *z)
> +static int zram_used(struct zram *z, int find_unused)
>  {
>  	uint64_t size;
>  	struct sysfs_cxt *sysfs = zram_get_sysfs(z);
>  
> -	if (sysfs &&
> -	    sysfs_read_u64(sysfs, "disksize", &size) == 0 &&
> -	    size > 0) {
> -
> +	if (sysfs && sysfs_read_u64(sysfs, "disksize", &size) == 0) {
> +		if (find_unused && size == 0)
> +			goto unused;
>  		DBG(fprintf(stderr, "%s used", z->devname));
>  		return 1;
>  	}
> + unused:
>  	DBG(fprintf(stderr, "%s unused", z->devname));
>  	return 0;
>  }

Do we want to give the same message for both 'unused' and the case
when sysfs or disksize can't be determined?

And IMO the 'goto' here is a big gun for skipping 2 lines and a '}';
just reversing the condition would have done it, too.

Have a nice day,
Berny
--
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