From patchwork Tue Feb 1 03:55:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Williams X-Patchwork-Id: 81265 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id DA2A0B7102 for ; Tue, 1 Feb 2011 14:56:01 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 00E542819F; Tue, 1 Feb 2011 04:56:00 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cQG6uzqgwCRQ; Tue, 1 Feb 2011 04:55:59 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C605728186; Tue, 1 Feb 2011 04:55:58 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1AE8428186 for ; Tue, 1 Feb 2011 04:55:57 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Uq0ahHQwg+f1 for ; Tue, 1 Feb 2011 04:55:55 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail3.caviumnetworks.com (unknown [12.108.191.235]) by theia.denx.de (Postfix) with ESMTP id 0A70028182 for ; Tue, 1 Feb 2011 04:55:53 +0100 (CET) Received: from caexch01.caveonetworks.com (Not Verified[192.168.16.9]) by mail3.caviumnetworks.com with MailMarshal (v6, 7, 2, 8378) id ; Mon, 31 Jan 2011 19:56:42 -0800 Received: from caexch01.caveonetworks.com ([192.168.16.9]) by caexch01.caveonetworks.com with Microsoft SMTPSVC(6.0.3790.4675); Mon, 31 Jan 2011 19:55:51 -0800 Received: from awilliams-suse.localnet ([12.108.191.236]) by caexch01.caveonetworks.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Mon, 31 Jan 2011 19:55:51 -0800 From: Aaron Williams To: u-boot@lists.denx.de Date: Mon, 31 Jan 2011 19:55:50 -0800 User-Agent: KMail/1.13.6 (Linux/2.6.34.7-0.7-desktop; KDE/4.5.5; x86_64; ; ) MIME-Version: 1.0 Message-Id: <201101311955.50902.Aaron.Williams@caviumnetworks.com> X-OriginalArrivalTime: 01 Feb 2011 03:55:51.0204 (UTC) FILETIME=[EAC95E40:01CBC1C3] Subject: [U-Boot] [PATCH 1/1] Fix min/max macros in include/common.h X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de 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 include/common.h | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) 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)