lkml.org 
[lkml]   [2009]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v3] perf tools: New function to parse string representing size in bytes

* Hitoshi Mitake <mitake@dcl.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


\
 
 \ /
  Last update: 2009-11-15 11:31    [W:0.043 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site