From: Jani Nikula <jani.nikula@intel.com>
To: Paulo Zanoni <paulo.r.zanoni@intel.com>, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] drm/i915/dp: use logical operators with boolean type
Date: Fri, 03 May 2019 10:30:04 +0300 [thread overview]
Message-ID: <87a7g4ngg3.fsf@intel.com> (raw)
In-Reply-To: <4619c4b85379a056d4d7876b64a69396508ad21f.camel@intel.com>
On Thu, 02 May 2019, Paulo Zanoni <paulo.r.zanoni@intel.com> wrote:
> Em qui, 2019-05-02 às 11:29 +0300, Jani Nikula escreveu:
>> Using arithmetic operators with booleans is confusing. Switch to logical
>> operators.
>>
>> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
>> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>> ---
>> drivers/gpu/drm/i915/intel_dp.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
>> index 4e7b8d..ef4992f 100644
>> --- a/drivers/gpu/drm/i915/intel_dp.c
>> +++ b/drivers/gpu/drm/i915/intel_dp.c
>> @@ -5094,7 +5094,7 @@ static void icl_update_tc_port_type(struct drm_i915_private *dev_priv,
>> enum port port = intel_dig_port->base.port;
>> enum tc_port_type old_type = intel_dig_port->tc_type;
>>
>> - WARN_ON(is_legacy + is_typec + is_tbt != 1);
>> + WARN_ON(is_legacy || is_typec || !is_tbt);
>
> This changes the meaning. You're interpreting this as:
>
> WARN_ON(is_legacy + is_typec + (is_tbt != 1))
>
> while the original intent of the code is to be:
>
> WARN_ON((is_legacy + is_typec + is_tbt) != 1)
*blush*
> and a quick check on operator precedence tables leads me to think the
> original code is indeed correct.
>
> We're asserting exactly one of these bools enabled, so the logic
> operation would be something like:
>
> WARN_ON((is_legacy && (is_typec || is_tbt)) ||
> (is_typec && (is_legacy || is_tbt)) ||
> (is_tbt && (is_legacy || is_typec)) ||
> (!is_legacy && !is_typec && !is_tbt))
>
> I would still prefer the arithmetic operation.
Agreed.
I'll go hide under a rock.
BR,
Jani.
--
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-05-03 7:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-02 8:29 [PATCH] drm/i915/dp: use logical operators with boolean type Jani Nikula
2019-05-02 14:02 ` ✗ Fi.CI.BAT: failure for " Patchwork
2019-05-02 15:30 ` [PATCH] " Paulo Zanoni
2019-05-03 7:30 ` Jani Nikula [this message]
2019-05-02 17:19 ` ✗ Fi.CI.BAT: failure for drm/i915/dp: use logical operators with boolean type (rev2) Patchwork
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=87a7g4ngg3.fsf@intel.com \
--to=jani.nikula@intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=paulo.r.zanoni@intel.com \
/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