linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Nathan Chancellor' <nathan@kernel.org>,
	Arnd Bergmann <arnd@kernel.org>,
	Maximilian Luz <luzmaximilian@gmail.com>,
	Hans de Goede <hdegoede@redhat.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	"platform-driver-x86@vger.kernel.org" 
	<platform-driver-x86@vger.kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"clang-built-linux@googlegroups.com" 
	<clang-built-linux@googlegroups.com>
Subject: RE: [PATCH] [v2] platform/surface: aggregator: avoid clang -Wconstant-conversion warning
Date: Mon, 17 May 2021 08:31:12 +0000	[thread overview]
Message-ID: <16280aaedc40425295d202431ac3adc0@AcuMS.aculab.com> (raw)
In-Reply-To: <057b5568-c4b8-820c-3dd7-2200f61a4d58@kernel.org>

From: Nathan Chancellor
> Sent: 14 May 2021 22:23
> >
> > Clang complains about the assignment of SSAM_ANY_IID to
> > ssam_device_uid->instance:

Has this been raised with clang?

...
> > -	.target   = ((tid) != SSAM_ANY_TID) ? (tid) : 0,			\
> > -	.instance = ((iid) != SSAM_ANY_IID) ? (iid) : 0,			\
> > -	.function = ((fun) != SSAM_ANY_FUN) ? (fun) : 0				\
> > +	.target   = __builtin_choose_expr((tid) != SSAM_ANY_TID, (tid), 0),	\
> > +	.instance = __builtin_choose_expr((iid) != SSAM_ANY_IID, (iid), 0),	\
> > +	.function = __builtin_choose_expr((fun) != SSAM_ANY_FUN, (fun), 0)

A simpler alternative:
		= fun * (fun != SSAM_ANY_FUN)

	David

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

  reply	other threads:[~2021-05-17  8:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-14 20:04 [PATCH] [v2] platform/surface: aggregator: avoid clang -Wconstant-conversion warning Arnd Bergmann
2021-05-14 21:22 ` Nathan Chancellor
2021-05-17  8:31   ` David Laight [this message]
2021-05-17 12:40     ` Maximilian Luz
2021-05-14 21:56 ` Maximilian Luz
2021-05-19 13:12 ` Hans de Goede

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=16280aaedc40425295d202431ac3adc0@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luzmaximilian@gmail.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=platform-driver-x86@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;
as well as URLs for NNTP newsgroup(s).