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?
#define min(x,y) ({ \
        typeof(x) _x = (x);       \
        typeof(y) _y = (y);       \
        _x < _y ? _x : _y; })
#define max(x,y) ({ \
        typeof(x) _x = (x);       \
        typeof(y) _y = (y);       \
        _x > _y ? _x : _y; })

Regards,
Andre

Attachment: min_max.patch
Description: Binary data

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to