Commit Graph

480 Commits

Author SHA1 Message Date
Bastien Nocera
ad2c296b46 iio: Fix sysfs attribute verification failing
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
2022-03-29 21:57:13 +02:00
Bastien Nocera
3d67c6dc83 iio: Remove left-over debug 2022-03-29 21:48:17 +02:00
Bastien Nocera
7124a42d34 tests: Bump timeout when running under valgrind 2022-03-25 16:55:38 +01:00
Bastien Nocera
5ba03b0636 main: Fix warning in accel_changed_func()
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
2022-03-25 16:45:26 +01:00
Bastien Nocera
ac053f8a12 iio: Remove fscanf usage in _write_sysfs_string()
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.
2022-03-25 16:45:26 +01:00
Bastien Nocera
7ba893a6c9 iio: Simplify _write_sysfs_string()
Use g_autofree to avoid a goto on error.
2022-03-25 16:45:26 +01:00
Bastien Nocera
62bb35960e iio: Fix filename variable leak in build_channel_array()
From Coverity:
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:289: leaked_storage: Variable "filename" going out of scope leaks the storage it points to.
2022-03-25 16:45:25 +01:00
Bastien Nocera
d87732b64c iio: Fix channel info leak in build_channel_array()
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'
2022-03-25 16:45:18 +01:00
Bastien Nocera
18a043f37f iio: Fix leak in buffer_drv_data_free()
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'
2022-03-25 16:45:04 +01:00
Bastien Nocera
a4b1f3ee09 mount-matrix: Fix unchecked return value
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).
2022-03-25 12:41:15 +01:00
Bastien Nocera
6a4d5fab95 mount-matrix: Split off getting the identity mount matrix 2022-03-25 12:41:15 +01:00
Bastien Nocera
2e3d7bb735 main: Check g_setenv() return value
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.
2022-03-25 12:41:11 +01:00
Bastien Nocera
a279a80502 iio: Fix filename leak in iioutils_get_param_float()
From Coverity:
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:173: leaked_storage: Variable "filename" going out of scope leaks the storage it points to.
2022-03-25 12:41:07 +01:00
Bastien Nocera
1f4e5cff01 iio: Fix filename variable leak in iioutils_get_type()
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.
2022-03-25 12:41:01 +01:00
Bastien Nocera
0ca8016560 iio: Simplify iioutils_break_up_name()
Use g_auto() to simplify the memory management.
2022-03-25 11:49:39 +01:00
Bastien Nocera
418f00ac40 build: Fix run_command() usage in newer meson
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
2022-03-25 11:48:59 +01:00
Bastien Nocera
716ee37d51 main: Prefer buffer driver to polling driver
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
2022-03-15 10:57:26 +01:00
Bastien Nocera
1728742047 drivers: Print debug when accelerometers are ignored 2022-03-14 13:00:10 +01:00
Bastien Nocera
6a07e25826 accel: Add enum to string helper 2022-03-14 13:00:10 +01:00
Guido Günther
bba4560748 README: Document near-level property
Linux 5.6 added the near level property in 445b16fb6bdc2 which can
be used in DT based devices to give a default.
2021-12-21 17:00:43 +01:00
Bastien Nocera
0b1574d0eb main: Check whether user is allowed to claim a sensor
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.
2021-09-29 12:06:55 +02:00
Bastien Nocera
abd16b5911 tests: Start mock polkitd in the tests
And allow all us to perform all the actions.
2021-09-29 11:54:26 +02:00
Bastien Nocera
63a84af6a2 data: Add polkit policy description
Describe and set defaults for claiming sensors.
2021-09-29 11:54:26 +02:00
Bastien Nocera
b68811417e tests: Split the integration test into individual tests
unittest_inspector.py lists the tests in the integration-test.py script,
which are then added as individual tests.
2021-09-07 11:06:25 +02:00
Bastien Nocera
74b71d9a3b tests: Rename integration test script
Add the python suffix.
2021-09-07 10:50:35 +02:00
Bastien Nocera
a7b603270f main: Print version in debug output on startup
This will stop needing to ask users that read the README when reporting
bugs but don't include this info.
2021-08-19 20:35:46 +02:00
Bastien Nocera
860405323b ci: Remove libgudev manual installation
The package is already available in repositories.
2021-08-19 20:35:46 +02:00
Bastien Nocera
83d963b345 3.3 2021-08-16 14:52:44 +02:00
Bastien Nocera
f42263d434 tests: Add tests for 0.0 IIO offsets
Test both parts of iioutils_get_param_float() for 0.0 readings.
2021-08-16 14:44:57 +02:00
Bastien Nocera
8980b8b74f iio: Allow "0.0" as an offset
0.0 is a valid offset.

https://bugzilla.redhat.com/show_bug.cgi?id=1978419#c11
2021-08-16 14:26:04 +02:00
Bastien Nocera
b6c4c7ccb7 3.2 2021-08-15 00:30:39 +02:00
Bastien Nocera
93a10cd84d tests: Another test for misparsed scale in some locales
Polling accelerometer drivers read the accelerometer scales using
libgudev. Check that libgudev is new enough and this bug is fixed:
https://gitlab.gnome.org/GNOME/libgudev/-/merge_requests/17
2021-08-15 00:18:43 +02:00
Bastien Nocera
7559d9b652 build: Require a newer libgudev to fix scale parsing errors 2021-08-15 00:18:43 +02:00
Bastien Nocera
4a0033c8dd ci: Install newer libgudev 2021-08-15 00:18:35 +02:00
Bastien Nocera
2f94e4981f iio: Error out when scale is parsed as 0.0 2021-08-14 22:48:54 +02:00
Bastien Nocera
cb8b8c3282 tests: Test for misparsed scale in some locales
Check that the scale is correctly parsed in the French locale.
2021-08-14 22:48:54 +02:00
Bastien Nocera
a0d058eeb1 iio: Fix iioutils_get_param_float() in some locales
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: 9f49caaf17

Closes: #331
2021-08-14 22:48:54 +02:00
Bastien Nocera
06b72df254 tests: Test for unparseable mount matrix in some locales 2021-08-14 22:48:54 +02:00
Bastien Nocera
55377329a2 mount-matrix: Fix parsing of mount matrix in some locales
Fix parsing of mount matrix in locales that use a comma as a decimal
separator.

Fixes: 9f49caaf17

Closes: #330
2021-08-14 22:48:54 +02:00
Bastien Nocera
38c1b4d5c1 ci: Add French locale to CI 2021-08-14 22:48:54 +02:00
Bastien Nocera
c5aea53101 tests: Initialise i18n in tests 2021-08-14 22:48:54 +02:00
Bastien Nocera
61a44175ca mount-matrix: Fix deprecation warning
src/accel-mount-matrix.c: In function ‘parse_mount_matrix’:
src/accel-mount-matrix.c:121:17: warning: ‘g_memdup’ is deprecated: Use 'g_memdup2' instead [-Wdeprecated-declarations]
  121 |                 *vecs = g_memdup (id_matrix, sizeof(id_matrix));
      |                 ^
2021-08-14 22:48:54 +02:00
Bastien Nocera
eb38ddb0d2 ci: Remove python-dbusmock hacks 2021-08-14 10:42:19 +02:00
Bastien Nocera
96c0b33191 mount-matrix: Fix stringop-overflow warnings
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,
      | ^~~~~~~~~~~~~~~~~~
2021-07-25 00:38:23 +02:00
Bastien Nocera
49d3771716 3.1 2021-06-14 13:40:32 +02:00
Bastien Nocera
f9f4976582 ci: Export the created dist 2021-06-14 13:40:32 +02:00
Bastien Nocera
9300c064bd build: Update version
meson port was started before 3.0 was released, and we haven't had a
meson release yet, so this slipped.
2021-06-14 13:40:32 +02:00
Bastien Nocera
5c6fa19b17 ci: Work-around uninstallable python-dbusmock in rawhide 2021-06-14 13:30:46 +02:00
Bastien Nocera
99a3737418 tests: Add integration test for "label" accel location
Make sure that accelerometers with a "accel-base" label get ignored.
2021-06-11 12:54:54 +02:00
Bastien Nocera
27a325b2f5 accel: Add support for the new "accel-*" IIO labels
See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9a6df4b1ab0e467f23ccdcbb82700cfb3eaf44a3
2021-06-11 12:54:48 +02:00