On Mon, Jan 7, 2019 at 9:36 AM Christian Hesse <l...@eworm.de> wrote:

> From: Christian Hesse <m...@eworm.de>
>
> +       int value = MIN(MAX(atoi(str), max), min);
>

This will always result in value = min
The correct statement would be
  int value = MIN(MAX(atoi(str), min), max);

Alternately, since this is the only time you use MIN/MAX, you could instead
define a CLAMP macro and use it.
  int value = CLAMP(atoi(str), min, max);


> +               ctx.cfg.cache_size = parse_int(value, 0, INT_MAX, 0);
>

In all but a couple of instances, the same min/max/default values are
passed in.
Wouldn't it be better to have parse_int(value) for these, and something like
parse_int_clamp_default(value, min, max, default_if_zero) for the
exceptions?
_______________________________________________
CGit mailing list
CGit@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/cgit

Reply via email to