From: Yu Watanabe Date: Tue, 13 May 2025 14:59:50 +0000 (+0900) Subject: backlight: use device_get_sysattr_unsigned() at one more place X-Git-Tag: v258-rc1~625^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=25151ca2b8ec091f046ab4d4328e5b8d767b6eed;p=thirdparty%2Fsystemd.git backlight: use device_get_sysattr_unsigned() at one more place --- 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. */