fileio: automatically add NULL sentinel to parse_env_file()

Let's modernize things a bit.
This commit is contained in:
Lennart Poettering
2018-11-14 17:01:55 +01:00
parent 608eea8ea0
commit 13df9c398d
25 changed files with 55 additions and 81 deletions
+1 -1
View File
@@ -710,7 +710,7 @@ int parse_env_filev(
return n_pushed;
}
int parse_env_file(
int parse_env_file_sentinel(
FILE *f,
const char *fname,
...) {
+2 -1
View File
@@ -43,7 +43,8 @@ int read_full_stream(FILE *f, char **contents, size_t *size);
int verify_file(const char *fn, const char *blob, bool accept_extra_nl);
int parse_env_filev(FILE *f, const char *fname, va_list ap);
int parse_env_file(FILE *f, const char *fname, ...) _sentinel_;
int parse_env_file_sentinel(FILE *f, const char *fname, ...) _sentinel_;
#define parse_env_file(f, fname, ...) parse_env_file_sentinel(f, fname, __VA_ARGS__, NULL)
int load_env_file(FILE *f, const char *fname, char ***l);
int load_env_file_pairs(FILE *f, const char *fname, char ***l);
+3 -1
View File
@@ -248,7 +248,9 @@ int container_get_leader(const char *machine, pid_t *pid) {
return -EINVAL;
p = strjoina("/run/systemd/machines/", machine);
r = parse_env_file(NULL, p, "LEADER", &s, "CLASS", &class, NULL);
r = parse_env_file(NULL, p,
"LEADER", &s,
"CLASS", &class);
if (r == -ENOENT)
return -EHOSTDOWN;
if (r < 0)