Commit 3276fcc0 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

FlexeLint inspired polishing:

Detect empty args.
Handle 'b' suffix in switch.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2960 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 2b2cbe0a
......@@ -45,6 +45,9 @@ str2bytes(const char *p, uintmax_t *r, uintmax_t rel)
double fval;
char *end;
if (p == NULL || *p == '\0')
return ("missing number");
fval = strtod(p, &end);
if (end == p || !isfinite(fval))
return ("Invalid number");
......@@ -88,11 +91,12 @@ str2bytes(const char *p, uintmax_t *r, uintmax_t rel)
fval *= (uintmax_t)1 << 60;
++end;
break;
}
/* accept 'b' for 'bytes' */
if (end[0] == 'b' || end[0] == 'B')
case 'b': case 'B':
++end;
break;
default:
break;
}
if (end[0] != '\0')
return ("Invalid suffix");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment