lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Fri, 30 Sep 2011 11:54:19 -0700
From:	"H. Peter Anvin" <hpa@...or.com>
To:	Dave Hansen <dave@...ux.vnet.ibm.com>
CC:	linux-mm@...ck.org, linux-kernel@...r.kernel.org,
	rientjes@...gle.com, James.Bottomley@...senPartnership.com
Subject: Re: [RFC][PATCH 2/4] break out unit selection from string_get_size()

On 09/30/2011 11:02 AM, Dave Hansen wrote:
> string_get_size() can really only print things in a single
> format.  You're always stuck with a space, and it will
> always zero-pad the decimal places:
> 
> 	4.00 KiB
> 	40.0 KiB
> 	400 KiB
> 
> Printing page sizes in decimal KiB does not make much sense
> since they are always nice powers of two.  But,
> string_get_size() does have some nice code for selecting
> the right units and doing the division.
> 
> This breaks that nice code out so that we can reuse it.
> find_size_units() is a bit of a funky function since it has
> so many outputs.  I don't think it's _too_ crazy though.
> 
> Signed-off-by: Dave Hansen <dave@...ux.vnet.ibm.com>

For powers of two, wouldn't it make a lot more sense to just do ilog2()
to get the power of two and then the moral equivalent of:

	sprintf("%u %s", 1 << (pw2 % 10), units_str[pw2 / 10]);

	-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ