alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: tiwai@suse.de, alsa-devel@alsa-project.org
Subject: Re: [PATCH 5/5] ASoC: Intel: sof_sdw: clarify operator precedence
Date: Thu, 13 Aug 2020 20:49:48 +0100	[thread overview]
Message-ID: <20200813194948.GF5541@sirena.org.uk> (raw)
In-Reply-To: <0b8b306f-f9b7-bb62-2fd2-9b396b862f6f@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 1030 bytes --]

On Thu, Aug 13, 2020 at 02:43:50PM -0500, Pierre-Louis Bossart wrote:
> On 8/13/20 1:45 PM, Mark Brown wrote:
> > On Thu, Aug 13, 2020 at 12:58:39PM -0500, Pierre-Louis Bossart wrote:

> > > -	hdmi_num = sof_sdw_quirk & SOF_SDW_TGL_HDMI ?
> > > +	hdmi_num = (sof_sdw_quirk & SOF_SDW_TGL_HDMI) ?
> > >   				SOF_TGL_HDMI_COUNT : SOF_PRE_TGL_HDMI_COUNT;

> > Or better yet, just don't abuse the ternery operator like this and write
> > normal conditional statements.

> I count 795 uses of the ternary operator in sound/soc and 68776 in my local
> kernel branch.
> Can you clarify in what way this is an abuse? I don't mind changing this, I
> wasn't aware this is frowned upon.

If you write a normal conditional statement then not only is the
precedence clear but it's just generally easier to read.  There are
cases where it can help make things clearer (eg, avoiding the use of
scratch variables to hold results) but this is most definitely not one
of them and I don't understand everyone's enthusiasm for trying to put
them in.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-08-13 19:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-13 17:58 [PATCH 0/5] ASoC: SOF/Intel: fix cppcheck warnings Pierre-Louis Bossart
2020-08-13 17:58 ` [PATCH 1/5] ASOC: SOF: Intel: hda-codec: move unused label to correct position Pierre-Louis Bossart
2020-08-23  3:48   ` Nathan Chancellor
2020-08-24 14:17     ` Pierre-Louis Bossart
2020-08-13 17:58 ` [PATCH 2/5] ASoC: SOF: Intel: hda-codec: move variable used conditionally Pierre-Louis Bossart
2020-08-13 17:58 ` [PATCH 3/5] ASoC: Intel: rename shadowed variable for all broadwell boards Pierre-Louis Bossart
2020-08-13 17:58 ` [PATCH 4/5] ASoC: Intel: bytcht_cx2072x: simplify return handling Pierre-Louis Bossart
2020-08-13 17:58 ` [PATCH 5/5] ASoC: Intel: sof_sdw: clarify operator precedence Pierre-Louis Bossart
2020-08-13 18:45   ` Mark Brown
2020-08-13 19:43     ` Pierre-Louis Bossart
2020-08-13 19:49       ` Mark Brown [this message]
2020-08-13 19:57         ` Pierre-Louis Bossart
2020-08-18 16:54 ` [PATCH 0/5] ASoC: SOF/Intel: fix cppcheck warnings Mark Brown

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=20200813194948.GF5541@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=tiwai@suse.de \
    /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).