From patchwork Tue Nov 20 21:05:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Santos X-Patchwork-Id: 1775741 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 398A33FD8C for ; Tue, 20 Nov 2012 21:06:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752977Ab2KTVFX (ORCPT ); Tue, 20 Nov 2012 16:05:23 -0500 Received: from nm19-vm0.access.bullet.mail.mud.yahoo.com ([66.94.236.25]:28516 "EHLO nm19-vm0.access.bullet.mail.mud.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753467Ab2KTVFW (ORCPT ); Tue, 20 Nov 2012 16:05:22 -0500 Received: from [66.94.237.198] by nm19.access.bullet.mail.mud.yahoo.com with NNFMP; 20 Nov 2012 21:05:20 -0000 Received: from [98.139.221.55] by tm9.access.bullet.mail.mud.yahoo.com with NNFMP; 20 Nov 2012 21:05:20 -0000 Received: from [127.0.0.1] by smtp108.sbc.mail.bf1.yahoo.com with NNFMP; 20 Nov 2012 21:05:20 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024; t=1353445520; bh=JNzSQojhsAgETpMLNZMvPK3vbdDpMsJiwoSCjOByLoo=; 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=rNjhfK2Hao0UkIF2h3v4bB3Pp1vnCstzTV84Va9eXQd0oON0dsu3hgiIZ54+rHBzStYbYlU29yAz4DN8MHPeXPUqV3o9UJ1nCEWHv8nbS/hVG8zFfKlEzbbCuk6j72oJodDK6UL8p5U/Vq/wR2tYFHo46nl95Q1bcNke6d5Gic8= X-Yahoo-Newman-Id: 243390.4524.bm@smtp108.sbc.mail.bf1.yahoo.com Received: from localhost.localdomain (danielfsantos@99.70.244.137 with login) by smtp108.sbc.mail.bf1.yahoo.com with SMTP; 20 Nov 2012 13:05:20 -0800 PST X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: UWyr_xQVM1lK1T1TRR43bupvc8b0I8ZjEMyDeN7_Vx_dWY1 cGsmh9ElF5D9VCRPUrxBDTiwpFcdW2x69.XxXR37SVSzUDMdbGuCHifx6dzQ rGycaIM1gjBnkpg8lmUsFlLbFMagTmq9wWIKTlLjgqUAlxDFwMYes3id8ldl OG_RDRxigUjM2XExtgD99IcVWiK7g8mFxdDGRnEW2.I4U2eoeQCGmRlhWNYJ mtOueZZYlRimXStpenJqMliXyPKvmD9Iknkc44yplNEP7VWoxutWEbPeHC4U HYRM2AiJpYkcQWWoRt89PVKp_npzKvjki_qyGWtC1B7ifRtg.i4Z8nT9Fh.z vUHsb1jyxx2vYwRC5e61CJ5U348HkLPIAk7xK1Jcuh_NJi2_QeTdECsUWMGh 5Lu4q8YcpBe3ruiqhHW5hLwEKgq207W2cfakJWc39MzxZC2juTVCq 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 v6 6/9] bug.h: Prevent double evaulation of in BUILD_BUG_ON Date: Tue, 20 Nov 2012 15:05:04 -0600 Message-Id: <1353445507-7233-6-git-send-email-daniel.santos@pobox.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1353444132-6809-1-git-send-email-daniel.santos@pobox.com> References: <1353444132-6809-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 Acked-by: Borislav Petkov --- 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 1b2465d..98bdbb3d 100644 --- a/include/linux/bug.h +++ b/include/linux/bug.h @@ -58,8 +58,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