[PATCH weston 1/2] libinput: Suppress unhandled-case warning
daniel at fooishbar.org
Wed Mar 15 09:23:29 UTC 2017
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?
More information about the wayland-devel