Linux-KBuild Archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Nathan Chancellor' <nathan@kernel.org>,
	"masahiroy@kernel.org" <masahiroy@kernel.org>
Cc: "nicolas@fjasle.eu" <nicolas@fjasle.eu>,
	"ndesaulniers@google.com" <ndesaulniers@google.com>,
	"morbo@google.com" <morbo@google.com>,
	"justinstitt@google.com" <justinstitt@google.com>,
	"arnd@arndb.de" <arnd@arndb.de>,
	"yonghong.song@linux.dev" <yonghong.song@linux.dev>,
	"linux-kbuild@vger.kernel.org" <linux-kbuild@vger.kernel.org>,
	"llvm@lists.linux.dev" <llvm@lists.linux.dev>,
	"patches@lists.linux.dev" <patches@lists.linux.dev>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH v2] kbuild: Move -Wenum-{compare-conditional,enum-conversion} into W=1
Date: Sun, 10 Mar 2024 17:02:34 +0000	[thread overview]
Message-ID: <8a7d0115e41949429e43e06b9479a781@AcuMS.aculab.com> (raw)
In-Reply-To: <20240305-disable-extra-clang-enum-warnings-v2-1-ba529ec15f95@kernel.org>

From: Nathan Chancellor
> Sent: 05 March 2024 22:13
...
>   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;
>         |                         ~~~~~~~~~~~~~~~~~~~~~~
> 
> Doing arithmetic between or returning two different types of enums could
> be a bug, so each of the instance of the warning needs to be evaluated.
> Unfortunately, as mentioned above, there are many instances of this
> warning in many different configurations, which can break the build when
> CONFIG_WERROR is enabled.

I'm not sure what is being done to avoid this warning.
(Apart from not using enum to define related integer constants.)
Until the compilers get even more clever^Wstupid perhaps the
simplest way is to just add '+ 0' to one of the enum values.

In code terms it is much safer than any cast.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

      parent reply	other threads:[~2024-03-10 17:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-05 22:12 [PATCH v2] kbuild: Move -Wenum-{compare-conditional,enum-conversion} into W=1 Nathan Chancellor
2024-03-05 22:20 ` Arnd Bergmann
2024-03-10 12:53 ` Masahiro Yamada
2024-03-10 17:02 ` David Laight [this message]

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=8a7d0115e41949429e43e06b9479a781@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --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 \
    --cc=yonghong.song@linux.dev \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).