We forgot to "steal" the pointer before returning from the function
successfully, so the file descriptor was closed. Oops.
Fixes: cc11240 ("fake-input-accelerometer: Simplify error paths")
sysfs usually appends newlines at the end of attributes to make them
easier to consume, but the test suite can't test for that.
** (iio-sensor-proxy:4882): WARNING **: 14:14:46.792: Possible failure in string write of 'accel_3d-dev0
' Should be 'accel_3d-dev0' written to /sys/devices/platform/AMDI0010:02/i2c-2/i2c-BMA250E:00/0018:6243:0001.0002/HID-SENSOR-200073.2.auto/iio:device0/trigger/current_trigger
Closes: #347
Fixes: ac053f8a12
From Coverity:
iio-sensor-proxy-3.3/src/iio-sensor-proxy.c:727:16: warning[deadcode.DeadStores]: Value stored to 'orientation' during its initialization is never read
From Coverity:
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:435: dont_call: "fscanf" assumes an arbitrarily long string, so callers must use correct precision specifiers or never use "fscanf".
This also fixes the temp variable being reused to parse the contents of
the sysfs file before being freed. How this behaves depends on the
length of the sysfs file path and the length of the string inside the
file.
On error, the channel info would just be left unfreed.
From Coverity:
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:330: leaked_storage: Variable "current" going out of scope leaks the storage it points to.
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:312: leaked_storage: Variable "current" going out of scope leaks the storage it points to.
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:304: leaked_storage: Variable "current" going out of scope leaks the storage it points to.
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:302: leaked_storage: Variable "current" going out of scope leaks the storage it points to.
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:293: leaked_storage: Variable "current" going out of scope leaks the storage it points to.
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:289: leaked_storage: Variable "current" going out of scope leaks the storage it points to.
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:350:2: warning[unix.Malloc]: Potential leak of memory pointed to by 'current'
From Coverity:
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:769: noescape: Resource "buffer_data" is not freed or pointed-to in "buffer_drv_data_free".
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:770:3: warning[unix.Malloc]: Potential leak of memory pointed to by 'buffer_data'
From Coverity:
iio-sensor-proxy-3.3/src/accel-mount-matrix.c:86: check_return: Calling "parse_mount_matrix" without checking return value (as is done elsewhere 10 out of 11 times).
From Coverity:
iio-sensor-proxy-3.3/src/iio-sensor-proxy.c:964: check_return: Calling "g_setenv("G_MESSAGES_DEBUG", "all", 1)" without checking return value. This library function may fail and return an error code.
From Coverity:
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:111: overwrite_var: Overwriting "filename" in "filename = g_build_filename(device_dir, "scan_elements", builtname, NULL)" leaks the storage that "filename" points to.
WARNING: You should add the boolean check kwarg to the run_command call.
It currently defaults to false,
but it will default to true in future releases of meson.
See also: https://github.com/mesonbuild/meson/issues/9300
In c7fb43e0, we added a buffer driver for ambient light sensors, but we
added it to the list of drivers in a way that would favour polling
drivers. Since we started using IIO_SENSOR_PROXY_TYPE to tag devices,
and as those can support multiple drivers, we need to prefer the buffer
driver as it's the one that doesn't require constant monitoring.
This also fixes operations on some Dell laptops where the polling driver
is completely broken.
See https://gitlab.freedesktop.org/hadess/iio-sensor-proxy/-/merge_requests/352
Check whether a particular user/D-Bus client is allowed to claim a
sensor.
The ClaimCompass method on net.hadess.SensorProxy.Compass doesn't have a
check as only the geoclue user is allowed to access this interface, as
per the D-Bus configuration.
Reimplement iioutils_get_param_float() to parse float data like it would
in the C locale. This fixes the scale being '0' for every axis on some
systems and in some locales.
This is used to get the scale and offset parameters from buffer IIO drivers.
Fixes: 9f49caaf17Closes: #331
iio-sensor-proxy/src/accel-mount-matrix.c:77:21: warning: ‘parse_mount_matrix’ accessing 24 bytes in a region of size 8 [-Wstringop-overflow=]
77 | if (parse_mount_matrix (mount_matrix, &ret))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
iio-sensor-proxy/src/accel-mount-matrix.c:77:21: note: referencing argument 2 of type ‘AccelVec3 **’
iio-sensor-proxy/src/accel-mount-matrix.c:91:1: note: in a call to function ‘parse_mount_matrix’
91 | parse_mount_matrix (const char *mtx,
| ^~~~~~~~~~~~~~~~~~