public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yonghong.song@linux.dev>
To: Nathan Chancellor <nathan@kernel.org>, masahiroy@kernel.org
Cc: nicolas@fjasle.eu, ndesaulniers@google.com, morbo@google.com,
	justinstitt@google.com, arnd@arndb.de,
	linux-kbuild@vger.kernel.org, llvm@lists.linux.dev,
	patches@lists.linux.dev, stable@vger.kernel.org
Subject: Re: [PATCH] kbuild: Disable two Clang specific enumeration warnings
Date: Tue, 5 Mar 2024 10:11:47 -0800	[thread overview]
Message-ID: <e2f2562e-5500-4afd-9e9d-fb92c7271758@linux.dev> (raw)
In-Reply-To: <20240305-disable-extra-clang-enum-warnings-v1-1-6a93ef3d35ff@kernel.org>


On 3/5/24 9:42 AM, Nathan Chancellor wrote:
> Clang enables -Wenum-enum-conversion and -Wenum-compare-conditional
> under -Wenum-conversion. A recent change in Clang strengthened these
> warnings and they appear frequently in common builds, primarily due to
> several instances in common headers but there are quite a few drivers
> that have individual instances as well.
>
>    include/linux/vmstat.h:508:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
>      508 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
>          |                            ~~~~~~~~~~~~~~~~~~~~~ ^
>      509 |                            item];
>          |                            ~~~~
>
>    drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c:955:24: warning: conditional expression between different enumeration types ('enum iwl_mac_beacon_flags' and 'enum iwl_mac_beacon_flags_v1') [-Wenum-compare-conditional]
>      955 |                 flags |= is_new_rate ? IWL_MAC_BEACON_CCK
>          |                                      ^ ~~~~~~~~~~~~~~~~~~
>      956 |                           : IWL_MAC_BEACON_CCK_V1;
>          |                             ~~~~~~~~~~~~~~~~~~~~~
>    drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c:1120:21: warning: conditional expression between different enumeration types ('enum iwl_mac_beacon_flags' and 'enum iwl_mac_beacon_flags_v1') [-Wenum-compare-conditional]
>     1120 |                                                0) > 10 ?
>          |                                                        ^
>     1121 |                         IWL_MAC_BEACON_FILS :
>          |                         ~~~~~~~~~~~~~~~~~~~
>     1122 |                         IWL_MAC_BEACON_FILS_V1;
>          |                         ~~~~~~~~~~~~~~~~~~~~~~
>
> While doing arithmetic with different types of enums may be potentially
> problematic, inspecting several instances of the warning does not reveal
> any obvious problems. To silence the warnings at the source level, an
> integral cast must be added to each mismatched enum (which is incredibly
> ugly when done frequently) or the value must moved out of the enum to a
> macro, which can remove the type safety offered by enums in other
> places, such as assignments that would trigger -Wenum-conversion.
>
> As the warnings do not appear to have a high signal to noise ratio and
> the source level silencing options are not sustainable, disable the
> warnings unconditionally, as they will be enabled with -Wenum-conversion
> and are supported in all versions of clang that can build the kernel.
>
> Cc: stable@vger.kernel.org
> Closes: https://github.com/ClangBuiltLinux/linux/issues/2002
> Link: https://github.com/llvm/llvm-project/commit/8c2ae42b3e1c6aa7c18f873edcebff7c0b45a37e
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Thanks for the fix. LGTM.

Acked-by: Yonghong Song <yonghong.song@linux.dev>


  reply	other threads:[~2024-03-05 18:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-05 17:42 [PATCH] kbuild: Disable two Clang specific enumeration warnings Nathan Chancellor
2024-03-05 18:11 ` Yonghong Song [this message]
2024-03-05 18:49 ` Arnd Bergmann
2024-03-05 18:52   ` Nick Desaulniers
2024-03-05 19:30     ` Nathan Chancellor
2024-03-05 21:52       ` Arnd Bergmann
2024-03-05 22:14         ` Nathan Chancellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e2f2562e-5500-4afd-9e9d-fb92c7271758@linux.dev \
    --to=yonghong.song@linux.dev \
    --cc=arnd@arndb.de \
    --cc=justinstitt@google.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=masahiroy@kernel.org \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox