summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2021-08-13 12:48:16 +0200
committerBastien Nocera <hadess@hadess.net>2021-08-13 12:48:16 +0200
commitaf51f0e4994ec52f40a07cd1c373b592bab3a14d (patch)
tree65897d48722896fdd7b556b1468d710701bd1f40
parent1bcf1e7d8d77b56e669758531dc9a48a15c42ecb (diff)
downloadlibgudev-af51f0e4994ec52f40a07cd1c373b592bab3a14d.tar.gz
gudev: Fix double parsing in locale with , as a decimal separator
All the functions parsing double values from sysfs were using strtod to parse the values instead of g_ascii_strtod() which forces C locale parsing. All the kernel values use C locale formatted doubles, so use g_ascii_strtod().
-rw-r--r--gudev/gudevdevice.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/gudev/gudevdevice.c b/gudev/gudevdevice.c
index 565fa28..38473dd 100644
--- a/gudev/gudevdevice.c
+++ b/gudev/gudevdevice.c
@@ -568,7 +568,7 @@ out:
* @key: Name of property.
*
* Look up the value for @key on @device and convert it to a double
- * precision floating point number using strtod().
+ * precision floating point number using g_ascii_strtod().
*
* Returns: The value for @key or 0.0 if @key doesn't exist or isn't a
* #gdouble.
@@ -588,7 +588,7 @@ g_udev_device_get_property_as_double (GUdevDevice *device,
if (s == NULL)
goto out;
- result = strtod (s, NULL);
+ result = g_ascii_strtod (s, NULL);
out:
return result;
}
@@ -856,7 +856,7 @@ 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(). The retrieved value is cached
+ * precision floating point number using g_ascii_strtod(). The retrieved value is cached
* in the device. Repeated calls will return the same value and not open the
* attribute again, unless updated through one of the "uncached" functions.
*
@@ -878,7 +878,7 @@ g_udev_device_get_sysfs_attr_as_double (GUdevDevice *device,
if (s == NULL)
goto out;
- result = strtod (s, NULL);
+ result = g_ascii_strtod (s, NULL);
out:
return result;
}
@@ -1114,7 +1114,7 @@ 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(). This function does blocking
+ * precision floating point number using g_ascii_strtod(). This function does blocking
* I/O, and updates the sysfs attributes cache.
*
* Returns: The value of the sysfs attribute or 0.0 if there is no such
@@ -1135,7 +1135,7 @@ g_udev_device_get_sysfs_attr_as_double_uncached (GUdevDevice *device,
if (s == NULL)
goto out;
- result = strtod (s, NULL);
+ result = g_ascii_strtod (s, NULL);
out:
return result;
}