[libgudev/wip/hadess/add-cached-info] gudev: Mention that sysfs_attr functions are cached



commit d0bd1da7a14323497b435b37ec99aa9375e751c1
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jul 16 17:11:47 2020 +0200

    gudev: Mention that sysfs_attr functions are cached
    
    Bit me once again, so best to make it clear in the API documentation
    that sysfs_attr are only fetched _once_.
    
    libgudev calls udev_device_get_sysattr_value() which says in its docs:
    
https://github.com/systemd/systemd/blob/4d939d2c849fea2169082451a90722030dca5139/src/libudev/libudev-device.c#L730-L731

 gudev/gudevdevice.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
---
diff --git a/gudev/gudevdevice.c b/gudev/gudevdevice.c
index 7838cec..6533099 100644
--- a/gudev/gudevdevice.c
+++ b/gudev/gudevdevice.c
@@ -761,7 +761,9 @@ g_udev_device_has_sysfs_attr (GUdevDevice  *device,
  * @device: A #GUdevDevice.
  * @name: Name of the sysfs attribute.
  *
- * Look up the sysfs attribute with @name on @device.
+ * Look up the sysfs attribute with @name on @device. The retrieved value
+ * is cached in the device. Repeated calls will return the same value and
+ * not open the attribute again.
  *
  * Returns: (nullable): The value of the sysfs attribute or %NULL if
  * there is no such attribute. Do not free this string, it is owned by
@@ -782,7 +784,8 @@ g_udev_device_get_sysfs_attr (GUdevDevice  *device,
  * @name: Name of the sysfs attribute.
  *
  * Look up the sysfs attribute with @name on @device and convert it to an integer
- * using strtol().
+ * using strtol(). The retrieved value is cached in the device. Repeated calls
+ * will return the same value and not open the attribute again.
  *
  * Returns: The value of the sysfs attribute or 0 if there is no such
  * attribute.
@@ -813,7 +816,9 @@ out:
  * @name: Name of the sysfs attribute.
  *
  * Look up the sysfs attribute with @name on @device and convert it to an unsigned
- * 64-bit integer using g_ascii_strtoull().
+ * 64-bit integer using g_ascii_strtoull(). The retrieved value is cached in the
+ * device. Repeated calls will return the same value and not open the attribute
+ * again.
  *
  * Returns: The value of the sysfs attribute or 0 if there is no such
  * attribute.
@@ -844,7 +849,9 @@ out:
  * @name: Name of the sysfs attribute.
  *
  * Look up the sysfs attribute with @name on @device and convert it to a double
- * precision floating point number using strtod().
+ * precision floating point number using strtod(). The retrieved value is cached
+ * in the device. Repeated calls will return the same value and not open the
+ * attribute again.
  *
  * Returns: The value of the sysfs attribute or 0.0 if there is no such
  * attribute.
@@ -876,7 +883,9 @@ out:
  *
  * Look up the sysfs attribute with @name on @device and convert it to an
  * boolean. This is done by doing a case-insensitive string comparison
- * on the string value against "1" and "true".
+ * on the string value against "1" and "true". The retrieved value is
+ * cached in the device. Repeated calls will return the same value and
+ * not open the attribute again.
  *
  * Returns: The value of the sysfs attribute or %FALSE if there is no such
  * attribute.
@@ -913,6 +922,9 @@ g_udev_device_get_sysfs_attr_as_boolean (GUdevDevice  *device,
  * tab ('\t'), and vertical tab ('\v') are considered; the locale is
  * not taken into account).
  *
+ * The retrieved value is cached in the device. Repeated calls will return
+ * the same value and not open the attribute again.
+ *
  * Returns: (nullable) (transfer none) (array zero-terminated=1) (element-type utf8):
  * The value of the sysfs attribute split into tokens or %NULL if
  * there is no such attribute. This array is owned by @device and


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