Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Feb 2026 09:52:00 -0800
From:      "Enji Cooper (yaneurabeya)" <yaneurabeya@gmail.com>
To:        Vladimir Kondratyev <wulf@FreeBSD.org>
Cc:        "src-committers@freebsd.org" <src-committers@FreeBSD.org>, "dev-commits-src-all@freebsd.org" <dev-commits-src-all@FreeBSD.org>, "dev-commits-src-main@freebsd.org" <dev-commits-src-main@FreeBSD.org>
Subject:   Re: git: 64dab63f3b3b - main - LinuxKPI: Use negative bit field size to trigger BUILD_BUG_ON_ZERO
Message-ID:  <241DCDC1-B8A5-43CF-9FAA-19406EB8A996@gmail.com>
In-Reply-To: <202201101950.20AJor0m009372@gitrepo.freebsd.org>

index | next in thread | previous in thread | raw e-mail


> On Jan 10, 2022, at 11:50 AM, Vladimir Kondratyev <wulf@FreeBSD.org> wrote:
> 
> The branch main has been updated by wulf:
> 
> URL: https://cgit.FreeBSD.org/src/commit/?id=64dab63f3b3b6c6a1f8a92f43bed0aa28319d627
> 
> commit 64dab63f3b3b6c6a1f8a92f43bed0aa28319d627
> Author:     Vladimir Kondratyev <wulf@FreeBSD.org>
> AuthorDate: 2021-12-25 18:42:15 +0000
> Commit:     Vladimir Kondratyev <wulf@FreeBSD.org>
> CommitDate: 2022-01-10 19:49: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
> ---
> 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 419dae214396..a84f577dd912 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); }))

Hi Vladimir,
	I think this change is causing build problems now with gcc14. Please see the snippet from https://ci.freebsd.org/job/FreeBSD-main-amd64-gcc14_build/2986/consoleText below.
Thanks,
-Enji

--- all_subdir_rtw89 ---
--- core.o ---
In file included from /workspace/src/sys/compat/linuxkpi/common/include/linux/kernel.h:44,
                 from /workspace/src/sys/compat/linuxkpi/common/include/linux/skbuff.h:39,
                 from /workspace/src/sys/compat/linuxkpi/common/include/linux/ip.h:40,
                 from /workspace/src/sys/contrib/dev/rtw89/core.c:9:
/workspace/src/sys/contrib/dev/rtw89/core.c: In function 'rtw89_bcn_calc_drift':
/workspace/src/sys/compat/linuxkpi/common/include/linux/build_bug.h:60:33: error: statement with no effect [-Werror=unused-value]
   60 | #define BUILD_BUG_ON_ZERO(x)    ((int)sizeof(struct { int:-((x) != 0); }))
      |                                 ^
/workspace/src/sys/compat/linuxkpi/common/include/linux/sort.h:37:9: note: in expansion of macro 'BUILD_BUG_ON_ZERO'
   37 |         BUILD_BUG_ON_ZERO(swap);                        \
      |         ^~~~~~~~~~~~~~~~~
/workspace/src/sys/contrib/dev/rtw89/core.c:2575:9: note: in expansion of macro 'sort'
 2575 |         sort(drift, RTW89_BCN_TRACK_STAT_NR, sizeof(*drift), cmp_u16, NULL);
      |         ^~~~

home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?241DCDC1-B8A5-43CF-9FAA-19406EB8A996>