fileio: automatically add NULL sentinel to parse_env_file()
Let's modernize things a bit.
This commit is contained in:
+1
-1
@@ -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
@@ -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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user