Date: Thu, 11 Mar 2021 08:50:00 GMT From: Emmanuel Vadot <manu@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: cb603e3ea2d4 - releng/13.0 - backlight: Fix incr/decr with percent value of 0 Message-ID: <202103110850.12B8o0rX053134@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch releng/13.0 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=cb603e3ea2d4f2fee8fa4e59bda7e27704b6899c commit cb603e3ea2d4f2fee8fa4e59bda7e27704b6899c Author: David Schlachter <fbsd-bugzilla@schlachter.ca> AuthorDate: 2021-03-03 07:57:35 +0000 Commit: Emmanuel Vadot <manu@FreeBSD.org> CommitDate: 2021-03-11 08:49:03 +0000 backlight: Fix incr/decr with percent value of 0 This now does nothing instead of incr/decr by 10% MFC After: 3 days PR: 253736 Approved by: re (gjb) (cherry picked from commit 3b005d51bd0fe4d8d19fb2df4d470b6e8baebf16) (cherry picked from commit 9ba393f2ca0fd561c1fbf96f38eb014d7f883381) --- usr.bin/backlight/backlight.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/usr.bin/backlight/backlight.c b/usr.bin/backlight/backlight.c index 1dae0cfe5c62..9cf7a0912e95 100644 --- a/usr.bin/backlight/backlight.c +++ b/usr.bin/backlight/backlight.c @@ -98,7 +98,7 @@ main(int argc, char *argv[]) BACKLIGHTGETSTATUS, BACKLIGHTUPDATESTATUS, BACKLIGHTGETINFO}; - long percent = 0; + long percent = -1; const char *percent_error; uint32_t i; bool setname; @@ -188,15 +188,20 @@ main(int argc, char *argv[]) } break; case BACKLIGHT_SET_BRIGHTNESS: + if (percent == -1) + usage(); props.brightness = percent; if (ioctl(fd, BACKLIGHTUPDATESTATUS, &props) == -1) errx(1, "Cannot update the backlight device"); break; case BACKLIGHT_INCR: case BACKLIGHT_DECR: + if (percent == 0) + /* Avoid any ioctl if we don't have anything to do */ + break; if (ioctl(fd, BACKLIGHTGETSTATUS, &props) == -1) errx(1, "Cannot query the backlight device"); - percent = percent == 0 ? 10 : percent; + percent = percent == -1 ? 10 : percent; percent = action == BACKLIGHT_INCR ? percent : -percent; props.brightness += percent; if ((int)props.brightness < 0)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202103110850.12B8o0rX053134>