Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Mar 2026 16:45:19 +0000
From:      Siva Mahadevan <siva@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 56401a9c3459 - stable/15 - LinuxKPI: avoid -Werror=unused-value in sort() from BUILD_BUG_ON_ZERO()
Message-ID:  <69b19c1f.440e6.2e993800@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch stable/15 has been updated by siva:

URL: https://cgit.FreeBSD.org/src/commit/?id=56401a9c3459f8f4151ac0da1f820863119c1749

commit 56401a9c3459f8f4151ac0da1f820863119c1749
Author:     Siva Mahadevan <siva@FreeBSD.org>
AuthorDate: 2026-03-03 19:09:35 +0000
Commit:     Siva Mahadevan <siva@FreeBSD.org>
CommitDate: 2026-03-11 16:16:17 +0000

    LinuxKPI: avoid -Werror=unused-value in sort() from BUILD_BUG_ON_ZERO()
    
    The BUILD_BUG_ON_ZERO() macro returns an (int)0 if it does not fail
    at build time. LinuxKPI sort() has it as a guard for an unsupported
    argument but ignores the return value.
    
    This leads to gcc complaining:
    
    /usr/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); }))
          |                                 ^
    /usr/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);                        \
          |         ^~~~~~~~~~~~~~~~~
    /usr/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);
    
    Change to BUILD_BUG_ON() for the statement version.
    
    Reported by:    CI
    Co-authored-by: bz
    Approved by:    emaste (mentor)
    MFC after:      3 days
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D55634
    
    (cherry picked from commit f26cb4757eb74ceace39144933ae198ebf1b4f28)
---
 sys/compat/linuxkpi/common/include/linux/sort.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/compat/linuxkpi/common/include/linux/sort.h b/sys/compat/linuxkpi/common/include/linux/sort.h
index e6196d1f41c7..361b37c587c8 100644
--- a/sys/compat/linuxkpi/common/include/linux/sort.h
+++ b/sys/compat/linuxkpi/common/include/linux/sort.h
@@ -34,7 +34,7 @@
 #include <sys/libkern.h>
 
 #define	sort(base, num, size, cmp, swap)	do {	\
-	BUILD_BUG_ON_ZERO(swap);			\
+	BUILD_BUG_ON(swap);				\
 	qsort(base, num, size, cmp);			\
 } while (0)
 


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69b19c1f.440e6.2e993800>