From a2b3c321244cf82de12d5dfa5854c287c3e7b535 Mon Sep 17 00:00:00 2001 From: Jente Hidskes Date: Mon, 11 Sep 2017 20:22:00 +0200 Subject: [PATCH] RatbagdResolution: clamp values instead of returning an error We cannot return error codes, but requesting a resync is overkill. Instead, let's be nice and clamp these values. --- ratbagd/ratbagd-resolution.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ratbagd/ratbagd-resolution.c b/ratbagd/ratbagd-resolution.c index 5f6f2100..0ea7cdef 100644 --- a/ratbagd/ratbagd-resolution.c +++ b/ratbagd/ratbagd-resolution.c @@ -282,8 +282,10 @@ ratbagd_resolution_set_report_rate(sd_bus *bus, return r; /* basic sanity check */ - if (rate > 5000 || rate % 100) - return 0; + if (rate > 5000) + rate = 5000; + else if (rate % 100) + rate = rate - (rate % 100); r = ratbag_resolution_set_report_rate(resolution->lib_resolution, rate);