[Toybox] Min/Max bug fix
Rob Landley
rob at landley.net
Sun Mar 17 16:06:50 PDT 2013
On 03/14/2013 03:46:02 PM, Andre Renaud wrote:
> There is a minor bug in the min/max macros that can result in
> unexpected results when doing things like:
> 5 + min(a,b)
> This currently essentially becomes
> (5 + a) < (b) ? (a) : (b)
> instead of:
> 5 + ((a < b) ? a : b)
>
> Attached patch resolves it with the minimal changes
> In general however, might not the following common min/max definitions
> be more robust?
Actually removing them entirely would be more robust. It's not more
efficient than open coding it, and doesn't really save any complexity
at the call site.
Thanks,
Rob
More information about the Toybox
mailing list