Re: [PATCH 1/3] ipcs: add --human readable size conversion option

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

 



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@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