From 25151ca2b8ec091f046ab4d4328e5b8d767b6eed Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 13 May 2025 23:59:50 +0900 Subject: [PATCH] backlight: use device_get_sysattr_unsigned() at one more place --- src/backlight/backlight.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c index a39398a638c..665d0c17e45 100644 --- a/src/backlight/backlight.c +++ b/src/backlight/backlight.c @@ -8,6 +8,7 @@ #include "alloc-util.h" #include "argv-util.h" +#include "device-private.h" #include "device-util.h" #include "escape.h" #include "fileio.h" @@ -298,19 +299,14 @@ static int validate_device(sd_device *device) { static int read_max_brightness(sd_device *device, unsigned *ret) { unsigned max_brightness; - const char *s; int r; assert(device); assert(ret); - r = sd_device_get_sysattr_value(device, "max_brightness", &s); - if (r < 0) - return log_device_warning_errno(device, r, "Failed to read 'max_brightness' attribute: %m"); - - r = safe_atou(s, &max_brightness); + r = device_get_sysattr_unsigned(device, "max_brightness", &max_brightness); if (r < 0) - return log_device_warning_errno(device, r, "Failed to parse 'max_brightness' \"%s\": %m", s); + return log_device_warning_errno(device, r, "Failed to read/parse 'max_brightness' attribute: %m"); /* If max_brightness is 0, then there is no actual backlight device. This happens on desktops * with Asus mainboards that load the eeepc-wmi module. */ -- 2.47.3