From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
intel-gfx@lists.freedesktop.org,
Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [PATCH] drm/i915: Reword warning for missing cases
Date: Tue, 13 Mar 2018 15:23:54 +0200 [thread overview]
Message-ID: <20180313132354.GW5453@intel.com> (raw)
In-Reply-To: <152094640984.515.8587384337375190871@mail.alporthouse.com>
On Tue, Mar 13, 2018 at 01:06:49PM +0000, Chris Wilson wrote:
> Quoting Ville Syrjälä (2018-03-13 13:01:42)
> > On Tue, Mar 13, 2018 at 12:17:13AM +0000, Chris Wilson wrote:
> > > Quoting Lucas De Marchi (2018-03-13 00:03:12)
> > > > In some places we end up converting switch statements to a series of
> > > > if/else, particularly when introducing helper functions to handle a
> > > > group of cases. It's tempting to either leave a wrong warning (since now
> > > > we don't have a switch case anymore) or to convert to WARN(1, ...),
> > > > losing what MISSING_CASE() provides: source location and id number.
> > > >
> > > > Fix the message to allow reusing MISSING_CASE() - it may not always be
> > > > correct (e.g. if you are not checking an id anymore), but it avoids
> > > > useless conversions. A quick grep reveals at least a few users in
> > > > drivers/gpu/drm/i915/intel_csr.c and drivers/gpu/drm/i915/intel_ddi.c.
> > > >
> > > > Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
> > > > ---
> > > > drivers/gpu/drm/i915/i915_utils.h | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/i915/i915_utils.h b/drivers/gpu/drm/i915/i915_utils.h
> > > > index 51dbfe5bb418..8cdc21b92f5f 100644
> > > > --- a/drivers/gpu/drm/i915/i915_utils.h
> > > > +++ b/drivers/gpu/drm/i915/i915_utils.h
> > > > @@ -40,7 +40,7 @@
> > > > #undef WARN_ON_ONCE
> > > > #define WARN_ON_ONCE(x) WARN_ONCE((x), "%s", "WARN_ON_ONCE(" __stringify(x) ")")
> > > >
> > > > -#define MISSING_CASE(x) WARN(1, "Missing switch case (%lu) in %s\n", \
> > > > +#define MISSING_CASE(x) WARN(1, "Missing case (%lu) in %s\n", \
> > > > (long)(x), __func__)
> > >
> > > Whilst here you could make this more informative by:
> > > "Missing case (%s = %lu) in %s\n", __stringify(x), (long)(x), __func__
> >
> > The backtrace isn't enough?
>
> Not if we have more than one in a function.
I was just commenting on the __func__ part actually. That seems pretty
much redundant to me. The stringify part does seem like a decent idea,
and matches our WARN() trickery pretty well.
> (Why would we do that, you
> might ask, and I'd answer if the point is to make this more generic and
> versatile, then do so. We already have the value, why not then explain
> what that value is.) And give me a single sentence identifying the missing
> case makes it much more pleasant.
> -Chris
--
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2018-03-13 13:23 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-13 0:03 [PATCH] drm/i915: Reword warning for missing cases Lucas De Marchi
2018-03-13 0:17 ` Chris Wilson
2018-03-13 13:01 ` Ville Syrjälä
2018-03-13 13:06 ` Chris Wilson
2018-03-13 13:23 ` Ville Syrjälä [this message]
2018-03-14 21:59 ` Lucas De Marchi
2018-03-19 17:37 ` [PATCH v2] " Lucas De Marchi
2018-03-19 21:41 ` Chris Wilson
2018-03-27 17:37 ` Rodrigo Vivi
2018-03-13 0:39 ` ✓ Fi.CI.BAT: success for " Patchwork
2018-03-13 6:15 ` ✓ Fi.CI.IGT: " Patchwork
2018-03-19 18:36 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: Reword warning for missing cases (rev2) Patchwork
2018-03-19 21:55 ` Lucas De Marchi
2018-03-19 18:51 ` ✗ Fi.CI.BAT: failure " Patchwork
2018-03-26 18:23 ` ✗ Fi.CI.CHECKPATCH: warning " Patchwork
2018-03-26 18:40 ` ✓ Fi.CI.BAT: success " Patchwork
2018-03-26 19:57 ` ✓ Fi.CI.IGT: " 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=20180313132354.GW5453@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=daniel.vetter@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.org \
--cc=lucas.demarchi@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;
as well as URLs for NNTP newsgroup(s).