Fix min/max macros in include/common.h
PATCH 1/1 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.
include/common.h | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
include/common.h +4 -2
@@ -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)
PATCH 1/1 Fix min/max macros in include/common.h
Dear Aaron Williams,
Quoted 5 lines · In message <[email protected]> you wrote:
There is a bug in the min and max macros in
common.hwhich 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.
Please stick to the rules. When resubmitting a patch you are supposed to mark it as a reposting, and to keep the message references in place so mails get threaded properly. Please make sure and read
http://www.denx.de/wiki/view/U-Boot/Patches#Sending_updated_patch_versions
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Always leave room to add an explanation if it doesn't work out.
Wolfgang Denk
AppliedPATCH 1/1 Fix min/max macros in include/common.h
In reply to Aaron WilliamsDear Aaron Williams,
Quoted 10 lines · In message <[email protected]> you wrote:
There is a bug in the min and max macros in
common.hwhich 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 <[email protected]>include/common.h | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
Applied, after manually fixing the bad patch format ("---" separator line missing). I recommend to use "git format-patch" and "git send-email"!
Thanks.
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Vulcans believe peace should not depend on force. -- Amanda, "Journey to Babel", stardate 3842.3