[Mesa-dev] [PATCH] intel/aubinator_error_decode: Get rid of warning for missing switch case

Toni Lönnberg toni.lonnberg at intel.com
Tue Dec 4 14:08:43 UTC 2018


On Tue, Dec 04, 2018 at 01:41:37PM +0000, Eric Engestrom wrote:
> On Tuesday, 2018-12-04 14:14:51 +0200, Toni Lönnberg wrote:
> > ../src/intel/tools/aubinator_error_decode.c: In function ‘instdone_register_for_ring’:
> > ../src/intel/tools/aubinator_error_decode.c:177:4: warning: enumeration value ‘I915_ENGINE_CLASS_INVALID’ not handled in switch [-Wswitch]
> >     switch (class) {
> >     ^~~~~~
> > ---
> >  src/intel/tools/aubinator_error_decode.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/src/intel/tools/aubinator_error_decode.c b/src/intel/tools/aubinator_error_decode.c
> > index 49f0738e881..ea822d0161b 100644
> > --- a/src/intel/tools/aubinator_error_decode.c
> > +++ b/src/intel/tools/aubinator_error_decode.c
> > @@ -196,6 +196,9 @@ instdone_register_for_ring(const struct gen_device_info *devinfo,
> >  
> >     case I915_ENGINE_CLASS_VIDEO_ENHANCE:
> >        return "VECS_INSTDONE";
> > +
> > +   default:
> > +      return NULL;
> 
> I'd much prefer this:
> 
>   case I915_ENGINE_CLASS_INVALID:
>     unreachable("invalid class");
> 
> as using `default` essentially nullifies the whole point of -Wswitch.
> (btw, adding a `return NULL` right before `return NULL` seems redundant :P)

I'm good either way. As Lionel reviewed it already, he could change it before 
pushing.

> 
> >     }
> >  
> >     return NULL;
> > -- 
> > 2.17.1
> > 
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list