From patchwork Fri Nov 16 06:27:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 151285 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp45475ljp; Thu, 15 Nov 2018 22:28:50 -0800 (PST) X-Google-Smtp-Source: AJdET5fhWkYD4L/9mUO+xS2ye3SS4uvkdlUKy4ZRAFUvr/c0B+GLvcFl6KBLrpohgp95fwvePCN1 X-Received: by 2002:a65:48c4:: with SMTP id o4mr8530746pgs.371.1542349730330; Thu, 15 Nov 2018 22:28:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542349730; cv=none; d=google.com; s=arc-20160816; b=epxSATtc8xkrr05hz+aX5wcEeRg87hyOKEr1azaJYbDoaQHStjNOKEYiDSj7v18YUX 3GXuhM/A674GixgX4ZGb/K9TFvNZ9JvZ7/aZ2ql+f4yuunKxERAQVkd6NDKmXgWd2ND2 j29cUgyLANemTsB3HRBQQnG49EaTrNesyaO9cidgIWRkd4ZQr25NNw2DqE/ff1Zn8MbE RjhvHf3Jx4W77cSqUss5xyxI4Fd2gPf9t/bNP5m+MVeVEwCU8F3+k6gqYGkFSpy8L1Fd J3IzoogcK2Yn8mDT0mWuw8drVl/Rln9uSH7jFdEZeLoxiEQmVoHV/ujHYtSKMIni7Inn pMaw== 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=AE9HOGag1iWONloFmWzxxe9Ll1Q5kgvlETsrHKesQQI=; b=fVtjX8FHJ9yxYV9ywKfAHSHvGIap8vh+5yMgELuhhjtbM8HqBiep+mjAJR6UTyTmqm IKTd9KgPe83t1jSbY3TDuaBTH2jBd+jJ/3qd4LZanMAQYlPc5Q7hPiK+qw0RLrLIsoA/ V1Eqq5/UV3VSjAYaevRWLmppFZ1hlmX2XCxe6y3D0nZiiAuhJnY6po4diBqyeaqA3TF6 FOU/xwFLHaLuqk/4//cDwU+zLNb2mnYU9mMr6tHQ8TXayaQZhAp4u7anwOiNTe/y3eBQ XMwdCBGPeNMdrwSlq75AACk1d+P15r4KECnc9FF7cJs258J9cDk9LqN98VL975QS+z5+ +bEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=axIo3gH5; 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 g8-v6si641594pfm.9.2018.11.15.22.28.50; Thu, 15 Nov 2018 22:28: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=axIo3gH5; 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 S2389154AbeKPQjq (ORCPT + 32 others); Fri, 16 Nov 2018 11:39:46 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:37122 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727353AbeKPQjq (ORCPT ); Fri, 16 Nov 2018 11:39:46 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id wAG6RdQR027653; Fri, 16 Nov 2018 15:27:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com wAG6RdQR027653 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1542349660; bh=AE9HOGag1iWONloFmWzxxe9Ll1Q5kgvlETsrHKesQQI=; h=From:To:Cc:Subject:Date:From; b=axIo3gH550BuYi8ju/zKpAPo4jB7f8KwnMfWuFjs05q0QLVBAlwjADUfypkd4eUiQ TrjazYvtYtLe1RcW32UTiu902FVodQzx2+vBu45JC893f4z8IXhGDupn5KvvQ3TGU5 0XuBeWctGjqYoboM5soYsA/C5AOiR/Axu35otKPa8nwvbV8I/+5IsgdiDa0DnxnrMp iDo2ytrEFRSBqC8P55m3jTlQC00wBW5cDhxULlMyzY6CdxFLsz4APwKgX7CS1fQHiy CThKwQYlakP/JbtAqEm/pXS8HA5rYCj/KxtjgO31vfq8tm2Qo3t7RRE35XXN76zdFO 1xIPfAyUhYz3g== 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 v2 1/2] build_bug.h: remove negative-array fallback for BUILD_BUG_ON() Date: Fri, 16 Nov 2018 15:27:24 +0900 Message-Id: <1542349645-8852-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. The 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 --- Changes in v2: None include/linux/build_bug.h | 14 -------------- 1 file changed, 14 deletions(-) -- 2.7.4 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:27:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 151284 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp45406ljp; Thu, 15 Nov 2018 22:28:46 -0800 (PST) X-Google-Smtp-Source: AJdET5cAxF9uyvvMdJCI65XRBmCqXPVC071j1WbVhdoxP8IeeAA8/UYiSDBf+a0i1q+o48qe6XMw X-Received: by 2002:a62:a511:: with SMTP id v17-v6mr9737835pfm.18.1542349726319; Thu, 15 Nov 2018 22:28:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542349726; cv=none; d=google.com; s=arc-20160816; b=gfvw//96hDEJRqboqY8VPJ7lz4CyWgcBXBSIURvBIgWoQQvPpE4ikgQAsMNTvHbgwX XyrciIOCH/JN+TklDqqgN0JCGU/+Fjb8xm+TtAzZUIpCGVB6iXCLmK7LQO7gFW0OqGm3 4R7t9W76rP2cDeQJOrI4LFOiCMoKModM+FKPaSUDn7GQDZGWtzGcbsAuXNyzMOk9lmjP DWDuCW47ES4C4suvXZkXLj4UMhII3dx3+OgiAtsgwrhqQQWFUkZrV0p5RePnzzO4ORd/ PFqEYw5pDGpbmd7M/B6n9LXFlHpuZSFer1E8+OsC6pHro3v4nLyyH/r/yOC5uNQdlfPl n+Ag== 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=FiMb9cm5cfC+tJ2DzG8B1uvbIVBWDvJqcdJNHmLq8dg=; b=Er769bqoieQEVq5JvVyoa6MwvV5diVrMyv9QjI4O42+b7JIocAwHbVrLlw9mBiuQoL Em37OCRA28JchvfK6IiYTEa/DG6v1yJE9kyyg94GT8FneJBrIT+pza1HVGQuIeDqYAB9 HUc3mHQiOqTSyravS4KtclwqTKKZAn0fB230JX/N0CezzGit6xSfBfDsQYhqU395yvS6 xZOXbf29dv/gopXc48KjXC4zHNP3Uz7QG7T8YaIMKaikrWhpinR7U6SxJZoqnZMEcLhk s7DX7iKf0J8nQrXBj8uPE1iF5e/MdZizN/HmTQ0wp0uBhmgoO+1Z/ZzyKzPURgrT2PgW YGZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=KTje1eHJ; 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 g8-v6si641594pfm.9.2018.11.15.22.28.45; Thu, 15 Nov 2018 22:28:46 -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=KTje1eHJ; 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 S2389283AbeKPQjq (ORCPT + 32 others); Fri, 16 Nov 2018 11:39:46 -0500 Received: from conuserg-08.nifty.com ([210.131.2.75]:37123 "EHLO conuserg-08.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727644AbeKPQjq (ORCPT ); Fri, 16 Nov 2018 11:39:46 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-08.nifty.com with ESMTP id wAG6RdQS027653; Fri, 16 Nov 2018 15:27:40 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-08.nifty.com wAG6RdQS027653 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1542349661; bh=FiMb9cm5cfC+tJ2DzG8B1uvbIVBWDvJqcdJNHmLq8dg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KTje1eHJ34nH0lQ8mleBtj+7Jr/c+y3AIs9EhiKH3tMvMIETEPRxGzrHleaR9FU8J k1ZX8ij6A+xTf7QqkpBsgaVYEc5ylOimFYr4pba4V/GxDVDOV0UA43E/ccIKmxdPOt ushtFWGMnbYMeDwndSxvhr+w64vTl6U/7U0AcWJY/Y5b678Re55r8DGvmTPR+hQJQs PHGqi4LfNRoqdhhATzaV1gOc8mqNzOi6Us0lu0URNpmP7qR2LEek8rtd0MgLamXET4 RyvQzBvPmuDgvkx1/j+AZkgiBQET65WZkE6jE3vpBJiwN+TjjHANxqSPSaHnYklULd XcnmncRyW4tNQ== 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 v2 2/2] build_bug.h: remove all dummy BUILD_BUG_ON stubs for sparse Date: Fri, 16 Nov 2018 15:27:25 +0900 Message-Id: <1542349645-8852-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542349645-8852-1-git-send-email-yamada.masahiro@socionext.com> References: <1542349645-8852-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 --- Changes in v2: - Fix a coding style error (two consecutive blank lines) include/linux/build_bug.h | 12 ------------ 1 file changed, 12 deletions(-) -- 2.7.4 Acked-by: Kees Cook diff --git a/include/linux/build_bug.h b/include/linux/build_bug.h index d415c64..6625c88 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,4 @@ */ #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed") -#endif /* __CHECKER__ */ - #endif /* _LINUX_BUILD_BUG_H */