From mboxrd@z Thu Jan 1 00:00:00 1970 From: whydoubt at gmail.com (Jeff Smith) Date: Tue, 8 Jan 2019 08:05:10 -0600 Subject: [PATCH 1/2] cgit: introduce parse_{bool, int}() for for cgitrc parsing In-Reply-To: <20190107153535.21620-1-list@eworm.de> References: <20190107163449.51f869a5@leda> <20190107153535.21620-1-list@eworm.de> Message-ID: On Mon, Jan 7, 2019 at 9:36 AM Christian Hesse wrote: > From: Christian Hesse > > + 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? -------------- next part -------------- An HTML attachment was scrubbed... URL: