[libgudev/wip/hadess/uncached-bools: 1/3] gudev: Add support for Y/N, y/n as bool sysfs attributes




commit 407798b74dfdc57aef1eb30bec18da91014b756c
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Mar 16 10:54:05 2021 +0100

    gudev: Add support for Y/N, y/n as bool sysfs attributes
    
    Which matches the string representation of a "bool" as used in module
    parameters:
    "
    Standard types are:
    [...]
     *  bool: a bool, values 0/1, y/n, Y/N.
    "
    
    See 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/moduleparam.h#n123

 gudev/gudevdevice.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/gudev/gudevdevice.c b/gudev/gudevdevice.c
index df6ebd1..8505b9a 100644
--- a/gudev/gudevdevice.c
+++ b/gudev/gudevdevice.c
@@ -926,8 +926,12 @@ g_udev_device_get_sysfs_attr_as_boolean (GUdevDevice  *device,
   if (s == NULL)
     goto out;
 
-  if (strcmp (s, "1") == 0 || g_ascii_strcasecmp (s, "true") == 0)
+  if (strcmp (s, "1") == 0 ||
+      g_ascii_strcasecmp (s, "true") == 0 ||
+      g_ascii_strcasecmp (s, "y") == 0) {
     result = TRUE;
+  }
+
  out:
   return result;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]