From nobody Sat Jan 22 19:36:40 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 40B34196BEE3; Sat, 22 Jan 2022 19:36:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Jh6232YjQz3hCS; Sat, 22 Jan 2022 19:36:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642880203; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SmfMwMRv5uLwDa730Jt1uhfweiMThvcb1jshH3C5dTY=; b=aGW+jd0HmFNn/h/5JUzNMnQ/UJxp7KeA9P2U9vXuXSzDtRsn1c0OLguIjVkOSJMXtGShzs BLNkRCksNBDqaDXn2POfDsMWAUt7AadcoDlsg9GYTRUrdU4b2oAnQmDWy02aFV1GYyrPGr P5jDSBIJKDaEheGfEz7ROeQulS+d63vs+fnRPvsvu2MckcX72UItlLQ85SQsIOQqWC6WxB fbTuWVyg/q16hIeGM5jsvRyHok6CUOBKudm5sTShAIycfe0izaapsc8lIQR8WfNX9SU/og wfslG4MtguF1NZgT3y0RNrnsm6cyYn51e4bKnKwfqoKqDodlHUwbs6bS/EQezw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1AE2714CCD; Sat, 22 Jan 2022 19:36:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20MJaf2O000447; Sat, 22 Jan 2022 19:36:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20MJaeUA000446; Sat, 22 Jan 2022 19:36:40 GMT (envelope-from git) Date: Sat, 22 Jan 2022 19:36:40 GMT Message-Id: <202201221936.20MJaeUA000446@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: ef743744f0f4 - stable/13 - LinuxKPI: Use negative bit field size to trigger BUILD_BUG_ON_ZERO List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: ef743744f0f4e06956fb785ed16cdc547758fefb Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642880204; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=SmfMwMRv5uLwDa730Jt1uhfweiMThvcb1jshH3C5dTY=; b=EV0tUZGCVrU3QxsHscactIz/UZtKJQqS3i6AwFrsBxP6mwtqEU1QFlFp8oYF6bwVwIgSEj JvoUsVNyT2IW0PDBBb2KBseQcRgtf2Ta9sndXzIWWsXbOvcrkFoQ1y9HWp3FnXsZfhoVen UKQJI63wcuB8b+w81OX3RVY0bU+jViovB8Qx6J6pQ0U4vWxVaSVPZJJNMox6eL8/S0Il3C kdhnoy74mUboEukcjnU4czcZrrL+jGTSHilKFChvq7oOnOIt8k1tj9qhDg0m6sw5NsL9+d AsgeosRa3NQQLXX5Jgdc48Wzl2EK4Jjfp1WYIqP9/pYWzVOSVATzz6yl0O98FA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642880204; a=rsa-sha256; cv=none; b=SZtJM8Z4qPR3tlx/ey/69ZFrS6k/8Rabv3nfTzHP3DKcOGdKb1rcDVfXtNKb6X/yyofGEk CLMBgRs8EJtoXpr4qbyQ1wtDh7HA51+ZQUbVNQj//Ra7g7wYc1gVnTUhV3uGPsCAsIEnbf slks9E4PkYFZxALDnET3whjf9jcL3nVQC5Y93LqeBJmJrBUJ5FERhQ5uZWBGVTI0EBK2nU ClBCg93qu51lT/DoOliGLjrEv9Rsrxag/fTLaepf/Uih75NZ6Bli2dGXosnvwyTQPg2X4c uNRh7OGzqe1Ra4qgxdHZdiZ7aqHkXq80nn0nOtqUEWmHlkFBd4sIgg7Z8baXXg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=ef743744f0f4e06956fb785ed16cdc547758fefb commit ef743744f0f4e06956fb785ed16cdc547758fefb Author: Vladimir Kondratyev AuthorDate: 2021-12-25 18:42:15 +0000 Commit: Vladimir Kondratyev CommitDate: 2022-01-22 19:34:38 +0000 LinuxKPI: Use negative bit field size to trigger BUILD_BUG_ON_ZERO compile time assertion on non-NULL pointers. Tests conducted show that _Static_assert, negative array size method and current code does not handle pointers well enough. Bit field method solves this problem. This change is derrived from Linux implementation of BUILD_BUG_ON_ZERO. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D33674 (cherry picked from commit 64dab63f3b3b6c6a1f8a92f43bed0aa28319d627) --- sys/compat/linuxkpi/common/include/linux/kernel.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index 75e274205259..58581ebe9101 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -109,9 +109,7 @@ #define BUILD_BUG_ON_MSG(x, msg) BUILD_BUG_ON(x) #define BUILD_BUG_ON_NOT_POWER_OF_2(x) BUILD_BUG_ON(!powerof2(x)) #define BUILD_BUG_ON_INVALID(expr) while (0) { (void)(expr); } - -extern const volatile int lkpi_build_bug_on_zero; -#define BUILD_BUG_ON_ZERO(x) ((x) ? lkpi_build_bug_on_zero : 0) +#define BUILD_BUG_ON_ZERO(x) ((int)sizeof(struct { int:-((x) != 0); })) #define BUG() panic("BUG at %s:%d", __FILE__, __LINE__) #define BUG_ON(cond) do { \