summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2023-04-26 11:18:42 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-04-26 11:18:46 +0900
commit5cfe9715f5faf81244f7f7eeae35d68ad2d85816 (patch)
tree3a9a937d55be05012e05703faee8657bbfe5b310 /src/udev
parentfa84c1ce00eb07f69a200322fc513fff226e444b (diff)
downloadsystemd-5cfe9715f5faf81244f7f7eeae35d68ad2d85816.tar.gz
udev/iocost: set default target in parse_config()
And make the failure in parsing config critical.
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/iocost/iocost.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/udev/iocost/iocost.c b/src/udev/iocost/iocost.c
index 54b50b4a8d..2ded9ab9f7 100644
--- a/src/udev/iocost/iocost.c
+++ b/src/udev/iocost/iocost.c
@@ -25,7 +25,9 @@ static int parse_config(void) {
static const ConfigTableItem items[] = {
{ "IOCost", "TargetSolution", config_parse_string, 0, &arg_target_solution },
};
- return config_parse(
+ int r;
+
+ r = config_parse(
NULL,
"/etc/udev/iocost.conf",
NULL,
@@ -35,6 +37,17 @@ static int parse_config(void) {
CONFIG_PARSE_WARN,
NULL,
NULL);
+ if (r < 0)
+ return r;
+
+ if (!arg_target_solution) {
+ arg_target_solution = strdup("naive");
+ if (!arg_target_solution)
+ return log_oom();
+ }
+
+ log_debug("Target solution: %s", arg_target_solution);
+ return 0;
}
static int help(void) {
@@ -318,15 +331,9 @@ static int run(int argc, char *argv[]) {
if (r <= 0)
return r;
- (void) parse_config();
-
- if (!arg_target_solution) {
- arg_target_solution = strdup("naive");
- if (!arg_target_solution)
- return log_oom();
- }
-
- log_debug("Target solution: %s.", arg_target_solution);
+ r = parse_config();
+ if (r < 0)
+ return r;
return iocost_main(argc, argv);
}