All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Dave Airlie <airlied@gmail.com>, Eryk Brol <eryk.brol@amd.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [git pull] drm next pull for 5.10-rc1
Date: Thu, 15 Oct 2020 11:42:22 -0700	[thread overview]
Message-ID: <CAHk-=wgYNzhoYuUBsBcFq1TFA5C+Bie-2uzZkF2McO9joXxW0A@mail.gmail.com> (raw)
In-Reply-To: <CAHk-=wiP+S4K3yU+FqgGmF+EgcSgk04Eerf3gE-6qObicy346w@mail.gmail.com>

On Thu, Oct 15, 2020 at 10:51 AM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> Thanks, looks good to me [..]

Uhhuh. I already pushed things out, but my clang build (which I don't
do between each merge) shows a problem:

  drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_mst_types.c:650:8:
  warning: logical not is only applied to the left hand side of this
comparison [-Wlogical-not-parentheses]
                && !params[i].clock_force_enable == DSC_CLK_FORCE_DEFAULT) {
                   ^                             ~~

and I think clang is entirely right to complain about that code.

Yes, the code may be correct, but even if it's correct, that's a
really odd way to write things.

Anyway, what it does is:

   !params[i].clock_force_enable

turns 0 into 1, and anything that isn't 0 into 0.

And DSC_CLK_FORCE_DEFAULT has a value of 0, so what that line actually means is

  (params[i].clock_force_enable == 0) == 0

which obviously is

  params[i].clock_force_enable != 0

which in this case is the same as

  params[i].clock_force_enable != DSC_CLK_FORCE_DEFAULT

which may be what the code actually meant to do.

So I suspect it does what it meant to do, but only because
DSC_CLK_FORCE_DEFAULT also happens to be 0, which also acts as a
boolean 'false'.

But it's also possible that the '!' is a left-over, and the code
actually _meant_ to do the exact reverse of that. I have no idea.

This odd code was introduced by commit 0749ddeb7d6c ("drm/amd/display:
Add DSC force disable to dsc_clock_en debugfs entry"), and can we
please agree to not write this kind of obfuscated C code?

               Linus

WARNING: multiple messages have this Message-ID (diff)
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Dave Airlie <airlied@gmail.com>, Eryk Brol <eryk.brol@amd.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	LKML <linux-kernel@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [git pull] drm next pull for 5.10-rc1
Date: Thu, 15 Oct 2020 11:42:22 -0700	[thread overview]
Message-ID: <CAHk-=wgYNzhoYuUBsBcFq1TFA5C+Bie-2uzZkF2McO9joXxW0A@mail.gmail.com> (raw)
In-Reply-To: <CAHk-=wiP+S4K3yU+FqgGmF+EgcSgk04Eerf3gE-6qObicy346w@mail.gmail.com>

On Thu, Oct 15, 2020 at 10:51 AM Linus Torvalds
<torvalds@linux-foundation.org> wrote:
>
> Thanks, looks good to me [..]

Uhhuh. I already pushed things out, but my clang build (which I don't
do between each merge) shows a problem:

  drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_mst_types.c:650:8:
  warning: logical not is only applied to the left hand side of this
comparison [-Wlogical-not-parentheses]
                && !params[i].clock_force_enable == DSC_CLK_FORCE_DEFAULT) {
                   ^                             ~~

and I think clang is entirely right to complain about that code.

Yes, the code may be correct, but even if it's correct, that's a
really odd way to write things.

Anyway, what it does is:

   !params[i].clock_force_enable

turns 0 into 1, and anything that isn't 0 into 0.

And DSC_CLK_FORCE_DEFAULT has a value of 0, so what that line actually means is

  (params[i].clock_force_enable == 0) == 0

which obviously is

  params[i].clock_force_enable != 0

which in this case is the same as

  params[i].clock_force_enable != DSC_CLK_FORCE_DEFAULT

which may be what the code actually meant to do.

So I suspect it does what it meant to do, but only because
DSC_CLK_FORCE_DEFAULT also happens to be 0, which also acts as a
boolean 'false'.

But it's also possible that the '!' is a left-over, and the code
actually _meant_ to do the exact reverse of that. I have no idea.

This odd code was introduced by commit 0749ddeb7d6c ("drm/amd/display:
Add DSC force disable to dsc_clock_en debugfs entry"), and can we
please agree to not write this kind of obfuscated C code?

               Linus
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2020-10-15 18:42 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-15  1:33 [git pull] drm next pull for 5.10-rc1 Dave Airlie
2020-10-15  1:33 ` Dave Airlie
2020-10-15  2:58 ` Dave Airlie
2020-10-15  2:58   ` Dave Airlie
2020-10-15 13:59 ` Peilin Ye
2020-10-15 13:59   ` Peilin Ye
2020-10-15 14:53   ` Alex Deucher
2020-10-15 14:53     ` Alex Deucher
2020-10-15 14:55     ` Peilin Ye
2020-10-15 14:55       ` Peilin Ye
2020-10-15 17:51 ` Linus Torvalds
2020-10-15 17:51   ` Linus Torvalds
2020-10-15 18:42   ` Linus Torvalds [this message]
2020-10-15 18:42     ` Linus Torvalds
2020-10-15 19:13     ` Dave Airlie
2020-10-15 19:13       ` Dave Airlie
2020-10-15 17:56 ` pr-tracker-bot
2020-10-15 17:56   ` pr-tracker-bot
2020-11-03 22:20 ` Kirill A. Shutemov
2020-11-03 22:20   ` Kirill A. Shutemov
2020-11-04 21:58   ` Lyude Paul
2020-11-04 21:58     ` Lyude Paul
2020-11-09 11:52     ` Kirill A. Shutemov
2020-11-09 11:52       ` Kirill A. Shutemov
2020-11-09 17:50       ` Lyude Paul
2020-11-09 17:50         ` Lyude Paul
2020-11-09 19:08         ` Ville Syrjälä
2020-11-09 19:08           ` Ville Syrjälä
2020-11-09 19:33           ` Lyude Paul
2020-11-09 19:33             ` Lyude Paul
2020-11-12 17:33       ` Lyude Paul
2020-11-12 17:33         ` Lyude Paul
2020-11-15 17:57   ` Linus Torvalds
2020-11-15 17:57     ` Linus Torvalds
2020-11-15 20:35     ` Dave Airlie
2020-11-15 20:35       ` Dave Airlie
2020-11-16 19:25     ` Dave Airlie
2020-11-16 19:25       ` Dave Airlie
2020-11-12 13:15 ` Wen Pu
2020-11-12 13:15   ` Wen Pu

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='CAHk-=wgYNzhoYuUBsBcFq1TFA5C+Bie-2uzZkF2McO9joXxW0A@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=airlied@gmail.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eryk.brol@amd.com \
    --cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.