[PATCH weston 1/2] libinput: Suppress unhandled-case warning

Peter Hutterer peter.hutterer at who-t.net
Wed Mar 15 22:48:06 UTC 2017

On Wed, Mar 15, 2017 at 09:23:29AM +0000, Daniel Stone wrote:
> Hey,
> On 14 March 2017 at 23:54, Peter Hutterer <peter.hutterer at who-t.net> wrote:
> > On Tue, Mar 14, 2017 at 05:26:50PM +0000, Daniel Stone wrote:
> >> When the wheel tilt source is present, gcc complains that we don't
> >> handle all possible enumeration values. We already ensure this cannot
> >> happen in its only caller (handle_pointer_axis), but gcc doesn't
> >> recognise this. Give it a default value to quiet the warning.
> >
> > tbh, I dislike adding default cases because the warnings are really
> > useful to spot which bits aren't handled correctly yet. Especially in cases
> > like restricted enums (that don't change that often) it's imo usually better
> > to add the missing cases to be clear about the code's intent.
> Fair enough; generally I agree, but I figured it'd be a bit cleaner to
> avoid a version check. Mostly though, it was because there's already a
> default case in the function's only caller which guarantees that no
> other case can ever trigger in this one. Could add an assert(0) in the
> default case here to make it really blindingly clear?

yeah, that would work. I also like the assert(!"Invalid type") approach so
there's an explanation right there.


More information about the wayland-devel mailing list