Do not catch values not covered by an enum
commit58a409dcbc83b63417d5dc2b4c3cb0bd3e0e53fd
authorMarc Schink <jaylink-dev@marcschink.de>
Sun, 7 Aug 2016 16:22:03 +0000 (7 18:22 +0200)
committerMarc Schink <jaylink-dev@marcschink.de>
Sat, 10 Sep 2016 09:01:16 +0000 (10 11:01 +0200)
tree812565b9d469aadf5025df656b2a17b7e1c0bf9e
parentc690cc11e12c7811ec83197a50efe2dd1dd210ff
Do not catch values not covered by an enum

Currently, the functions jaylink_select_interface() and
jaylink_get_selected_interface() check if the target interface value
returned by a device is covered by an enum. If this is not the case they
fail with an error.

This approach is very restrictive and may stop applications from
working when using devices with target interfaces or other values which
are not covered by an enum. It also requires to update libjaylink every
time a new value is introduced. This could occur with every update of
the device firmware. In the mean time applications would fail with such
devices.

Also, using this approach for jaylink_get_hardware_version() would make
it impossible to retrieve the hardware version number of a device with
a hardware type which is not yet covered by an enum. In the worst case
an application would fail because jaylink_get_hardware_version() fails
even though the application does not use the hardware type at all but
the hardware version.

Do not catch values returned by a device and not covered by an enum to
overcome these problems. Instead, add a warning to the documentation of
all functions which may return such values.

Signed-off-by: Marc Schink <jaylink-dev@marcschink.de>
libjaylink/device.c
libjaylink/target.c