Skip to content

Commit 20e14e1

Browse files
committed
ioping: allow fractional values in arguments
example: -s 3/4m -- 768k, -i 1/10s -- 10 iops Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
1 parent 27de115 commit 20e14e1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ioping.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,17 @@ long long parse_suffix(const char *str, struct suffix *sfx,
401401
long long min, long long max)
402402
{
403403
char *end;
404-
double val;
404+
double val, den;
405405

406406
val = strtod(str, &end);
407+
if (*end == '/') {
408+
if (end == str)
409+
val = 1;
410+
den = strtod(end + 1, &end);
411+
if (!den)
412+
errx(1, "division by zero in parsing argument: %s", str);
413+
val /= den;
414+
}
407415
for ( ; sfx->txt ; sfx++ ) {
408416
if (strcasecmp(end, sfx->txt))
409417
continue;

0 commit comments

Comments
 (0)