From: Bernhard Voelker <mail@bernhard-voelker.de>
To: Sami Kerola <kerolasa@iki.fi>, util-linux@vger.kernel.org
Subject: Re: [PATCH 1/7] zramctl: print all devices as a default action
Date: Mon, 04 Aug 2014 00:19:43 +0200 [thread overview]
Message-ID: <53DEB57F.3080806@bernhard-voelker.de> (raw)
In-Reply-To: <1407075463-19586-1-git-send-email-kerolasa@iki.fi>
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
next prev parent reply other threads:[~2014-08-03 22:19 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-03 14:17 [PATCH 1/7] zramctl: print all devices as a default action Sami Kerola
2014-08-03 14:17 ` [PATCH 2/7] docs: add details to zramctl --size option documentation Sami Kerola
2014-08-03 14:17 ` [PATCH 3/7] zramctl: mark --reset mutually exclusive with --algorithm and --streams Sami Kerola
2014-08-03 14:17 ` [PATCH 4/7] zramctl: fail status printout when device does not exist Sami Kerola
2014-08-03 14:17 ` [PATCH 5/7] zramctl: improve error message Sami Kerola
2014-08-03 14:17 ` [PATCH 6/7] zramctl: fix mount point printout Sami Kerola
2014-08-04 12:15 ` Karel Zak
2014-08-05 23:03 ` Sami Kerola
2014-08-03 14:17 ` [PATCH 7/7] zramctl: add bash completion script Sami Kerola
2014-08-03 14:50 ` [PATCH 1/7] zramctl: print all devices as a default action Mike Frysinger
2014-08-03 20:50 ` Sami Kerola
2014-08-04 7:31 ` Mike Frysinger
2014-08-06 8:16 ` Karel Zak
2014-08-03 22:19 ` Bernhard Voelker [this message]
2014-08-04 12:02 ` Karel Zak
2014-08-05 22:38 ` Sami Kerola
2014-08-11 12:49 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53DEB57F.3080806@bernhard-voelker.de \
--to=mail@bernhard-voelker.de \
--cc=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).