diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-08-24 21:53:10 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-08-24 23:18:30 +0200 |
commit | f4810fe2371ec3d230a788de233d85ca3a312782 (patch) | |
tree | 2814f619f0affed23d4086bb2d485b8cdfd0661e /src | |
parent | parse-util: drop unused parse_ip_prefix_length() (diff) | |
download | systemd-f4810fe2371ec3d230a788de233d85ca3a312782.tar.xz systemd-f4810fe2371ec3d230a788de233d85ca3a312782.zip |
conf-parser: return 1 on success
Typically, conf parsers will ignore most errors during parsing strings
and return 0. Let's return 1 on success. Otherwise it is hard to reused
these function in another conf parser.
Diffstat (limited to '')
-rw-r--r-- | src/shared/conf-parser.c | 6 | ||||
-rw-r--r-- | src/shared/conf-parser.h | 13 |
2 files changed, 10 insertions, 9 deletions
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 5a5a3c7613..d33ee8a9b0 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -1005,7 +1005,7 @@ int config_parse_bool( } *b = k; - return 0; + return 1; /* set */ } int config_parse_id128( @@ -1453,7 +1453,7 @@ int config_parse_ifname( if (isempty(rvalue)) { *s = mfree(*s); - return 0; + return 1; } if (!ifname_valid(rvalue)) { @@ -1465,7 +1465,7 @@ int config_parse_ifname( if (r < 0) return log_oom(); - return 0; + return 1; } int config_parse_ifnames( diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index b73039cc5c..94f81a3bd6 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -320,7 +320,7 @@ typedef enum ConfigParseStringFlags { } \ \ *i = r; \ - return 0; \ + return 1; \ } #define DEFINE_CONFIG_PARSE_PTR(function, parser, type, msg) \ @@ -337,7 +337,7 @@ typedef enum ConfigParseStringFlags { log_syntax(unit, LOG_WARNING, filename, line, r, \ msg ", ignoring: %s", rvalue); \ \ - return 0; \ + return 1; \ } #define DEFINE_CONFIG_PARSE_ENUM_FULL(function, from_string, type, msg) \ @@ -357,7 +357,7 @@ typedef enum ConfigParseStringFlags { } \ \ *i = x; \ - return 0; \ + return 1; \ } #define DEFINE_CONFIG_PARSE_ENUM(function, name, type, msg) \ @@ -374,7 +374,7 @@ typedef enum ConfigParseStringFlags { \ if (isempty(rvalue)) { \ *i = default_value; \ - return 0; \ + return 1; \ } \ \ x = name##_from_string(rvalue); \ @@ -385,7 +385,7 @@ typedef enum ConfigParseStringFlags { } \ \ *i = x; \ - return 0; \ + return 1; \ } #define DEFINE_CONFIG_PARSE_ENUMV(function, name, type, invalid, msg) \ @@ -448,7 +448,8 @@ typedef enum ConfigParseStringFlags { *(xs + i) = invalid; \ } \ \ - return free_and_replace(*enums, xs); \ + free_and_replace(*enums, xs); \ + return 1; \ } int config_parse_unsigned_bounded( |