From patchwork Tue Nov 13 22:13:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Santos X-Patchwork-Id: 1736821 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 12D4A3FCAE for ; Tue, 13 Nov 2012 22:15:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754900Ab2KMWOB (ORCPT ); Tue, 13 Nov 2012 17:14:01 -0500 Received: from nm25.access.bullet.mail.mud.yahoo.com ([66.94.237.90]:27571 "EHLO nm25.access.bullet.mail.mud.yahoo.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754856Ab2KMWN7 (ORCPT ); Tue, 13 Nov 2012 17:13:59 -0500 Received: from [66.94.237.127] by nm25.access.bullet.mail.mud.yahoo.com with NNFMP; 13 Nov 2012 22:13:57 -0000 Received: from [98.138.226.244] by tm2.access.bullet.mail.mud.yahoo.com with NNFMP; 13 Nov 2012 22:13:57 -0000 Received: from [127.0.0.1] by smtp115.sbc.mail.ne1.yahoo.com with NNFMP; 13 Nov 2012 22:13:57 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=att.net; s=s1024; t=1352844837; bh=QQ+8ufTswLp+Djnpnya9T8fG5QHpS1gdZKabpH1TZh8=; h=X-Yahoo-Newman-Id:Received:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:From:To:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=a2SP9EgpkKKSKJVjpz//7nYyG5MUoC4/9QY3EYBvTCQcEsE6S6H15NvGvKI5HhLeSWZiiCjPI3T/JTfJ5pGlUT7yVGK7HmcjTL8Y+rbfjPc2CIrSRz3HJMblQ85tu6RfsE7DekkcMTadAj7Q57eBTHS0LiKTt3g1K/bt9xiLtc0= X-Yahoo-Newman-Id: 901629.28409.bm@smtp115.sbc.mail.ne1.yahoo.com Received: from localhost.localdomain (danielfsantos@99.70.244.137 with login) by smtp115.sbc.mail.ne1.yahoo.com with SMTP; 13 Nov 2012 14:13:57 -0800 PST X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: Cotpxm8VM1lHs32QvPqceHomGPygDY5eVLW5RmwDS.Jhqvc ubfOLgL1eSM7jSM6uxKtceHkqgDi2FqP8qjUjcAszekFoY.atcpJhgJ1tITL T842xJijiKVOfXRyrmZaibMLqtMzo5Gn4Kv1k8EJ8Ybq_MBcPwngOvJP8QX4 PenTWLrQqFzeQ1Ei2df3.ccPZS.FceLQ3LQQYfq9WdC5JgTw9RUUGV6ak66U J6NBhvAKSZ_5Fne6zFcicQ8TNesuUQsqITYGCl6Txb_k1WOYRSD2qC3oO357 UI.oCSJ5c..5kQKTwVQuNrSmbVg45LwtdvT67sin0dfTs6droE.jKgwDNWSE v4U3s5zWnzYepwZEyp8_gFrJjTPb3T.CycsmEE5qPzZDw4FxamwKaNrsJqOp tEIRrD2_dIhx7XfIx4jBT5bif72tajnvWUp9HLyAKU2GRnQrqk_nkqnFjLqV _qVuM6K_38vQuevOFEuiOQa73iEzc X-Yahoo-SMTP: xXkkXk6swBBAi.5wfkIWFW3ugxbrqyhyk_b4Z25Sfu.XGQ-- From: danielfsantos@att.net To: LKML , Andi Kleen , Andrea Arcangeli , Andrew Morton , Borislav Petkov , Christopher Li , Daniel Santos , David Daney , David Howells , Joe Perches , Josh Triplett , Konstantin Khlebnikov , linux-sparse@vger.kernel.org, Michel Lespinasse , Paul Gortmaker , Pavel Pisa , Peter Zijlstra , Steven Rostedt Subject: [PATCH v5 6/9] bug.h: Prevent double evaulation of in BUILD_BUG_ON Date: Tue, 13 Nov 2012 16:13:38 -0600 Message-Id: <1352844821-18952-6-git-send-email-daniel.santos@pobox.com> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1352844568-18826-1-git-send-email-daniel.santos@pobox.com> References: <1352844568-18826-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 1b2465d..ccd44ce 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