Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp112346imu; Mon, 19 Nov 2018 18:51:58 -0800 (PST) X-Google-Smtp-Source: AJdET5eG9oftFB7TXFU1tlsUSXRLNELX72BBgq68DzYNYlMHAGZcRx7PFkDOfb2QyqFZD3xHDhLc X-Received: by 2002:a62:8096:: with SMTP id j144mr310468pfd.140.1542682318497; Mon, 19 Nov 2018 18:51:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542682318; cv=none; d=google.com; s=arc-20160816; b=auofJrN3+LRR4S/K9F1LoniAcratwKfOpigwCgysP8G+vsTTOYltdws09IVAeQTg7x un6kELq0FXOIqHDHviOVdJ7aanS5HHhpzKX+ZPUUYVEXXw8UGFvdoLUF6YUnvSlXe8a+ Uts6BuN51Gn2X7EjeNeV1TmlFOkUe9L2TK74GIsqQTwftmjqqSicRZ8f3pBI1Tcd5CUm xLsaNBlVTKhapGY+lQ8/O4oPLrBuiGlnJz8EUTAe/sru+RvoGipl/9R26/9X/PRwwsab +V/gZJVtomfrBJA5rI4805xR/PyTKGJC5onUU4WfZOtZEY5bUI2V3IPZjqiR8ad1HNLt XDmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=qCUhewSzIc2GeOtflP1a7oilJ1RZJ0wDQCNS/6YM6Yg=; b=VGaY+dXRC2ox5es4KzwtYf3XSEmd4hQcTrSppFWxDZr/LFO+qfA2gpSnYbHeP88Tt+ 8qdgokQeCZxqJZFpBA7ukfHksdUo31N81x5G6vAJgBjJKJbW8fgQJbQPBx646SNLI45B jGacVzkTR4YRodddMtwelUw2SilZrbrLkPvCB8rQdb8okB4ERu6fj2nfiOROFk06AEQe Eg3Pu7P569AfyO9vVQxl4EYr8+2lPqC/IB7DYUoAm0lgDEAnLZlAFopIXg9x5pPpGJ5a +Bzy/MELNsyqewE2R/YkrP9phSilff+913mb4XVJM6p+g/EK7SU4UQDBczsch5aaWpca JK2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=YtV5r3l2; 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 z136si40075814pgz.28.2018.11.19.18.51.42; Mon, 19 Nov 2018 18:51:58 -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=YtV5r3l2; 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 S1730746AbeKTL5v (ORCPT + 99 others); Tue, 20 Nov 2018 06:57:51 -0500 Received: from conssluserg-03.nifty.com ([210.131.2.82]:48906 "EHLO conssluserg-03.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726119AbeKTL5v (ORCPT ); Tue, 20 Nov 2018 06:57:51 -0500 Received: from mail-ua1-f44.google.com (mail-ua1-f44.google.com [209.85.222.44]) (authenticated) by conssluserg-03.nifty.com with ESMTP id wAK1V9P2027970 for ; Tue, 20 Nov 2018 10:31:10 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-03.nifty.com wAK1V9P2027970 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1542677470; bh=qCUhewSzIc2GeOtflP1a7oilJ1RZJ0wDQCNS/6YM6Yg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=YtV5r3l2kkWeDtL2eGy0VyB6iZYp/HmBsdRlqvcknkJRJwLhY24MM2G6kXbYWKl2J KGlWnd6D8hsDsiZuBL+5Gn7jMX87ZttYRAht7L9v2wbLD+aoNeTu10AT7wMdIuoBFO Lc8TKnkZVSiTnMpXgm7BjBEMy+L+ryuisJ1QCm1pC0TjVbTDlZLAfvIoIa9CHU8fM+ 0gXP5olJB9zh5vEmXkyi8sAXnfTvtFDFlb7VVtXx3FbLX35VnFqjX1vqGBHUK5K4SC b3H00+HXP2gngT49v07ROk3zVjTa16jJpEdyiWt1NHs6fFOoWJfptB+NNA2xfZWo6E CQrODutR+MxIA== X-Nifty-SrcIP: [209.85.222.44] Received: by mail-ua1-f44.google.com with SMTP id z11so85817uaa.10 for ; Mon, 19 Nov 2018 17:31:10 -0800 (PST) X-Gm-Message-State: AA+aEWZSJD9yMT4aRnlS/yoM+eYjTQ32NGbbdZTRSpY91xTr65ER1ndQ gzXEUI+b31kB8WuRVWdoi11L3dG3fBL+vYuyh1w= X-Received: by 2002:a9f:3f41:: with SMTP id i1mr26427uaj.42.1542677469177; Mon, 19 Nov 2018 17:31:09 -0800 (PST) MIME-Version: 1.0 References: <1542623503-3755-1-git-send-email-yamada.masahiro@socionext.com> <1542623503-3755-3-git-send-email-yamada.masahiro@socionext.com> <20181119123732.zcb6axl25bixgtly@ltop.local> In-Reply-To: From: Masahiro Yamada Date: Tue, 20 Nov 2018 10:30:33 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 3/3] build_bug.h: remove most of dummy BUILD_BUG_ON stubs for sparse To: Nick Desaulniers Cc: Luc Van Oostenryck , Andrew Morton , Kees Cook , Josh Triplett , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 20, 2018 at 3:02 AM Nick Desaulniers wrote: > > On Mon, Nov 19, 2018 at 4:37 AM Luc Van Oostenryck > wrote: > > > > On Mon, Nov 19, 2018 at 07:31:43PM +0900, Masahiro Yamada wrote: > > > 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 *and* the link-time trick, like this: > > > > > > 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; \ > > > } while(0) > > > > > > Sparse is more strict about the negative array trick than GCC because > > > Sparse requires the array length to be really constant. > > > > > > Here is the simple test code for the macro above: > > > > > > static const int x = 0; > > > BUILD_BUG_ON(x); > > > > > > GCC is absolutely fine with it (-Wvla was not enabled at that time), > > > but Sparse warns like this: > > > > > > error: bad constant expression > > > error: cannot size expression > > > > > > (If you are using a newer version of Sparse, you will see a different > > > warning message, "warning: Variable length array is used".) > > > > > > Anyway, Sparse was producing many false positive warnings, hence > > > silenced. > > > > > > With the previous commit, the leftover negative array trick is gone. > > > Sparse is fine with the current BUILD_BUG_ON(), which is implemented > > > by using the 'error' attribute. (assuming your Sparse version supports > > > -Wno-unknown-attribute option) > > > > > > I am keeping the stub for BUILD_BUG_ON_ZERO(). Otherwise, Sparse > > > would complain about the following code, which GCC is fine with: > > > > > > static const int x = 0; > > > int y = BUILD_BUG_ON_ZERO(x); > > > > > > Signed-off-by: Masahiro Yamada > > > Acked-by: Kees Cook > > > > Reviewed-by: Luc Van Oostenryck > > Clang builds not affected. Tested a quick arm64 defconfig build with > Clang + this patch. > Reviewed-by: Nick Desaulniers > Tested-by: Nick Desaulniers > This patch can go in only when 1/3 is acceptable. But, I see 1/3 is controversial. -- Best Regards Masahiro Yamada