mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-24 19:20:06 +01:00
tools: print an error if we don't have any matching events in the dpi tool
Beats crashing by dereferencing a null-pointer (when we access m->frequencies[idx]) Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
parent
a155a977b7
commit
1ec01b1310
1 changed files with 9 additions and 2 deletions
|
|
@ -215,8 +215,15 @@ static void
|
|||
print_summary(struct libevdev *dev, struct measurements *m)
|
||||
{
|
||||
int res;
|
||||
int max_freq = (int)m->max_frequency,
|
||||
mean_freq = (int)mean_frequency(m);
|
||||
int max_freq, mean_freq;
|
||||
|
||||
if (m->nfrequencies == 0) {
|
||||
fprintf(stderr, "Error: no matching events received.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
max_freq = (int)m->max_frequency;
|
||||
mean_freq = (int)mean_frequency(m);
|
||||
|
||||
printf("Estimated sampling frequency: %dHz (mean %dHz)\n",
|
||||
max_freq, mean_freq);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue