From patchwork Fri Jul 26 14:18:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mischa Jonker X-Patchwork-Id: 262162 X-Patchwork-Delegate: panto@antoniou-consulting.com 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 878D12C00A3 for ; Sat, 27 Jul 2013 00:19:38 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 781224A01E; Fri, 26 Jul 2013 16:19:30 +0200 (CEST) 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 b0coAazVHZYQ; Fri, 26 Jul 2013 16:19:30 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B2EB34A01B; Fri, 26 Jul 2013 16:19:25 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7C83A4A01B for ; Fri, 26 Jul 2013 16:19:18 +0200 (CEST) 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 TZPVNUamHQQq for ; Fri, 26 Jul 2013 16:19:12 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 BL_NJABL=ERR(-1.5) (only DNSBL check requested) Received: from hermes.synopsys.com (hermes.synopsys.com [198.182.44.81]) by theia.denx.de (Postfix) with ESMTP id B4A4F4A019 for ; Fri, 26 Jul 2013 16:19:02 +0200 (CEST) Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by hermes.synopsys.com (Postfix) with ESMTP id B7A5BDA3F; Fri, 26 Jul 2013 07:18:58 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id A78C944F; Fri, 26 Jul 2013 07:18:58 -0700 (PDT) Received: from mischa-VirtualBox.internal.synopsys.com (mischa-virtualbox.internal.synopsys.com [10.100.24.25]) by mailhost.synopsys.com (Postfix) with ESMTP id 99AEB44B; Fri, 26 Jul 2013 07:18:56 -0700 (PDT) From: Mischa Jonker To: u-boot@lists.denx.de Date: Fri, 26 Jul 2013 16:18:41 +0200 Message-Id: <1374848321-15002-2-git-send-email-mjonker@synopsys.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1374848321-15002-1-git-send-email-mjonker@synopsys.com> References: <1374848321-15002-1-git-send-email-mjonker@synopsys.com> Cc: Marek Vasut , Anton Staaf , Alexey Brodkin , Tom Rini , Mischa Jonker Subject: [U-Boot] [PATCH 2/2] Add parentheses to ALLOC_ALIGN_BUFFER macro's X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Without those it's very easy to make mistakes when for instance the 'size' field is more than just a constant. Signed-off-by: Mischa Jonker Cc: Alexey Brodkin Cc: Marek Vasut Cc: Anton Staaf Cc: Tom Rini Cc: Wolfgang Denk --- include/common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/common.h b/include/common.h index 8addf43..cc7454a 100644 --- a/include/common.h +++ b/include/common.h @@ -1015,10 +1015,10 @@ static inline phys_addr_t map_to_sysmem(void *ptr) * of a function scoped static buffer. It can not be used to create a cache * line aligned global buffer. */ -#define PAD_COUNT(s, pad) ((s - 1) / pad + 1) +#define PAD_COUNT(s, pad) (((s) - 1) / (pad) + 1) #define PAD_SIZE(s, pad) (PAD_COUNT(s, pad) * pad) #define ALLOC_ALIGN_BUFFER_PAD(type, name, size, align, pad) \ - char __##name[ROUND(PAD_SIZE(size * sizeof(type), pad), align) \ + char __##name[ROUND(PAD_SIZE((size) * sizeof(type), pad), align) \ + (align - 1)]; \ \ type *name = (type *) ALIGN((uintptr_t)__##name, align)