Skip to content

Fix Clang 22 warnings#7299

Open
KonstaT wants to merge 7 commits intoraspberrypi:rpi-6.18.yfrom
KonstaT:rpi-6.18.y-clang
Open

Fix Clang 22 warnings#7299
KonstaT wants to merge 7 commits intoraspberrypi:rpi-6.18.yfrom
KonstaT:rpi-6.18.y-clang

Conversation

@KonstaT
Copy link
Copy Markdown

@KonstaT KonstaT commented Apr 2, 2026

This patch set fixes build warnings with Clang. These issues were observed when compiling code merged from this repository as part of Android kernel which is compiled using Clang 22 and CONFIG_WERROR=y set.

I also reproduced that these issues are present and resolved with this patch set when compiling the kernel from this repository (rpi-6.18.y branch) with Clang 22 both cross-compiling on Ubuntu host as well as natively on Raspberry Pi 5 using Raspberry Pi OS.

# Install Raspberry Pi OS (2025-12-04-raspios-trixie-arm64.img.xz) and update
$ sudo apt update
$ sudo apt full-upgrade

# Install build dependecies (https://www.raspberrypi.com/documentation/computers/linux_kernel.html#natively-build-a-kernel)
$ sudo apt install bc bison flex libssl-dev make

# Install Clang 22 (https://apt.llvm.org/)
$ wget https://apt.llvm.org/llvm.sh
$ chmod +x llvm.sh
$ sudo ./llvm.sh 22

# Download kernel source code (shallow clone to save time)
$ git clone https://github.com/raspberrypi/linux -b rpi-6.18.y --depth=1
$ cd linux

# Compile using Clang 22 with CONFIG_WERROR=y set
$ export LLVM=-22 CC=clang-22 KERNEL=kernel_2712
$ make bcm2712_defconfig
$ scripts/config --file .config --set-val CONFIG_WERROR y
$ make Image.gz modules dtbs -j$(nproc)

Also fixed minor issue that SND_PIMIDI and SND_PISOUND_MICRO should rather select CRC8 than depend on it. This likely works here as some other drivers already selects CRC8. I generally don't compile the Android kernel with SND_PISOUND_MICRO enabled but it doesn't get set in defconfig as there's also no CRC8 set otherwise.

KonstaT added 7 commits April 2, 2026 18:29
* Fixes build with Clang.

drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:1513:3: error: variable 'chan_flags_all' is uninitialized when used here [-Werror,-Wuninitialized]
 1513 |                 chan_flags_all |= dw->chan_flags[i];
      |                 ^~~~~~~~~~~~~~
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c:1502:25: note: initialize the variable 'chan_flags_all' to silence this warning
 1502 |         uint32_t chan_flags_all;
      |                                ^
      |                                 = 0
1 error generated.
* Fixes build with Clang.

drivers/gpu/drm/vc4/vc4_plane.c:2799:2: error: variable 'txp_crtc' is used uninitialized whenever 'for' loop exits because its condition is false [-Werror,-Wsometimes-uninitialized]
 2799 |         drm_for_each_crtc(crtc, drm) {
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/drm/drm_crtc.h:1312:2: note: expanded from macro 'drm_for_each_crtc'
 1312 |         list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head)
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/list.h:783:7: note: expanded from macro 'list_for_each_entry'
  783 |              !list_entry_is_head(pos, head, member);                    \
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/vc4/vc4_plane.c:2809:20: note: uninitialized use occurs here
 2809 |                                         drm_crtc_mask(txp_crtc);
      |                                                       ^~~~~~~~
drivers/gpu/drm/vc4/vc4_plane.c:2799:2: note: remove the condition if it is always true
 2799 |         drm_for_each_crtc(crtc, drm) {
      |         ^
include/drm/drm_crtc.h:1312:2: note: expanded from macro 'drm_for_each_crtc'
 1312 |         list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head)
      |         ^
include/linux/list.h:783:7: note: expanded from macro 'list_for_each_entry'
  783 |              !list_entry_is_head(pos, head, member);                    \
      |              ^
drivers/gpu/drm/vc4/vc4_plane.c:2796:27: note: initialize the variable 'txp_crtc' to silence this warning
 2796 |         struct drm_crtc *txp_crtc;
      |                                  ^
      |                                   = NULL
1 error generated.
* Fixes build with Clang.

drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c:461:10: error: array index 18 is past the end of the array (that has type 'u8[1]' (aka 'unsigned char[1]')) [-Werror,-Warray-bounds]
  461 |                 setbit(eventmask_msg->mask, BRCMF_E_ULP);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/broadcom/brcm80211/brcmfmac/../include/brcmu_utils.h:37:30: note: expanded from macro 'setbit'
   37 | #define setbit(a, i)    (((u8 *)a)[(i)/NBBY] |= 1<<((i)%NBBY))
      |                                 ^  ~~~~~~~~
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.h:313:2: note: array 'mask' declared here
  313 |         u8      mask[1];
      |         ^
1 error generated.
…nk-up

* Fixes build with Clang.

drivers/pci/controller/pcie-brcmstb.c:1595:3: error: variable 'clkreq_cntl' is uninitialized when used here [-Werror,-Wuninitialized]
 1595 |                 clkreq_cntl |= PCIE_MISC_HARD_PCIE_HARD_DEBUG_CLKREQ_DEBUG_ENABLE_MASK;
      |                 ^~~~~~~~~~~
drivers/pci/controller/pcie-brcmstb.c:1578:17: note: initialize the variable 'clkreq_cntl' to silence this warning
 1578 |         u32 clkreq_cntl;
      |                        ^
      |                         = 0
1 error generated.
* Fixes build with Clang.

In file included from drivers/pwm/pwm-pio-rp1.c:20:
include/linux/pio_rp1.h:283:42: error: implicit conversion from 'uint' (aka 'unsigned int') to 'uint16_t' (aka 'unsigned short') changes value from 4294967295 to 65535 [-Werror,-Wconstant-conversion]
  283 |         args.origin = (program->origin == -1) ? PIO_ORIGIN_ANY : program->origin;
      |                     ~                           ^~~~~~~~~~~~~~
include/linux/pio_rp1.h:44:27: note: expanded from macro 'PIO_ORIGIN_ANY'
   44 | #define PIO_ORIGIN_ANY                  ((uint)(~0))
      |                                          ^~~~~~~~~~
include/linux/pio_rp1.h:312:42: error: implicit conversion from 'uint' (aka 'unsigned int') to 'uint16_t' (aka 'unsigned short') changes value from 4294967295 to 65535 [-Werror,-Wconstant-conversion]
  312 |         args.origin = (program->origin == -1) ? PIO_ORIGIN_ANY : program->origin;
      |                     ~                           ^~~~~~~~~~~~~~
include/linux/pio_rp1.h:44:27: note: expanded from macro 'PIO_ORIGIN_ANY'
   44 | #define PIO_ORIGIN_ANY                  ((uint)(~0))
      |                                          ^~~~~~~~~~
2 errors generated.
* Change SND_PIMIDI and SND_PISOUND_MICRO to select CRC8 instead of depend
  on it.
* Fixes build with Clang.

sound/drivers/upisnd/upisnd_codec.c:741:6: error: variable 'ret' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
  741 |         if (adau->clk_src != ADAU1961_CLK_SRC_MCLK)
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/drivers/upisnd/upisnd_codec.c:744:9: note: uninitialized use occurs here
  744 |         return ret;
      |                ^~~
sound/drivers/upisnd/upisnd_codec.c:741:2: note: remove the 'if' if its condition is always true
  741 |         if (adau->clk_src != ADAU1961_CLK_SRC_MCLK)
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  742 |                 ret = snd_soc_dapm_add_routes(dapm, &adau1961_dapm_pll_route, 1);
sound/drivers/upisnd/upisnd_codec.c:739:9: note: initialize the variable 'ret' to silence this warning
  739 |         int ret;
      |                ^
      |                 = 0
1 error generated.
* Fixes build with Clang.

sound/soc/bcm/hifiberry_studio_dac8x.c:770:41: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality]
  770 |                 if ((priv->card_info.card_clk_options == 0x02)) {
      |                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
sound/soc/bcm/hifiberry_studio_dac8x.c:770:41: note: remove extraneous parentheses around the comparison to silence this warning
  770 |                 if ((priv->card_info.card_clk_options == 0x02)) {
      |                     ~                                 ^      ~
sound/soc/bcm/hifiberry_studio_dac8x.c:770:41: note: use '=' to turn this equality comparison into an assignment
  770 |                 if ((priv->card_info.card_clk_options == 0x02)) {
      |                                                       ^~
      |                                                       =
1 error generated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant