From patchwork Fri Nov 16 06:19:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 151282 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp39565ljp; Thu, 15 Nov 2018 22:20:49 -0800 (PST) X-Google-Smtp-Source: AJdET5eLkRlyNyRz+6ixZ3ABlTrVLA8v0oofHG8IwVU9ANIzuDyQvRtk4HlwHzJ7gb9R8C1ON/rZ X-Received: by 2002:a17:902:6b87:: with SMTP id p7-v6mr9631212plk.282.1542349249388; Thu, 15 Nov 2018 22:20:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542349249; cv=none; d=google.com; s=arc-20160816; b=y9KFFahHFXtMdeJhE8wjB8ihh826hUiGPI6ZxQwe6zyhAfBAYcpX9y0R42kC2gPYmC 3YETSfZYcQybOBYjWkjKNkpc/fvFcQbtmBR7/X8r+psXsPqhKiKURLvCa36txxyDxQEH EbF/sXTe03eOOqwtSrz0OtAxLm1RaYxjncPk+FzfLztXr8zB36MUfQHHvHRQfQfq+JS5 Wx2XrWPwXEsDvkK82vmIInlgrLNV/tF5Slxn+SxtpDatKUldEbgygwhz/jyYmJafDjb5 CB+vu9AfEPPDl7KPjTkF+x61BK4H2UzJqDss0F725r237tgAbJWs6bbopWX1U2wwQev4 w/VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=b7bIis8GuYOhefMZ1/UmXoVBCnD/P6pVfgD6PBk3yw8=; b=vARDVcUff/Y84qG9TIJ7FzrveAoFehaEYVVRXVBTMGQ3iCapJgR6fv3VmfIut6b16s rgn+asg8oUAfKXfMtNfX6jqfg2KuuPx9BzaWLxZKyaEo1LBp1KTzNGXjZ23LKtVLQodK L/J8nQdNVViSq9Y4N/vORxphm+etu0D2Gdv/33eNQyhaPOLMjMjwlZOonxY9dedSF89h wD9r8Jh/WmmP3kePE84KhBuv3Z8jmmyIHji9MgWzreqaE7taKErc6D8tWmG88SbIE+8j w1j655ZgOdvFBhjihRbXanCWaqUT7tnvb7MDUT1fmJnBAcxyiF0eWd0dBkKe0TL29pZ6 DStQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=WMmNUH9l; 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 h7si9539188pls.326.2018.11.15.22.20.49; Thu, 15 Nov 2018 22:20:49 -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=WMmNUH9l; 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 S2389249AbeKPQbs (ORCPT + 32 others); Fri, 16 Nov 2018 11:31:48 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:50717 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727377AbeKPQbs (ORCPT ); Fri, 16 Nov 2018 11:31:48 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id wAG6Jp5F005743; Fri, 16 Nov 2018 15:19:51 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com wAG6Jp5F005743 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1542349191; bh=b7bIis8GuYOhefMZ1/UmXoVBCnD/P6pVfgD6PBk3yw8=; h=From:To:Cc:Subject:Date:From; b=WMmNUH9lCidfCyu0kwH4Mq1kZy4FuXg44vJ+39ktGCQz/SLOWVvj9qxru7lJN7+QY lBOJc8GBriuZdv27UPMFxiGObkQD+IrEVZAk/hOnOaQqcQVmVpqKMrWBpxHkb3Nsvv ds45N//wDh88Q9VgECNAqaTVq5759rasfsHXhvV06+w6HMHpyLsgk/VbC7Hn6VLH1v 1d9ah9W/znywOm0q6ZwPZK40lSPI1ePRBq3FOVMui47K8yzvilvmFjwrMcRMv0jYbB hBaPnn9ozQrZsLZgKXUW0HRxHHWKQ5KLCMLNbcXI5wkrVDjUaZZPd78BvdKMy/YRSt 9oemg5Lh7j5/w== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Andrew Morton Cc: Linus Torvalds , Arnd Bergmann , Kees Cook , Nick Desaulniers , Miguel Ojeda , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] build_bug.h: remove negative-array fallback for BUILD_BUG_ON() Date: Fri, 16 Nov 2018 15:19:00 +0900 Message-Id: <1542349141-7229-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 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. A fallback for -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 --- include/linux/build_bug.h | 14 -------------- 1 file changed, 14 deletions(-) -- 2.7.4 Acked-by: Kees Cook Acked-by: Miguel Ojeda 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. From patchwork Fri Nov 16 06:19:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 151283 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp39585ljp; Thu, 15 Nov 2018 22:20:51 -0800 (PST) X-Google-Smtp-Source: AJdET5dEz179UGyd13XofKAe1raiw4W0SZ2bo1ljaeijtvgrvLwSQbD/BS+sx3Hl5wYMC4PHE/ch X-Received: by 2002:a17:902:108a:: with SMTP id c10-v6mr9276870pla.171.1542349250911; Thu, 15 Nov 2018 22:20:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542349250; cv=none; d=google.com; s=arc-20160816; b=mgPdKk6Zqsm0rypQEZwMZ5AoTs7rGo+S/qiBBav/RNtXz9qZtUOP768M5RzLfsFtpc o3rQgvvNXqYzCSjq9axkcL1EW2kQ/KrmX637CZ93AFV+JWtZrOa8VMdEUNTlhPjsvpXZ 2K67ctHUPXdCK97xG0xq616M3NplsvC39qCKXSXMB+a27TzdU7PS3sBTLxZ6whp3LMqi yqV9MLHvXT4ZP1S76e1chO3WzlQr1RqzzOwaRPCNCOKJ9h8TqZAwWbMpT6VUoK+Tj4ww MitFZqpYcGQXDjLeYCIZaY1yu/5aytSnXW8KGy1TPfzymb6iJ07t5UynInwQDqHAgKEr JMdA== 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=WR2halLsHQdGN9ZbpibG6kScGLBXaoZnZSO1D3qzw/o=; b=MJaMTNsNVMTtfxYuxgsXxA0o1ZLofBssDoO/Rsu+Abxscwpn9CdBsSl4VFMGUMiF1V QM6LOZfJhC2g+1M+cvtUoj73p0WmBRk6tgGS+0OqUXuaZMCHlecq32xWgiMnwTgez253 rTRbTgNIlwc6b++x1CzkQzqnXjPBGgpaCI+ih/P22hNZ+gWdJn0EfwHdLs0SK1E+L2Lm 7gycFi7ET6cB+OzNFOQaVuW/LThfwhLSkhusQqfiidenHgAxxpTpCsMrHqQTBNwI3Iwc uXWlV4QjBKdz3yiGFqzRYM8REoKj26Vy4tIAV2QzCm1rL7SFOiA9/w39+WM2kPWmaY4Y Uegw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=XDJqom5z; 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 d12-v6si31622773pla.24.2018.11.15.22.20.50; Thu, 15 Nov 2018 22:20:50 -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=XDJqom5z; 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 S2389336AbeKPQbt (ORCPT + 32 others); Fri, 16 Nov 2018 11:31:49 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:50718 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727370AbeKPQbs (ORCPT ); Fri, 16 Nov 2018 11:31:48 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id wAG6Jp5G005743; Fri, 16 Nov 2018 15:19:52 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com wAG6Jp5G005743 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1542349192; bh=WR2halLsHQdGN9ZbpibG6kScGLBXaoZnZSO1D3qzw/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XDJqom5zKTaf2CG18WGGQ2LcpgcBlSSIJLlVwR4pngzqyoq3Ljlz+/7OFckbhYi8S pN5JQg1Lqwdxt1Um/+loQnaIetbNfcyoeDXMXdbAb3YapaMj0StcoQ/ByJJnxvrE3g GRWpPaJRICdhad7MlcnRwoM8RU3axoSfMjwpeULPxFuY1dKzXdBSV+J0DBzNRgsrIX Mn+UOeKapRIWBIjK/5yzPtzzggeELJ6RYXV8EmXQ/7FGf7mHU9qG/6LTxmeP1kedaM JSa9mT4O7noU4khtb2LAiv250KttCdn/O2ARSU6an5O1ZsVyvqPlccko3SFwz4a6fJ kOy2iqtSiOODQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Andrew Morton Cc: Linus Torvalds , Arnd Bergmann , Kees Cook , Nick Desaulniers , Miguel Ojeda , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] build_bug.h: remove all dummy BUILD_BUG_ON stubs for sparse Date: Fri, 16 Nov 2018 15:19:01 +0900 Message-Id: <1542349141-7229-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542349141-7229-1-git-send-email-yamada.masahiro@socionext.com> References: <1542349141-7229-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 introduction of these dummy BUILD_BUG_ON stubs dates back to commit 903c0c7cdc21 ("sparse: define dummy BUILD_BUG_ON definition for sparse"). At that time, BUILD_BUG_ON() was implemented with the negative array trick, which Sparse complains about even if the condition can be optimized and evaluated to 0 at compile-time. With the previous commit, the leftover negative array trick is gone. Sparse is happy with the current BUILD_BUG_ON(), which is implemented by using the 'error' attribute. There might be a little room for argument about BUILD_BUG_ON_ZERO(). Sparse reports 'invalid bitfield width, -1' for non-zero value, and 'bad integer constant expression' for non-constant value. This is the same criteria as GCC uses. So, if those Sparse errors occurred, they would cause errors for GCC as well. (Hence, such errors would have been detected by the normal compile test process.) Signed-off-by: Masahiro Yamada --- include/linux/build_bug.h | 11 ----------- 1 file changed, 11 deletions(-) -- 2.7.4 diff --git a/include/linux/build_bug.h b/include/linux/build_bug.h index d415c64..b0828f7 100644 --- a/include/linux/build_bug.h +++ b/include/linux/build_bug.h @@ -4,16 +4,6 @@ #include -#ifdef __CHECKER__ -#define __BUILD_BUG_ON_NOT_POWER_OF_2(n) (0) -#define BUILD_BUG_ON_NOT_POWER_OF_2(n) (0) -#define BUILD_BUG_ON_ZERO(e) (0) -#define BUILD_BUG_ON_INVALID(e) (0) -#define BUILD_BUG_ON_MSG(cond, msg) (0) -#define BUILD_BUG_ON(condition) (0) -#define BUILD_BUG() (0) -#else /* __CHECKER__ */ - /* Force a compilation error if a constant expression is not a power of 2 */ #define __BUILD_BUG_ON_NOT_POWER_OF_2(n) \ BUILD_BUG_ON(((n) & ((n) - 1)) != 0) @@ -64,6 +54,5 @@ */ #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed") -#endif /* __CHECKER__ */ #endif /* _LINUX_BUILD_BUG_H */