From patchwork Tue Jan 1 21:09:54 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Santos X-Patchwork-Id: 1922211 Return-Path: X-Original-To: patchwork-linux-sparse@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 83DD93FF0F for ; Tue, 1 Jan 2013 21:16:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752509Ab3AAVQj (ORCPT ); Tue, 1 Jan 2013 16:16:39 -0500 Received: from nm1-vm0.access.bullet.mail.sp2.yahoo.com ([98.139.44.94]:29610 "EHLO nm1-vm0.access.bullet.mail.sp2.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752450Ab3AAVQi (ORCPT ); Tue, 1 Jan 2013 16:16:38 -0500 Received: from [98.139.44.100] by nm1.access.bullet.mail.sp2.yahoo.com with NNFMP; 01 Jan 2013 21:10:16 -0000 Received: from [98.138.84.175] by tm5.access.bullet.mail.sp2.yahoo.com with NNFMP; 01 Jan 2013 21:10:16 -0000 Received: from [127.0.0.1] by smtp109.sbc.mail.ne1.yahoo.com with NNFMP; 01 Jan 2013 21:10:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024; t=1357074616; bh=yTp1/2jY91stMtZoOt4tWep6Ldz4VaF0W9JKQHE0OzQ=; h=X-Yahoo-Newman-Id:Received:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=XfkPF+X08HBHweg1axxtNvSV59gTZYOtCszyUfM8h7rsL8y8Fl7gLbpEYfx+5WK7m+G3qKo7kjk8dp6f9ODCVJfBjpEPMXZ1CrvJztBw/EPjqRzIJiYDpJ0DCtQRw/ZTQqu+h1mb5hvBYOzTE6XLccHAbWOGWHsTHY2dchkCzrM= X-Yahoo-Newman-Id: 120148.17119.bm@smtp109.sbc.mail.ne1.yahoo.com Received: from localhost.localdomain (danielfsantos@99.70.244.137 with login) by smtp109.sbc.mail.ne1.yahoo.com with SMTP; 01 Jan 2013 13:10:16 -0800 PST X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: Ce2lUVwVM1mQWqgDjHAl2TQF8rI2K0HmZ84mOkFDP08Q0ie SeBP48raLfzLYaCyBZ0ZN.lpnTV05CHMo7dlAkkyJ8I3OSAWdDu6tFQIVEVK skwJ7e1tNHfiLm7mZ41oYDMMpzDAlXDWThhr6.ziGZpFJTLqGaC.B1xdZYNO xOXqzNbCHJJxcXigtDKyRKa9Mxxp_rcdPhmQTueSoDzThTyg1yS8MZXpgs0W 7lsgci7lojQ_dfmMBqwSecyC7jNpLbk4T8xhdFPIHy1_JZlfoVwkkrPjCKwz mRxjkOuUF5JLC4KS8.W6awvw9VZsIUrpDBzhNoKeEsVIpqiku_2BiXXn7v4n gT4Z4UwRdsddCgTap9q3S.RALx6lljU2LI493_whqQySwApvbSvm7_H40y73 vtXyAGGCI_S.v4.09l.UurNMvoATJI0hOhiL0tbxxxxpUevcgvF.8bRwQqxf g3qM_YGgUps5W2nRzXl4h7P_dAoo. X-Yahoo-SMTP: xXkkXk6swBBAi.5wfkIWFW3ugxbrqyhyk_b4Z25Sfu.XGQ-- From: danielfsantos@att.net To: LKML , Andi Kleen , Andrea Arcangeli , Andrew Morton , Borislav Petkov , Christopher Li , David Daney , David Rientjes , Joe Perches , Josh Triplett , linux-sparse@vger.kernel.org, Michel Lespinasse , Paul Gortmaker , Peter Zijlstra , Steven Rostedt Cc: Daniel Santos Subject: [PATCH v7 6/9] bug.h: Prevent double evaulation of in BUILD_BUG_ON Date: Tue, 1 Jan 2013 15:09:54 -0600 Message-Id: <1357074597-21722-6-git-send-email-daniel.santos@pobox.com> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1357074597-21722-1-git-send-email-daniel.santos@pobox.com> References: <1357074491-21669-1-git-send-email-daniel.santos@pobox.com> <1357074597-21722-1-git-send-email-daniel.santos@pobox.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org When calling BUILD_BUG_ON in an optimized build using gcc 4.3 and later, the condition will be evaulated twice, possibily with side-effects. This patch eliminates that error. Signed-off-by: Daniel Santos --- include/linux/bug.h | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/bug.h b/include/linux/bug.h index 27d404f..0d75762 100644 --- a/include/linux/bug.h +++ b/include/linux/bug.h @@ -59,8 +59,9 @@ struct pt_regs; extern int __build_bug_on_failed; #define BUILD_BUG_ON(condition) \ do { \ - ((void)sizeof(char[1 - 2*!!(condition)])); \ - if (condition) __build_bug_on_failed = 1; \ + bool __cond = !!(condition); \ + ((void)sizeof(char[1 - 2 * __cond])); \ + if (__cond) __build_bug_on_failed = 1; \ } while(0) #endif