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] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 15 Nov 2009 11:28:59 +0100
From:	Ingo Molnar <mingo@...e.hu>
To:	Hitoshi Mitake <mitake@....info.waseda.ac.jp>
Cc:	linux-kernel@...r.kernel.org,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Paul Mackerras <paulus@...ba.org>,
	Frederic Weisbecker <fweisbec@...il.com>
Subject: Re: [PATCH v3] perf tools: New function to parse string representing
 size in bytes


* Hitoshi Mitake <mitake@....info.waseda.ac.jp> wrote:

> + * bytesexp2int()

i suspect this could be named 'bytestring2ll' ? Is 'bytesexp' an 
existing naming in other libraries?

> + * Parse (\d+)(b|B|kb|KB|mb|MB|gb|GB|tb|TB) (e.g. "256MB")
> + * and return its numeric value
> + */
> +long long int bytesexp2int(const char *str)

we have type shortcuts for 'long long': s64.

> +{
> +	unsigned int i;
> +	long long int length = -1, unit = 1;

s64 too i suspect.

> +tera:
> +			unit = (long long int)K * K * K * K;

Note, you can probably avoid this type cast if you define the 'K' 
literal as 1024LL or so.

> +	length = atoll(str) * unit;

we might want to take a naming clue here and name this new function as 
atoll_exp(), to signal that it works like atoll, just with an extension 
for KB/MB/GB/etc. expressions?

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