diff options
author | Bastien Nocera <hadess@hadess.net> | 2021-03-16 12:02:13 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2021-03-16 12:02:13 +0100 |
commit | 70db9f988b23020b353f1936b024a6fc49afe6c5 (patch) | |
tree | 7e4e5a3a78afa67086446a30919b58c0a7e2d2ea | |
parent | ca88a4be7e6844e39b3181caa6fc93455183cdc9 (diff) | |
download | libgudev-70db9f988b23020b353f1936b024a6fc49afe6c5.tar.gz |
gudev: Fix 'Y' in _sysfs_attr_as_boolean_uncached()
The changes made haphazardly in e186dac0 and 31e31d52 were documented
for _sysfs_attr_as_boolean_uncached() but not implemented.
-rw-r--r-- | gudev/gudevdevice.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gudev/gudevdevice.c b/gudev/gudevdevice.c index b38bd4d..ec792da 100644 --- a/gudev/gudevdevice.c +++ b/gudev/gudevdevice.c @@ -1171,18 +1171,26 @@ g_udev_device_get_sysfs_attr_as_boolean_uncached (GUdevDevice *device, const gchar *name) { gboolean result; - const gchar *s; + const gchar *raw; + g_autofree char *truncated = NULL; + const char *s; g_return_val_if_fail (G_UDEV_IS_DEVICE (device), FALSE); g_return_val_if_fail (name != NULL, FALSE); result = FALSE; - s = g_udev_device_get_sysfs_attr_uncached (device, name); - if (s == NULL) + raw = g_udev_device_get_sysfs_attr_uncached (device, name); + if (raw == NULL) goto out; - if (strcmp (s, "1") == 0 || g_ascii_strcasecmp (s, "true") == 0) + truncated = truncate_at_linefeed (raw); + s = truncated ?: raw; + if (strcmp (s, "1") == 0 || + g_ascii_strcasecmp (s, "true") == 0 || + g_ascii_strcasecmp (s, "y") == 0) { result = TRUE; + } + out: return result; } |