From: Aaron Williams Date: Tue, 25 Jan 2011 14:30:55 -0800 Subject: [U-Boot] [PATCH 1/1] fix min/max macros in common.h Message-ID: <201101251430.55755.Aaron.Williams@caviumnetworks.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de In some of my work with the Cavium Octeon 64-bit processor I ran into a problem with the min and max macros provided in common.h. The problem occurs if x is 32-bit and y is 64-bit. In this case, y will always be truncated to 32-bits. This patch fixes this problem. -Aaron diff --git a/include/common.h b/include/common.h index d8c912d..cf5c076 100644 --- a/include/common.h +++ b/include/common.h @@ -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)