[Bug 268788] When kernel is being built without assertions there are a tons of warnings about unused variable

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 06 Jan 2023 18:05:32 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268788

            Bug ID: 268788
           Summary: When kernel is being built without assertions there
                    are a tons of warnings about unused variable
           Product: Base System
           Version: 12.4-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: lev@FreeBSD.org

sys/sys/bus.h defines __BUS_ACCESSOR macro which create "int e" variable. This
variable is assigned always bu later used only in KASSERT() "call". If kernel
is being built without assertions, this "e" variable becomes set-but-unused and
generates a tons of warnings with clang included into 12-STABLE and later.

Looks like this variable should be #ifdef'ed.

Warnings looks like this:

===========================
In file included from /usr/src/sys/dev/mlx5/mlx5_core/mlx5_port.c:29:
In file included from /usr/src/sys/dev/mlx5/port.h:31:
In file included from /usr/src/sys/dev/mlx5/driver.h:35:
In file included from
/usr/src/sys/compat/linuxkpi/common/include/linux/pci.h:44:
/usr/src/sys/dev/pci/pcivar.h:420:1: warning: variable 'e' set but not used
[-Wunused-but-set-variable]
PCIB_ACCESSOR(bus,              BUS,            uint32_t)
^
/usr/src/sys/dev/pci/pcivar.h:417:5: note: expanded from macro 'PCIB_ACCESSOR'
    __BUS_ACCESSOR(pcib, var, PCIB, ivar, type)
    ^
/usr/src/sys/sys/bus.h:814:6: note: expanded from macro '__BUS_ACCESSOR'
        int e;                                                          \
            ^
In file included from /usr/src/sys/dev/mlx5/mlx5_core/mlx5_port.c:29:
In file included from /usr/src/sys/dev/mlx5/port.h:31:
In file included from /usr/src/sys/dev/mlx5/driver.h:35:
In file included from
/usr/src/sys/compat/linuxkpi/common/include/linux/pci.h:44:
/usr/src/sys/dev/pci/pcivar.h:420:1: warning: variable 'e' set but not used
[-Wunused-but-set-variable]
/usr/src/sys/dev/pci/pcivar.h:417:5: note: expanded from macro 'PCIB_ACCESSOR'
    __BUS_ACCESSOR(pcib, var, PCIB, ivar, type)
    ^
/usr/src/sys/sys/bus.h:826:6: note: expanded from macro '__BUS_ACCESSOR'
        int e;                                                          \
===========================

-- 
You are receiving this mail because:
You are the assignee for the bug.