1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-07 05:57:46 +03:00

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.
This commit is contained in:
Yu Watanabe 2024-08-25 04:53:10 +09:00
parent 83c187f585
commit f4810fe237
2 changed files with 10 additions and 9 deletions

View File

@ -1005,7 +1005,7 @@ int config_parse_bool(
} }
*b = k; *b = k;
return 0; return 1; /* set */
} }
int config_parse_id128( int config_parse_id128(
@ -1453,7 +1453,7 @@ int config_parse_ifname(
if (isempty(rvalue)) { if (isempty(rvalue)) {
*s = mfree(*s); *s = mfree(*s);
return 0; return 1;
} }
if (!ifname_valid(rvalue)) { if (!ifname_valid(rvalue)) {
@ -1465,7 +1465,7 @@ int config_parse_ifname(
if (r < 0) if (r < 0)
return log_oom(); return log_oom();
return 0; return 1;
} }
int config_parse_ifnames( int config_parse_ifnames(

View File

@ -320,7 +320,7 @@ typedef enum ConfigParseStringFlags {
} \ } \
\ \
*i = r; \ *i = r; \
return 0; \ return 1; \
} }
#define DEFINE_CONFIG_PARSE_PTR(function, parser, type, msg) \ #define DEFINE_CONFIG_PARSE_PTR(function, parser, type, msg) \
@ -337,7 +337,7 @@ typedef enum ConfigParseStringFlags {
log_syntax(unit, LOG_WARNING, filename, line, r, \ log_syntax(unit, LOG_WARNING, filename, line, r, \
msg ", ignoring: %s", rvalue); \ msg ", ignoring: %s", rvalue); \
\ \
return 0; \ return 1; \
} }
#define DEFINE_CONFIG_PARSE_ENUM_FULL(function, from_string, type, msg) \ #define DEFINE_CONFIG_PARSE_ENUM_FULL(function, from_string, type, msg) \
@ -357,7 +357,7 @@ typedef enum ConfigParseStringFlags {
} \ } \
\ \
*i = x; \ *i = x; \
return 0; \ return 1; \
} }
#define DEFINE_CONFIG_PARSE_ENUM(function, name, type, msg) \ #define DEFINE_CONFIG_PARSE_ENUM(function, name, type, msg) \
@ -374,7 +374,7 @@ typedef enum ConfigParseStringFlags {
\ \
if (isempty(rvalue)) { \ if (isempty(rvalue)) { \
*i = default_value; \ *i = default_value; \
return 0; \ return 1; \
} \ } \
\ \
x = name##_from_string(rvalue); \ x = name##_from_string(rvalue); \
@ -385,7 +385,7 @@ typedef enum ConfigParseStringFlags {
} \ } \
\ \
*i = x; \ *i = x; \
return 0; \ return 1; \
} }
#define DEFINE_CONFIG_PARSE_ENUMV(function, name, type, invalid, msg) \ #define DEFINE_CONFIG_PARSE_ENUMV(function, name, type, invalid, msg) \
@ -448,7 +448,8 @@ typedef enum ConfigParseStringFlags {
*(xs + i) = invalid; \ *(xs + i) = invalid; \
} \ } \
\ \
return free_and_replace(*enums, xs); \ free_and_replace(*enums, xs); \
return 1; \
} }
int config_parse_unsigned_bounded( int config_parse_unsigned_bounded(