mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 23:24:38 +00:00
Fix min/max macros in include/common.h
There is a bug in the min and max macros in common.h which occurs if Y is a larger type than X. For example, if Y is a 64-bit value and X is a 32-bit value then Y will be truncated to 32-bits. This fix matches what is done in the Linux kernel but without the additional type checking present in the kernel version. Signed-off-by: Aaron Williams <aaron.williams@caviumnetworks.com>
This commit is contained in:
parent
9096963c72
commit
1472af34c1
1 changed files with 4 additions and 2 deletions
|
@ -180,11 +180,13 @@ typedef void (interrupt_handler_t)(void *);
|
|||
* General Purpose Utilities
|
||||
*/
|
||||
#define min(X, Y) \
|
||||
({ typeof (X) __x = (X), __y = (Y); \
|
||||
({ typeof (X) __x = (X); \
|
||||
typeof (Y) __y = (Y); \
|
||||
(__x < __y) ? __x : __y; })
|
||||
|
||||
#define max(X, Y) \
|
||||
({ typeof (X) __x = (X), __y = (Y); \
|
||||
({ typeof (X) __x = (X); \
|
||||
typeof (Y) __y = (Y); \
|
||||
(__x > __y) ? __x : __y; })
|
||||
|
||||
#define MIN(x, y) min(x, y)
|
||||
|
|
Loading…
Reference in a new issue