summaryrefslogtreecommitdiffstats
path: root/src/backlight
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-06-30 12:28:50 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-06-30 15:19:21 +0200
commit74f1bb5c9fadd96c7753597aaeeebd96cf0c99f4 (patch)
treea565c0c0f218652a8f790aa2b456fa158cf53ced /src/backlight
parenthwdb: adjust touchpad edge detection for X1Tab3 (#16310) (diff)
downloadsystemd-74f1bb5c9fadd96c7753597aaeeebd96cf0c99f4.tar.xz
systemd-74f1bb5c9fadd96c7753597aaeeebd96cf0c99f4.zip
backlight: use SYNTHETIC_ERRNO() macro
Diffstat (limited to 'src/backlight')
-rw-r--r--src/backlight/backlight.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/src/backlight/backlight.c b/src/backlight/backlight.c
index 0484414290..bb6773e837 100644
--- a/src/backlight/backlight.c
+++ b/src/backlight/backlight.c
@@ -224,10 +224,8 @@ static int get_max_brightness(sd_device *device, unsigned *ret) {
if (r < 0)
return log_device_warning_errno(device, r, "Failed to parse 'max_brightness' \"%s\": %m", max_brightness_str);
- if (max_brightness <= 0) {
- log_device_warning(device, "Maximum brightness is 0, ignoring device.");
- return -EINVAL;
- }
+ if (max_brightness <= 0)
+ return log_device_warning_errno(device, SYNTHETIC_ERRNO(EINVAL), "Maximum brightness is 0, ignoring device.");
*ret = max_brightness;
return 0;
@@ -306,10 +304,8 @@ static int run(int argc, char *argv[]) {
unsigned max_brightness;
int r;
- if (argc != 3) {
- log_error("This program requires two arguments.");
- return -EINVAL;
- }
+ if (argc != 3)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "This program requires two arguments.");
log_setup_service();
@@ -320,19 +316,15 @@ static int run(int argc, char *argv[]) {
return log_error_errno(r, "Failed to create backlight directory /var/lib/systemd/backlight: %m");
sysname = strchr(argv[2], ':');
- if (!sysname) {
- log_error("Requires a subsystem and sysname pair specifying a backlight device.");
- return -EINVAL;
- }
+ if (!sysname)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Requires a subsystem and sysname pair specifying a backlight device.");
ss = strndupa(argv[2], sysname - argv[2]);
sysname++;
- if (!STR_IN_SET(ss, "backlight", "leds")) {
- log_error("Not a backlight or LED device: '%s:%s'", ss, sysname);
- return -EINVAL;
- }
+ if (!STR_IN_SET(ss, "backlight", "leds"))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Not a backlight or LED device: '%s:%s'", ss, sysname);
r = sd_device_new_from_subsystem_sysname(&device, ss, sysname);
if (r < 0)
@@ -424,10 +416,8 @@ static int run(int argc, char *argv[]) {
if (r < 0)
return log_device_error_errno(device, r, "Failed to write %s: %m", saved);
- } else {
- log_error("Unknown verb %s.", argv[1]);
- return -EINVAL;
- }
+ } else
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown verb %s.", argv[1]);
return 0;
}