dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: "Koenig, Christian" <Christian.Koenig@amd.com>,
	"Zhou, David(ChunMing)" <David1.Zhou@amd.com>,
	"Pan, Xinhui" <Xinhui.Pan@amd.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"clang-built-linux@googlegroups.com"
	<clang-built-linux@googlegroups.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
	"Deucher, Alexander" <Alexander.Deucher@amd.com>,
	Nathan Chancellor <natechancellor@gmail.com>
Subject: Re: Clang warning in drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
Date: Thu, 21 Mar 2019 00:44:08 -0400	[thread overview]
Message-ID: <CADnq5_PTfJXJ99gFhxeMZ3RKigkipwjH5jLqfNM3mv49Z=d7Bw@mail.gmail.com> (raw)
In-Reply-To: <CAKwvOdnQa-DnBqm7LgSaPZUeC2JP4UcCJD=piOZd5hdzHPc3ew@mail.gmail.com>

On Wed, Mar 20, 2019 at 4:49 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>
> On Wed, Mar 20, 2019 at 2:37 AM Koenig, Christian
> <Christian.Koenig@amd.com> wrote:
> >
> > Am 20.03.19 um 05:34 schrieb Nathan Chancellor:
> > > On Wed, Mar 20, 2019 at 01:31:27AM +0000, Pan, Xinhui wrote:
> > >> these two enumerated types are same for now. both of them might change in the future.
>
> Please consider if the YAGNI principle applies here.
> https://martinfowler.com/bliki/Yagni.html
>
> > >>
> > >> I have not used clang, but would  .block_id =  (int)head->block fix your warning? If such change is acceptable, I can make one then.
>
> My preference on solutions, in order:
> 1. One enum (this is the simplest most type safe solution).  Add
> another enum when you actually need it.  Otherwise, YAGNI.

It make sense to have two enums.  One is a firmware interface that is
only used by some asics and the other is for the general driver
interface (non-asic specific for the ras features.

> 2. Safe casting function (like the one Nathan supplied, maybe with
> WARN_ONCE rather than WARN).  This ensures that at least if the types
> diverge you get a runtime warning.  A compile-time warning would be
> preferred, but I haven't taken the time to think through how that
> might be implemented.

I'd prefer this one.

Alex

> 3. Cast to int (this has been used in other places throughout the
> kernel, but provides the weakest type safety and doesn't catch future
> divergence).
> 4. Disabling the warning. (I almost never advocate for this).
>
> > Another question is if it is such a good idea to just silence the warning?
>
> For the kernel, it seems that each maintainer can choose what to apply
> to their subsystem.  I would recommend against disabling additional
> warnings that aren't disable kernel-wide for most cases.
> -Wenum-conversion has spotted many bugs.  While the enums in question
> today are not different, they MIGHT eventually diverge and lead to
> bugs, like the others we've found and fixed throughout the kernel.  So
> I would recommend fixing now, and be insulated in the future.
>
> --
> Thanks,
> ~Nick Desaulniers
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

      reply	other threads:[~2019-03-21  4:44 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20  0:54 Clang warning in drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c Nathan Chancellor
2019-03-20  1:31 ` Pan, Xinhui
2019-03-20  4:34   ` Nathan Chancellor
2019-03-20  9:37     ` Koenig, Christian
     [not found]       ` <63518f1f-b808-77b0-aac6-ee1ece669c4b-5C7GfCeVMHo@public.gmane.org>
2019-03-20 14:58         ` Stephen Hines
2019-03-20 15:32           ` Stephen Hines
2019-03-20 15:44           ` Nathan Chancellor
2019-03-21  6:58             ` Pan, Xinhui
2019-03-20 17:19       ` Nick Desaulniers
2019-03-21  4:44         ` Alex Deucher [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='CADnq5_PTfJXJ99gFhxeMZ3RKigkipwjH5jLqfNM3mv49Z=d7Bw@mail.gmail.com' \
    --to=alexdeucher@gmail.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=David1.Zhou@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=clang-built-linux@googlegroups.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.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;
as well as URLs for NNTP newsgroup(s).