Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp972691imu; Thu, 22 Nov 2018 08:06:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/XiN8BeXJ8YAnj+xKL8x4BMQcxREMYJYnbEoO0tBFFtnjtBHuYT8Y4eTeK8ZInJRP+Z33LP X-Received: by 2002:a63:5c41:: with SMTP id n1mr10186961pgm.1.1542902817022; Thu, 22 Nov 2018 08:06:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542902816; cv=none; d=google.com; s=arc-20160816; b=uuN5lRAMDKsHrgmef3Elyi/z+Q2rSe/J0vMvtgQ4AK9BIB+Gm3PmDUb5QnqcjKTXCJ sAVBZQY7krN15U8wn8cuxOU7PzVlWsYxQv4A0q728FMC50cvxZynUglZ7ZBHDIrASLtZ 1uwscVnsiggOJGA3q9M1HtjTNAH62u1nDzR4iX2XujrzG4Es8y2JzBmNZ5JmJBVHiYQU RlE28mNOUbrCzaULdhnZBx1j4YqglmZKno6/LCq3Y/W19oaP9ELDs9d0AdrI6NBmNPLM a6Y9jpEuPGPYVn8TKZYBw2Tc1CSyfJULMxNDrmWYGJK0+kq8PtaUz12+piKTeU42jxXb v+lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=EC6OrDl+Pe6xGCqyh6yaEOjJ/Vdp3qzeTiZNHyrNG5o=; b=wbdW98i+SiiaPRglB/LysITc1HU2M4IP6e3fTCvgO4PLCWFtcHSmQvgTSoIfroDRH5 jm34vaNLbUfL9jl8KNIz6n3EVFISPTJv069BxgBWaaXhjTyUH8VtkJCErzAngtah2szb yPcG0y7K66fegnVinSeAhwoE8CjfJDnV5wTVxtumcJcI9tfREbsj1gjIsW5bRRw8HXpD qyXJfaRFRsJ2AazoPDgA745SGkvgZDGeCl99Yw53pYql+gjKdD0s4P0Po3d95u5nzUhd SsbdzKgu7qa7UlBrVBS3yJPZznxTsT5NrlgY4+x17TO+jcdMzHhue+K1nTWRYIKf2IAa MgdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=hjyuNNvk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v9si24682223pfl.45.2018.11.22.08.06.41; Thu, 22 Nov 2018 08:06:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=hjyuNNvk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391978AbeKVNw7 (ORCPT + 99 others); Thu, 22 Nov 2018 08:52:59 -0500 Received: from conuserg-09.nifty.com ([210.131.2.76]:51145 "EHLO conuserg-09.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732521AbeKVNw6 (ORCPT ); Thu, 22 Nov 2018 08:52:58 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id wAM3EZ3F004964; Thu, 22 Nov 2018 12:14:36 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com wAM3EZ3F004964 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1542856476; bh=EC6OrDl+Pe6xGCqyh6yaEOjJ/Vdp3qzeTiZNHyrNG5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hjyuNNvk1c0hopbgMPdWHghO38rHW7Rz523ZlAlLjuR/jZmbg6xv4y+/rflnb9sBg 6EDX192L0HhoEauJNDUcu0HY4X1StRdrXVGIRdAxerPOq5wIG17vsHbOuigF5eSbAi o58qT/ZTRPQpS6dNngbRbYl+ZWg1kjqbVZsWroUPWRL5RXRinTVQaGp8JYesvWJL9v s+8LZpxlVughcuzhgj5Idqpxj8zbbHJ649AZb/+LbG9/cOVISpDnlafXPVmeccpXUA pqDBojJ/khiBqbo0COGx6FPXoa1/bJ9mPvIfZ9J936PmSR7mUQui0u+4BupNKBceoy s6cDpCfY/vHbg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Andrew Morton Cc: Luc Van Oostenryck , Nick Desaulniers , Kees Cook , Josh Triplett , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v4 2/3] build_bug.h: remove negative-array fallback for BUILD_BUG_ON() Date: Thu, 22 Nov 2018 12:14:21 +0900 Message-Id: <1542856462-18836-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542856462-18836-1-git-send-email-yamada.masahiro@socionext.com> References: <1542856462-18836-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kernel can only be compiled with an optimization option (-O2, -Os, or the currently proposed -Og). Hence, __OPTIMIZE__ is always defined in the kernel source. The fallback for the -O0 case is just hypothetical and pointless. Moreover, commit 0bb95f80a38f ("Makefile: Globally enable VLA warning") enabled -Wvla warning. The use of variable length arrays is banned. Signed-off-by: Masahiro Yamada Acked-by: Kees Cook Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers --- Changes in v4: None Changes in v3: None Changes in v2: None include/linux/build_bug.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/include/linux/build_bug.h b/include/linux/build_bug.h index 43d1fd5..d415c64 100644 --- a/include/linux/build_bug.h +++ b/include/linux/build_bug.h @@ -51,23 +51,9 @@ * If you have some code which relies on certain constants being equal, or * some other compile-time-evaluated condition, you should use BUILD_BUG_ON to * detect if someone changes it. - * - * The implementation uses gcc's reluctance to create a negative array, but gcc - * (as of 4.4) only emits that error for obvious cases (e.g. not arguments to - * inline functions). Luckily, in 4.3 they added the "error" function - * attribute just for this type of case. Thus, we use a negative sized array - * (should always create an error on gcc versions older than 4.4) and then call - * an undefined function with the error attribute (should always create an - * error on gcc 4.3 and later). If for some reason, neither creates a - * compile-time error, we'll still have a link-time error, which is harder to - * track down. */ -#ifndef __OPTIMIZE__ -#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) -#else #define BUILD_BUG_ON(condition) \ BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) -#endif /** * BUILD_BUG - break compile if used. -- 2.7.4