From: Karel Zak <kzak@redhat.com>
To: Sami Kerola <kerolasa@iki.fi>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH 1/3] ipcs: add --human readable size conversion option
Date: Mon, 10 Dec 2012 10:06:07 +0100 [thread overview]
Message-ID: <20121210090607.GB21405@x2.net.home> (raw)
In-Reply-To: <1355087316-12422-1-git-send-email-kerolasa@iki.fi>
On Sun, Dec 09, 2012 at 09:08:34PM +0000, Sami Kerola wrote:
> +.B \-\-human
> +Show print sizes in human readable format (e.g., 1K 234M 2G).
Nice idea, but what about create any smart function to print the
stuff to avoid all the "if (unit == UNIT_DEFAULT) else" in the code?
> + if (unit == UNIT_DEFAULT)
> + printf(_("max seg size (kbytes) = %ju\n"),
> + lim.shmmax / 1024);
> + else if (unit == UNIT_HUMAN)
> + printf(_("max seg size = %s\n"),
> + size_to_human_string(SIZE_SUFFIX_1LETTER,
> + lim.shmmax));
ipc_print(IPC_UNIT_KB, _("max seg size), lim.shmmax, "\n");
(append " (bytes) = " if there is not "=" at the end of the string)
> @@ -560,8 +632,17 @@ void print_msg(int msgid)
> msgdata->msg_perm.uid, msgdata->msg_perm.uid,
> msgdata->msg_perm.cuid, msgdata->msg_perm.cgid,
> msgdata->msg_perm.mode);
> - printf(_("cbytes=%jd\tqbytes=%jd\tqnum=%jd\tlspid=%d\tlrpid=%d\n"),
> - msgdata->q_cbytes, msgdata->q_qbytes, msgdata->q_qnum,
> + if (unit == UNIT_DEFAULT)
> + printf(_("cbytes=%jd\tqbytes=%jd"), msgdata->q_cbytes,
> + msgdata->q_qbytes);
ipc_print(IPC_UNIT_B, "cbytes=", msgdata->q_cbytes, "\t");
ipc_print(IPC_UNIT_B, "qbytes=", msgdata->q_qbytes, NULL);
... or so.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
next prev parent reply other threads:[~2012-12-10 9:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-09 21:08 [PATCH 1/3] ipcs: add --human readable size conversion option Sami Kerola
2012-12-09 21:08 ` [PATCH 2/3] docs: swapon.8 option name fix Sami Kerola
2012-12-09 21:08 ` [PATCH 3/3] ipcs: add --bytes size output option Sami Kerola
2012-12-10 9:06 ` Karel Zak [this message]
2012-12-10 23:38 ` [PATCH 1/3] ipcs: add --human readable size conversion option Sami Kerola
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=20121210090607.GB21405@x2.net.home \
--to=kzak@redhat.com \
--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