diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2021-03-29 14:21:46 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2021-04-23 10:22:39 +1000 |
commit | c582cb3d07de2adbbf7741f33dc84dbaa78dfc75 (patch) | |
tree | 6a6e1e299ff75c268a4b6d3cec7bbed86c6dd0aa | |
parent | 1193498d8818e2122f0b2741a5c6cf332a419e8e (diff) | |
download | libwacom-c582cb3d07de2adbbf7741f33dc84dbaa78dfc75.tar.gz |
Reorder the fallback handling for better readability
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | libwacom/libwacom.c | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/libwacom/libwacom.c b/libwacom/libwacom.c index 4fc88c3..935344c 100644 --- a/libwacom/libwacom.c +++ b/libwacom/libwacom.c @@ -555,15 +555,15 @@ libwacom_new_from_path(const WacomDeviceDatabase *db, const char *path, WacomFal match_name = NULL; device = libwacom_new (db, match_name, vendor_id, product_id, bus, error); } - if (device != NULL) - ret = libwacom_copy(device); - else if (fallback == WFALLBACK_NONE) - goto bail; - if (device == NULL && fallback == WFALLBACK_GENERIC) { + if (device == NULL) { + if (fallback == WFALLBACK_NONE) + goto out; + + /* WFALLBACK_GENERIC */ device = libwacom_get_device(db, "generic"); if (device == NULL) - goto bail; + goto out; ret = libwacom_copy(device); @@ -571,6 +571,8 @@ libwacom_new_from_path(const WacomDeviceDatabase *db, const char *path, WacomFal g_free (ret->name); ret->name = g_strdup(name); } + } else { + ret = libwacom_copy(device); } /* for multiple-match devices, set to the one we requested */ @@ -578,20 +580,15 @@ libwacom_new_from_path(const WacomDeviceDatabase *db, const char *path, WacomFal libwacom_set_default_match(ret, match); libwacom_match_unref(match); - if (device) { - /* if unset, use the kernel flags. Could be unset as well. */ - if (ret->integration_flags == WACOM_DEVICE_INTEGRATED_UNSET) - ret->integration_flags = integration_flags; - - g_free (name); - - return ret; - } + /* if unset, use the kernel flags. Could be unset as well. */ + if (device && ret->integration_flags == WACOM_DEVICE_INTEGRATED_UNSET) + ret->integration_flags = integration_flags; -bail: +out: g_free (name); - libwacom_error_set(error, WERROR_UNKNOWN_MODEL, NULL); - return NULL; + if (ret == NULL) + libwacom_error_set(error, WERROR_UNKNOWN_MODEL, NULL); + return ret; } LIBWACOM_EXPORT WacomDevice* |