lkml.org 
[lkml]   [2022]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2 1/2] asus-wmi: Adjust tablet/lidflip handling to use enum
On Mon, Aug 8, 2022 at 6:13 PM Hans de Goede <hdegoede@redhat.com> wrote:
> On 8/8/22 17:48, Andy Shevchenko wrote:
> > On Mon, Aug 8, 2022 at 5:12 AM Luke D. Jones <luke@ljones.dev> wrote:

...

> > To the switch-cases, please add a "default" case to each of them.
>
> The switch-cases are on an enum type, so adding a default is
> not necessary and adding one will actually loose the useful
> compiler warning about unhandled enum values.

It's good if you can cover all enum values, which usually you can't.
enum according to the standard should be located in the type that is
enough to keep it and be compatible to a char. This means that the
code somewhere else may assign anything to enum (actually enum values
are type of int) and without default you can't see the difference here
and the compiler probably will be happy. That said, I doubt the
usefulness of such a warning. But it's up to you.

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2022-08-08 18:24    [W:0.047 / U:0.796 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site