<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jan 7, 2019 at 9:36 AM Christian Hesse <<a href="mailto:list@eworm.de">list@eworm.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Christian Hesse <<a href="mailto:mail@eworm.de" target="_blank">mail@eworm.de</a>><br>
<br>+ int value = MIN(MAX(atoi(str), max), min);<br>
</blockquote><div><br></div><div>This will always result in value = min</div><div>The correct statement would be</div><div> int value = MIN(MAX(atoi(str), min), max);</div><div><br></div><div>Alternately, since this is the only time you use MIN/MAX, you could instead define a CLAMP macro and use it.</div><div> int value = CLAMP(atoi(str), min, max);</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+ ctx.cfg.cache_size = parse_int(value, 0, INT_MAX, 0);<br></blockquote><div> </div><div>In all but a couple of instances, the same min/max/default values are passed in.</div><div>Wouldn't it be better to have parse_int(value) for these, and something like</div><div>parse_int_clamp_default(value, min, max, default_if_zero) for the exceptions?</div></div></div>