Commit graph

70 commits

Author SHA1 Message Date
Peter Hutterer
77b36de85d touchpad: reduce the jumping cursor warnings to 5 per day
It's been a while since we really could do something about those jumps,
so let's assume most of these are informative and not a bug in libinput.
For that let's not spam the user's journal and ratelimit it to a handful
a day.

Per day because that increases the chance of an error being present in
the recent logs if the user does search for it.

Related #663

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-09-17 09:03:17 +10:00
José Expósito
dbcb003c5e util: add a function to parse bool properties
Move the logic used to parse boolean quirks and udev flags to a common
function in utils.

Refactor, no functional changes.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-09-12 21:16:32 +00:00
Peter Hutterer
492f6817d3 util-list: restore list_for_each_safe() to be a single statement
3d3d9b7f69 got rid of the need for a tmp
argument for list_for_each_safe() but switched the loop to be a
multiline statement. This could potentially cause bugs where the loop is
used inside a block without curly braces, e.g.

    if (condition)
        list_for_each_safe()
            func()

The assignment preceding the actual loop would result in the code
reading as:

    if (condition)
        pos = ....

    list_for_each_safe()

The actual list loop would be unconditional.

Fix this by moving the initial assignment into an expression statement.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 12:53:08 +10:00
Peter Hutterer
7f4df04d59 tools/record: deduplicate the device opening logic
With a new helper function strv_from_argv we can re-use the device opening
loop for all the use-cases we have.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-30 08:26:30 +10:00
Peter Hutterer
671eb8cbbb utils: add a safe version of basename
So we don't need to worry about the libgen.h include game.
And we can switch trunkname over to that, making it a bit simpler.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-23 10:56:53 +10:00
Peter Hutterer
e6ed506df3 utils: add a trunkname() function to extract the trunk of a filename
/path/to/foo.bar returns "foo"

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-02-12 14:31:50 +10:00
weizhixiang
2ea6589892 modify macro streq/strneq for check one null pointer
Signed-off-by: weizhixiang <1138871845@qq.com>
Minor modifications applied by Peter Hutterer <peter.hutterer@who-t.net>
2021-01-18 17:46:17 +10:00
Peter Hutterer
e882bd0216 quirks: add AttrInputPropEnable and Disable
The latter requires libevdev 1.10 but since that'll take a while to filter
into our various CI systems, let's make it conditional.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-23 13:35:50 +10:00
Peter Hutterer
bd1fcb9c6e utils: add strstartswith() and strendswith() utility functions
Modeled after Python's str.startswith() and str.endswith()

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-06-17 07:52:00 +00:00
Peter Hutterer
05201958eb evdev: print a human time for ratelimit tests
No point in printing an interval of e.g. 2h as milliseconds, let's convert
this to something human-readable.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-03-22 10:35:21 +10:00
Peter Hutterer
d80bbcb028 tools: record: drop quotes from os-release information
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-03-21 11:02:48 +10:00
Peter Hutterer
148b147173 test: indentation fix
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-01-03 16:44:03 +10:00
Peter Hutterer
bfc4980754 test: add the test cases to the suite in the utils tests
oops...

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-01-03 16:44:03 +10:00
Peter Hutterer
e7a9c07ffe udev: parse the EVDEV_ABS properties for a potential fuzz setting
Where a fuzz is defined in the 60-evdev.hwdb, we rely on a udev builtin to
set the kernel device to that fuzz value. Unfortunately that happens after our
program is called with this order of events:
1. 60-evdev.rules calls IMPORT(builtin) for the hwdb which sets the EVDEV_ABS_*
  properties. It also sets RUN{builtin}=keyboard but that's not invoked yet.
2. 90-libinput-fuzz-override.rules calls IMPORT{program} for our fuzz override
  bits. That sets the kernel fuzz value to 0 and sets the LIBINPUT_FUZZ_*
  propertie
3. The keyboard builtin is run once all the rules have been processed.

Our problem is that where the fuzz is set in a hwdb entry, the kernel fuzz is
still unset when we get to look at it, so we always end up with a fuzz of zero
for us and a nonzero kernel fuzz.

Work around this by checking the EVDEV_ABS property, extracting the fuzz from
there and re-printing that property without the fuzz. This way we ensure the
kernel remains at zero fuzz and we use the one from the hwdb instead.

Fixes #346

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-11 12:24:02 +10:00
Peter Hutterer
c84366e85e Split utility functions into separate source files
libinput-util.h is getting a bit of a catchall bucket and it includes things
like libinput-private.h which in turn includes libwacom. This makes
libinput-util.h less useful for bits that only need e.g. the string processing
utilities.

So let's split them all up in to separate files, to be used as-needed.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-11 12:23:04 +10:00
Peter Hutterer
00f3345b80 test: do run the util tests under valgrind
These tests include string parsers, definitely want those to run under
valgrind to detect OOB reads and writes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-11 12:21:44 +10:00
Michael Forney
9d1b43d241 Avoid unnecessary VLAs
When the array length is fixed, or bounded by a fixed upper bound,
just use that fixed length.

Signed-off-by: Michael Forney <mforney@mforney.org>
2019-06-15 15:24:10 -07:00
Peter Hutterer
2185a9d6bd test: return 77 for skip when we're not running a test
This isn't technically needed since those tests aren't in the valgrind test
suite anymore. But let's have it here anyway.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-05-07 04:48:00 +00:00
Peter Hutterer
01efe9de4f test: replace the USING_VALGRIND env with the valgrind.h header
This header is intended to be included in the project, so let's do that and
have proper runtime detection of the valgrind environment.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-05-07 04:48:00 +00:00
Peter Hutterer
cbbd5b15c6 test: split out the unit tests into a separate test suite
All the bits that test for utility functions to work correctly can be run
separately from the main test suite (which tests devices and libinput in
general). These bits here are the ones that test the code itself and aren't
reliant on anything else.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-03-14 11:28:05 +10:00