Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3251169imu; Sat, 24 Nov 2018 01:05:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/VBAeMCcaN1lbyvisf3hhvvnWlXUN/vakcYBKo7s8dz5+Mv5xHaYdltd9Y6g719DrklA8hT X-Received: by 2002:a63:ce50:: with SMTP id r16mr17095068pgi.217.1543050326087; Sat, 24 Nov 2018 01:05:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543050326; cv=none; d=google.com; s=arc-20160816; b=tmGZiiWKB6+xoPXkpL4f6qgrjp2if71DOyQPunkB4fPTxe7/nRF/C1HiXv7s+wryzz NRlRNUdtJyjxXNdw87T3o3mYHYNoqtW133olfC8DHtzQ21h+h5CoKcCEMQFdbYoxxHWm JMlGW4BBCE4Ndbg4IULoH+gJxyLFxECII4K8xZYJdUpcl2Y4D5MPyS8L2F60vIJY0Jaw Lunntopy7ZLgeQh9Z7ZJv2nI2cC8iCb64Egbkp1wYe6TGUh3oLa3qO1RRdZhGPniA5D0 YGDP3mgdsMQwqhfBa+dlmtYf0Snn2QIv4UAFGZKvkzhpaVx6/3RZ/ayh7w7X/G1vzXek z57w== 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; bh=kU1ElEhVkbr30oK8MLui4GfD2NPYz5fVABy0vwjSEFk=; b=SF3zl4yvxWzVkwbiKdqyGRmohb2UdohunDpQi74wUy7eki0ZQWgbzlnlr2iQjfKLUX ndxsqtSACypIJic3RceeuUsqT+Hge0hC1lo6XbJtMcHOeKQZPt+3g0MV7oiMqb0k4Kr/ 7l8FUCb2HvvNrN3MpZwxVp9eG2dpvxPYMaIptSi3YdbinQuHwUn4IRIMvTZxLEPD9l9Y +8S4VGHIO63QpDcRF5dnM2rEvbjjPpGN2Or/ZsvF3PavfbOf9Q/U8upd9l9PjfgzQ7rv NH1pG5LURnWTKiYp4hsCjYQlAW9IFafP1ZCkdZhBjXhzVBOvpPxm8wceqRuatl8VfjNP iJtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Fz+xeMef; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e184si25161397pfg.185.2018.11.24.01.05.11; Sat, 24 Nov 2018 01:05:26 -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=@gmail.com header.s=20161025 header.b=Fz+xeMef; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728819AbeKXTRR (ORCPT + 99 others); Sat, 24 Nov 2018 14:17:17 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:41874 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728298AbeKXTRR (ORCPT ); Sat, 24 Nov 2018 14:17:17 -0500 Received: by mail-lj1-f196.google.com with SMTP id z80-v6so12403291ljb.8 for ; Sat, 24 Nov 2018 00:29:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kU1ElEhVkbr30oK8MLui4GfD2NPYz5fVABy0vwjSEFk=; b=Fz+xeMefCjlyeh8dq8n2CnOQE8EVVSD1pG6i+ZsxPrIKQrP1WxPCZJZMpDHMgs05GU lDxUNvl8a+KDzfUphm/rBCKAGqovGHaOp1QlIg5Wg7PAQUSaKxA3tqcO1FQqvsPgGVae x3ZnVgAqDscXtdnwWEi95JfjZ8ImqDvqQs0NVIo0JQ+yj066G4zbb/wfY8XChSuoTWEt 85rzXc+0zFxd2SfngerJ5Uw1GZISYZbzQ5sgLRKnvzz+8b97NWwCuaw2PgVmckWu6COQ ZnVg2l1Ycp09GroPPs5dVHgfvHQ747xKGEN1Lr3+WQDSSMMkRFsy/zBeX4fbP0xk/Rv7 a2aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kU1ElEhVkbr30oK8MLui4GfD2NPYz5fVABy0vwjSEFk=; b=NPlgeRmCHeExQQuw8jIYNzU0xsFO/ZhnvYckMv8gCz2SlaUCMuFM0U2DWO9JndOkxW ecbfuSITqPHIJ7yvdoBwDIMmRXmFupUUr6djUpCteLLSCOvblb/L7wTZ3+LGxdnlceE/ SemAtzXBdNfnaTfbInSBIqky8lIL88tzq6AMTG/FPJgOb3nABpNKozfiU2fQk1XxaS52 9K7ncfKU1cAIZ1WRc4EhPLfJgsxO+lwMJ6nJ9pfHIBBLFeqtSw6q4JAxYUBfLuQDXgzl RCQTfcG4U9uQfvxTC+LtTB508caoUsumM6nUX44RsfLsWAf+fzwqMhg+mxEy7TQ+pLlJ anBA== X-Gm-Message-State: AA+aEWYVefhjMe7wPMliVtfwn34A7CwcIISeiPAwiMkXmNVLoaPB602R I5gqb0N3aEi+rqFs9U59tWfGKmOyh4cFVNbjseI= X-Received: by 2002:a2e:6f11:: with SMTP id k17-v6mr11715111ljc.94.1543048169760; Sat, 24 Nov 2018 00:29:29 -0800 (PST) MIME-Version: 1.0 References: <1542856462-18836-1-git-send-email-yamada.masahiro@socionext.com> <1542856462-18836-3-git-send-email-yamada.masahiro@socionext.com> In-Reply-To: <1542856462-18836-3-git-send-email-yamada.masahiro@socionext.com> From: Miguel Ojeda Date: Sat, 24 Nov 2018 09:29:19 +0100 Message-ID: Subject: Re: [PATCH v4 3/3] build_bug.h: remove most of dummy BUILD_BUG_ON stubs for Sparse To: Masahiro Yamada Cc: Andrew Morton , Luc Van Oostenryck , Nick Desaulniers , Kees Cook , josh@joshtriplett.org, linux-kernel 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 Thu, Nov 22, 2018 at 5:08 PM 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 enabled only very recently), > 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 positives, and noisier than > it should be at that time. > > 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. > > 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 > Reviewed-by: Nick Desaulniers > Tested-by: Nick Desaulniers Nice to see those CHECKER blocks are being reduced! Acked-by: Miguel Ojeda Cheers, Miguel