fileio: drop "newline" parameter for env file parsers

Now that we don't (mis-)use the env file parser to parse kernel command
lines there's no need anymore to override the used newline character
set. Let's hence drop the argument and just "\n\r" always. This nicely
simplifies our code.
This commit is contained in:
Lennart Poettering 2018-11-12 14:04:47 +01:00
parent 01771226c2
commit aa8fbc74e3
33 changed files with 81 additions and 95 deletions

View File

@ -242,7 +242,7 @@ static int gather_environment_generate(int fd, void *arg) {
return -errno;
}
r = load_env_file_pairs(f, NULL, NULL, &new);
r = load_env_file_pairs(f, NULL, &new);
if (r < 0)
return r;

View File

@ -368,7 +368,6 @@ int read_full_file(const char *fn, char **contents, size_t *size) {
static int parse_env_file_internal(
FILE *f,
const char *fname,
const char *newline,
int (*push) (const char *filename, unsigned line,
const char *key, char *value, void *userdata, int *n_pushed),
void *userdata,
@ -394,8 +393,6 @@ static int parse_env_file_internal(
COMMENT_ESCAPE
} state = PRE_KEY;
assert(newline);
if (f)
r = read_full_stream(f, &contents, NULL);
else
@ -423,7 +420,7 @@ static int parse_env_file_internal(
break;
case KEY:
if (strchr(newline, c)) {
if (strchr(NEWLINE, c)) {
state = PRE_KEY;
line++;
n_key = 0;
@ -445,7 +442,7 @@ static int parse_env_file_internal(
break;
case PRE_VALUE:
if (strchr(newline, c)) {
if (strchr(NEWLINE, c)) {
state = PRE_KEY;
line++;
key[n_key] = 0;
@ -483,7 +480,7 @@ static int parse_env_file_internal(
break;
case VALUE:
if (strchr(newline, c)) {
if (strchr(NEWLINE, c)) {
state = PRE_KEY;
line++;
@ -528,7 +525,7 @@ static int parse_env_file_internal(
case VALUE_ESCAPE:
state = VALUE;
if (!strchr(newline, c)) {
if (!strchr(NEWLINE, c)) {
/* Escaped newlines we eat up entirely */
if (!GREEDY_REALLOC(value, value_alloc, n_value+2))
return -ENOMEM;
@ -554,7 +551,7 @@ static int parse_env_file_internal(
case SINGLE_QUOTE_VALUE_ESCAPE:
state = SINGLE_QUOTE_VALUE;
if (!strchr(newline, c)) {
if (!strchr(NEWLINE, c)) {
if (!GREEDY_REALLOC(value, value_alloc, n_value+2))
return -ENOMEM;
@ -579,7 +576,7 @@ static int parse_env_file_internal(
case DOUBLE_QUOTE_VALUE_ESCAPE:
state = DOUBLE_QUOTE_VALUE;
if (!strchr(newline, c)) {
if (!strchr(NEWLINE, c)) {
if (!GREEDY_REALLOC(value, value_alloc, n_value+2))
return -ENOMEM;
@ -590,7 +587,7 @@ static int parse_env_file_internal(
case COMMENT:
if (c == '\\')
state = COMMENT_ESCAPE;
else if (strchr(newline, c)) {
else if (strchr(NEWLINE, c)) {
state = PRE_KEY;
line++;
}
@ -699,17 +696,13 @@ static int parse_env_file_push(
int parse_env_filev(
FILE *f,
const char *fname,
const char *newline,
va_list ap) {
int r, n_pushed = 0;
va_list aq;
if (!newline)
newline = NEWLINE;
va_copy(aq, ap);
r = parse_env_file_internal(f, fname, newline, parse_env_file_push, &aq, &n_pushed);
r = parse_env_file_internal(f, fname, parse_env_file_push, &aq, &n_pushed);
va_end(aq);
if (r < 0)
return r;
@ -720,14 +713,13 @@ int parse_env_filev(
int parse_env_file(
FILE *f,
const char *fname,
const char *newline,
...) {
va_list ap;
int r;
va_start(ap, newline);
r = parse_env_filev(f, fname, newline, ap);
va_start(ap, fname);
r = parse_env_filev(f, fname, ap);
va_end(ap);
return r;
@ -763,14 +755,11 @@ static int load_env_file_push(
return 0;
}
int load_env_file(FILE *f, const char *fname, const char *newline, char ***rl) {
int load_env_file(FILE *f, const char *fname, char ***rl) {
char **m = NULL;
int r;
if (!newline)
newline = NEWLINE;
r = parse_env_file_internal(f, fname, newline, load_env_file_push, &m, NULL);
r = parse_env_file_internal(f, fname, load_env_file_push, &m, NULL);
if (r < 0) {
strv_free(m);
return r;
@ -812,14 +801,11 @@ static int load_env_file_push_pairs(
return 0;
}
int load_env_file_pairs(FILE *f, const char *fname, const char *newline, char ***rl) {
int load_env_file_pairs(FILE *f, const char *fname, char ***rl) {
char **m = NULL;
int r;
if (!newline)
newline = NEWLINE;
r = parse_env_file_internal(f, fname, newline, load_env_file_push_pairs, &m, NULL);
r = parse_env_file_internal(f, fname, load_env_file_push_pairs, &m, NULL);
if (r < 0) {
strv_free(m);
return r;
@ -872,7 +858,7 @@ int merge_env_file(
* plus "extended" substitutions, unlike other exported parsing functions.
*/
return parse_env_file_internal(f, fname, NEWLINE, merge_env_file_push, env, NULL);
return parse_env_file_internal(f, fname, merge_env_file_push, env, NULL);
}
static void write_env_var(FILE *f, const char *v) {

View File

@ -42,10 +42,10 @@ 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, const char *separator, va_list ap);
int parse_env_file(FILE *f, const char *fname, const char *separator, ...) _sentinel_;
int load_env_file(FILE *f, const char *fname, const char *separator, char ***l);
int load_env_file_pairs(FILE *f, const char *fname, const char *separator, char ***l);
int parse_env_filev(FILE *f, const char *fname, va_list ap);
int parse_env_file(FILE *f, const char *fname, ...) _sentinel_;
int load_env_file(FILE *f, const char *fname, char ***l);
int load_env_file_pairs(FILE *f, const char *fname, char ***l);
int merge_env_file(char ***env, FILE *f, const char *fname);

View File

@ -98,7 +98,7 @@ int parse_os_release(const char *root, ...) {
return r;
va_start(ap, root);
r = parse_env_filev(f, p, NEWLINE, ap);
r = parse_env_filev(f, p, ap);
va_end(ap);
return r;
@ -113,5 +113,5 @@ int load_os_release_pairs(const char *root, char ***ret) {
if (r < 0)
return r;
return load_env_file_pairs(f, p, NEWLINE, ret);
return load_env_file_pairs(f, p, ret);
}

View File

@ -248,7 +248,7 @@ int container_get_leader(const char *machine, pid_t *pid) {
return -EINVAL;
p = strjoina("/run/systemd/machines/", machine);
r = parse_env_file(NULL, p, NEWLINE, "LEADER", &s, "CLASS", &class, NULL);
r = parse_env_file(NULL, p, "LEADER", &s, "CLASS", &class, NULL);
if (r == -ENOENT)
return -EHOSTDOWN;
if (r < 0)

View File

@ -3961,7 +3961,7 @@ static int exec_context_load_environment(const Unit *unit, const ExecContext *c,
assert(pglob.gl_pathc > 0);
for (n = 0; n < pglob.gl_pathc; n++) {
k = load_env_file(NULL, pglob.gl_pathv[n], NULL, &p);
k = load_env_file(NULL, pglob.gl_pathv[n], &p);
if (k < 0) {
if (ignore)
continue;

View File

@ -40,7 +40,7 @@ int locale_setup(char ***environment) {
/* Hmm, nothing set on the kernel cmd line? Then let's try /etc/locale.conf */
if (r <= 0) {
r = parse_env_file(NULL, "/etc/locale.conf", NEWLINE,
r = parse_env_file(NULL, "/etc/locale.conf",
"LANG", &variables[VARIABLE_LANG],
"LANGUAGE", &variables[VARIABLE_LANGUAGE],
"LC_CTYPE", &variables[VARIABLE_LC_CTYPE],

View File

@ -89,7 +89,7 @@ static int context_read_data(Context *c) {
if (r < 0 && r != -ENOENT)
return r;
r = parse_env_file(NULL, "/etc/machine-info", NEWLINE,
r = parse_env_file(NULL, "/etc/machine-info",
"PRETTY_HOSTNAME", &c->data[PROP_PRETTY_HOSTNAME],
"ICON_NAME", &c->data[PROP_ICON_NAME],
"CHASSIS", &c->data[PROP_CHASSIS],
@ -314,7 +314,7 @@ static int context_write_data_machine_info(Context *c) {
assert(c);
r = load_env_file(NULL, "/etc/machine-info", NULL, &l);
r = load_env_file(NULL, "/etc/machine-info", &l);
if (r < 0 && r != -ENOENT)
return r;

View File

@ -149,7 +149,7 @@ static int load_cursor_state(Uploader *u) {
if (!u->state_file)
return 0;
r = parse_env_file(NULL, u->state_file, NEWLINE,
r = parse_env_file(NULL, u->state_file,
"LAST_CURSOR", &u->last_cursor,
NULL);

View File

@ -651,7 +651,7 @@ static int stdout_stream_load(StdoutStream *stream, const char *fname) {
return log_oom();
}
r = parse_env_file(NULL, stream->state_file, NEWLINE,
r = parse_env_file(NULL, stream->state_file,
"PRIORITY", &priority,
"LEVEL_PREFIX", &level_prefix,
"FORWARD_TO_SYSLOG", &forward_to_syslog,

View File

@ -1888,7 +1888,7 @@ _public_ int sd_journal_open_container(sd_journal **ret, const char *machine, in
assert_return(machine_name_is_valid(machine), -EINVAL);
p = strjoina("/run/systemd/machines/", machine);
r = parse_env_file(NULL, p, NEWLINE, "ROOT", &root, "CLASS", &class, NULL);
r = parse_env_file(NULL, p, "ROOT", &root, "CLASS", &class, NULL);
if (r == -ENOENT)
return -EHOSTDOWN;
if (r < 0)

View File

@ -1016,7 +1016,7 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
if (r < 0)
return r;
r = parse_env_file(NULL, lease_file, NEWLINE,
r = parse_env_file(NULL, lease_file,
"ADDRESS", &address,
"ROUTER", &router,
"NETMASK", &netmask,

View File

@ -268,7 +268,7 @@ _public_ int sd_uid_get_state(uid_t uid, char**state) {
if (r < 0)
return r;
r = parse_env_file(NULL, p, NEWLINE, "STATE", &s, NULL);
r = parse_env_file(NULL, p, "STATE", &s, NULL);
if (r == -ENOENT) {
free(s);
s = strdup("offline");
@ -299,7 +299,7 @@ _public_ int sd_uid_get_display(uid_t uid, char **session) {
if (r < 0)
return r;
r = parse_env_file(NULL, p, NEWLINE, "DISPLAY", &s, NULL);
r = parse_env_file(NULL, p, "DISPLAY", &s, NULL);
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
@ -354,7 +354,7 @@ _public_ int sd_uid_is_on_seat(uid_t uid, int require_active, const char *seat)
variable = require_active ? "ACTIVE_UID" : "UIDS";
r = parse_env_file(NULL, p, NEWLINE, variable, &s, NULL);
r = parse_env_file(NULL, p, variable, &s, NULL);
if (r == -ENOENT)
return 0;
if (r < 0)
@ -383,7 +383,7 @@ static int uid_get_array(uid_t uid, const char *variable, char ***array) {
if (r < 0)
return r;
r = parse_env_file(NULL, p, NEWLINE, variable, &s, NULL);
r = parse_env_file(NULL, p, variable, &s, NULL);
if (r == -ENOENT || (r >= 0 && isempty(s))) {
if (array)
*array = NULL;
@ -461,7 +461,7 @@ _public_ int sd_session_is_active(const char *session) {
if (r < 0)
return r;
r = parse_env_file(NULL, p, NEWLINE, "ACTIVE", &s, NULL);
r = parse_env_file(NULL, p, "ACTIVE", &s, NULL);
if (r == -ENOENT)
return -ENXIO;
if (r < 0)
@ -480,7 +480,7 @@ _public_ int sd_session_is_remote(const char *session) {
if (r < 0)
return r;
r = parse_env_file(NULL, p, NEWLINE, "REMOTE", &s, NULL);
r = parse_env_file(NULL, p, "REMOTE", &s, NULL);
if (r == -ENOENT)
return -ENXIO;
if (r < 0)
@ -501,7 +501,7 @@ _public_ int sd_session_get_state(const char *session, char **state) {
if (r < 0)
return r;
r = parse_env_file(NULL, p, NEWLINE, "STATE", &s, NULL);
r = parse_env_file(NULL, p, "STATE", &s, NULL);
if (r == -ENOENT)
return -ENXIO;
if (r < 0)
@ -524,7 +524,7 @@ _public_ int sd_session_get_uid(const char *session, uid_t *uid) {
if (r < 0)
return r;
r = parse_env_file(NULL, p, NEWLINE, "UID", &s, NULL);
r = parse_env_file(NULL, p, "UID", &s, NULL);
if (r == -ENOENT)
return -ENXIO;
if (r < 0)
@ -546,7 +546,7 @@ static int session_get_string(const char *session, const char *field, char **val
if (r < 0)
return r;
r = parse_env_file(NULL, p, NEWLINE, field, &s, NULL);
r = parse_env_file(NULL, p, field, &s, NULL);
if (r == -ENOENT)
return -ENXIO;
if (r < 0)
@ -638,7 +638,7 @@ _public_ int sd_seat_get_active(const char *seat, char **session, uid_t *uid) {
if (r < 0)
return r;
r = parse_env_file(NULL, p, NEWLINE,
r = parse_env_file(NULL, p,
"ACTIVE", &s,
"ACTIVE_UID", &t,
NULL);
@ -676,7 +676,7 @@ _public_ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **ui
if (r < 0)
return r;
r = parse_env_file(NULL, p, NEWLINE,
r = parse_env_file(NULL, p,
"SESSIONS", &s,
"UIDS", &t,
NULL);
@ -745,7 +745,7 @@ static int seat_get_can(const char *seat, const char *variable) {
if (r < 0)
return r;
r = parse_env_file(NULL, p, NEWLINE,
r = parse_env_file(NULL, p,
variable, &s,
NULL);
if (r == -ENOENT)
@ -901,7 +901,7 @@ _public_ int sd_machine_get_class(const char *machine, char **class) {
return -EINVAL;
p = strjoina("/run/systemd/machines/", machine);
r = parse_env_file(NULL, p, NEWLINE, "CLASS", &c, NULL);
r = parse_env_file(NULL, p, "CLASS", &c, NULL);
if (r == -ENOENT)
return -ENXIO;
if (r < 0)
@ -925,7 +925,7 @@ _public_ int sd_machine_get_ifindices(const char *machine, int **ifindices) {
assert_return(ifindices, -EINVAL);
p = strjoina("/run/systemd/machines/", machine);
r = parse_env_file(NULL, p, NEWLINE, "NETIF", &netif, NULL);
r = parse_env_file(NULL, p, "NETIF", &netif, NULL);
if (r == -ENOENT)
return -ENXIO;
if (r < 0)

View File

@ -24,7 +24,7 @@ _public_ int sd_network_get_operational_state(char **state) {
assert_return(state, -EINVAL);
r = parse_env_file(NULL, "/run/systemd/netif/state", NEWLINE, "OPER_STATE", &s, NULL);
r = parse_env_file(NULL, "/run/systemd/netif/state", "OPER_STATE", &s, NULL);
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
@ -44,7 +44,7 @@ static int network_get_strv(const char *key, char ***ret) {
assert_return(ret, -EINVAL);
r = parse_env_file(NULL, "/run/systemd/netif/state", NEWLINE, key, &s, NULL);
r = parse_env_file(NULL, "/run/systemd/netif/state", key, &s, NULL);
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
@ -92,7 +92,7 @@ static int network_link_get_string(int ifindex, const char *field, char **ret) {
xsprintf(path, "/run/systemd/netif/links/%i", ifindex);
r = parse_env_file(NULL, path, NEWLINE, field, &s, NULL);
r = parse_env_file(NULL, path, field, &s, NULL);
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
@ -115,7 +115,7 @@ static int network_link_get_strv(int ifindex, const char *key, char ***ret) {
assert_return(ret, -EINVAL);
xsprintf(path, "/run/systemd/netif/links/%i", ifindex);
r = parse_env_file(NULL, path, NEWLINE, key, &s, NULL);
r = parse_env_file(NULL, path, key, &s, NULL);
if (r == -ENOENT)
return -ENODATA;
if (r < 0)
@ -216,7 +216,7 @@ static int network_link_get_ifindexes(int ifindex, const char *key, int **ret) {
assert_return(ret, -EINVAL);
xsprintf(path, "/run/systemd/netif/links/%i", ifindex);
r = parse_env_file(NULL, path, NEWLINE, key, &s, NULL);
r = parse_env_file(NULL, path, key, &s, NULL);
if (r == -ENOENT)
return -ENODATA;
if (r < 0)

View File

@ -114,7 +114,7 @@ int locale_read_data(Context *c, sd_bus_message *m) {
c->locale_mtime = t;
context_free_locale(c);
r = parse_env_file(NULL, "/etc/locale.conf", NEWLINE,
r = parse_env_file(NULL, "/etc/locale.conf",
"LANG", &c->locale[VARIABLE_LANG],
"LANGUAGE", &c->locale[VARIABLE_LANGUAGE],
"LC_CTYPE", &c->locale[VARIABLE_LC_CTYPE],
@ -186,7 +186,7 @@ int vconsole_read_data(Context *c, sd_bus_message *m) {
c->vc_mtime = t;
context_free_vconsole(c);
r = parse_env_file(NULL, "/etc/vconsole.conf", NEWLINE,
r = parse_env_file(NULL, "/etc/vconsole.conf",
"KEYMAP", &c->vc_keymap,
"KEYMAP_TOGGLE", &c->vc_keymap_toggle,
NULL);
@ -341,7 +341,7 @@ int vconsole_write_data(Context *c) {
struct stat st;
int r;
r = load_env_file(NULL, "/etc/vconsole.conf", NULL, &l);
r = load_env_file(NULL, "/etc/vconsole.conf", &l);
if (r < 0 && r != -ENOENT)
return r;

View File

@ -193,7 +193,7 @@ int inhibitor_load(Inhibitor *i) {
char *cc;
int r;
r = parse_env_file(NULL, i->state_file, NEWLINE,
r = parse_env_file(NULL, i->state_file,
"WHAT", &what,
"UID", &uid,
"PID", &pid,

View File

@ -406,7 +406,7 @@ int session_load(Session *s) {
assert(s);
r = parse_env_file(NULL, s->state_file, NEWLINE,
r = parse_env_file(NULL, s->state_file,
"REMOTE", &remote,
"SCOPE", &s->scope,
"SCOPE_JOB", &s->scope_job,

View File

@ -312,7 +312,7 @@ int user_load(User *u) {
assert(u);
r = parse_env_file(NULL, u->state_file, NEWLINE,
r = parse_env_file(NULL, u->state_file,
"SERVICE_JOB", &u->service_job,
"STOPPING", &stopping,
"REALTIME", &realtime,

View File

@ -373,7 +373,7 @@ int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, s
pair[0] = -1;
r = load_env_file_pairs(f, "/etc/os-release", NULL, &l);
r = load_env_file_pairs(f, "/etc/os-release", &l);
if (r < 0)
return r;

View File

@ -251,7 +251,7 @@ int machine_load(Machine *m) {
if (!m->state_file)
return 0;
r = parse_env_file(NULL, m->state_file, NEWLINE,
r = parse_env_file(NULL, m->state_file,
"SCOPE", &m->unit,
"SCOPE_JOB", &m->scope_job,
"SERVICE", &m->service,

View File

@ -3210,7 +3210,7 @@ static int link_load(Link *link) {
assert(link);
r = parse_env_file(NULL, link->state_file, NEWLINE,
r = parse_env_file(NULL, link->state_file,
"NETWORK_FILE", &network_file,
"ADDRESSES", &addresses,
"ROUTES", &routes,

View File

@ -244,7 +244,7 @@ static int link_send_lldp(Link *link) {
return r;
(void) gethostname_strict(&hostname);
(void) parse_env_file(NULL, "/etc/machine-info", NEWLINE, "PRETTY_HOSTNAME", &pretty_hostname, NULL);
(void) parse_env_file(NULL, "/etc/machine-info", "PRETTY_HOSTNAME", &pretty_hostname, NULL);
assert_cc(LLDP_TX_INTERVAL_USEC * LLDP_TX_HOLD + 1 <= (UINT16_MAX - 1) * USEC_PER_SEC);
ttl = DIV_ROUND_UP(LLDP_TX_INTERVAL_USEC * LLDP_TX_HOLD + 1, USEC_PER_SEC);

View File

@ -279,7 +279,7 @@ static int inspect_image(int argc, char *argv[], void *userdata) {
if (!f)
return log_error_errno(errno, "Failed to open /etc/os-release buffer: %m");
r = parse_env_file(f, "/etc/os-release", NEWLINE,
r = parse_env_file(f, "/etc/os-release",
"PORTABLE_PRETTY_NAME", &pretty_portable,
"PRETTY_NAME", &pretty_os,
NULL);

View File

@ -1257,7 +1257,7 @@ int link_load_user(Link *l) {
if (l->is_managed)
return 0; /* if the device is managed, then networkd is our configuration source, not the bus API */
r = parse_env_file(NULL, l->state_file, NEWLINE,
r = parse_env_file(NULL, l->state_file,
"LLMNR", &llmnr,
"MDNS", &mdns,
"DNSSEC", &dnssec,

View File

@ -339,7 +339,7 @@ int show_cgroup_get_path_and_warn(
const char *m;
m = strjoina("/run/systemd/machines/", machine);
r = parse_env_file(NULL, m, NEWLINE, "SCOPE", &unit, NULL);
r = parse_env_file(NULL, m, "SCOPE", &unit, NULL);
if (r < 0)
return log_error_errno(r, "Failed to load machine data: %m");

View File

@ -471,7 +471,7 @@ static int condition_test_needs_update(Condition *c) {
uint64_t timestamp;
int r;
r = parse_env_file(NULL, p, NULL, "TIMESTAMP_NSEC", &timestamp_str, NULL);
r = parse_env_file(NULL, p, "TIMESTAMP_NSEC", &timestamp_str, NULL);
if (r < 0) {
log_error_errno(r, "Failed to parse timestamp file '%s', using mtime: %m", p);
return true;

View File

@ -1333,14 +1333,14 @@ int dissected_image_acquire_metadata(DissectedImage *m) {
}
case META_MACHINE_INFO:
r = load_env_file_pairs(f, "machine-info", NULL, &machine_info);
r = load_env_file_pairs(f, "machine-info", &machine_info);
if (r < 0)
log_debug_errno(r, "Failed to read /etc/machine-info: %m");
break;
case META_OS_RELEASE:
r = load_env_file_pairs(f, "os-release", NULL, &os_release);
r = load_env_file_pairs(f, "os-release", &os_release);
if (r < 0)
log_debug_errno(r, "Failed to read OS release file: %m");

View File

@ -1114,7 +1114,7 @@ int image_read_metadata(Image *i) {
if (r < 0 && r != -ENOENT)
log_debug_errno(r, "Failed to chase /etc/machine-info in image %s: %m", i->name);
else if (r >= 0) {
r = load_env_file_pairs(NULL, path, NULL, &machine_info);
r = load_env_file_pairs(NULL, path, &machine_info);
if (r < 0)
log_debug_errno(r, "Failed to parse machine-info data of %s: %m", i->name);
}

View File

@ -47,7 +47,7 @@ static void load_testdata_env(void) {
dirname(s);
envpath = path_join(NULL, s, "systemd-runtest.env");
if (load_env_file_pairs(NULL, envpath, NULL, &pairs) < 0)
if (load_env_file_pairs(NULL, envpath, &pairs) < 0)
return;
STRV_FOREACH_PAIR(k, v, pairs)

View File

@ -29,7 +29,7 @@ int udev_parse_config_full(
_cleanup_free_ char *log_val = NULL, *children_max = NULL, *exec_delay = NULL, *event_timeout = NULL, *resolve_names = NULL;
int r;
r = parse_env_file(NULL, "/etc/udev/udev.conf", NEWLINE,
r = parse_env_file(NULL, "/etc/udev/udev.conf",
"udev_log", &log_val,
"children_max", &children_max,
"exec_delay", &exec_delay,

View File

@ -55,7 +55,7 @@ static void test_parse_env_file(void) {
fflush(f);
fclose(f);
r = load_env_file(NULL, t, NULL, &a);
r = load_env_file(NULL, t, &a);
assert_se(r >= 0);
STRV_FOREACH(i, a)
@ -82,7 +82,7 @@ static void test_parse_env_file(void) {
}
r = parse_env_file(
NULL, t, NULL,
NULL, t,
"one", &one,
"two", &two,
"three", &three,
@ -128,7 +128,7 @@ static void test_parse_env_file(void) {
r = write_env_file(p, a);
assert_se(r >= 0);
r = load_env_file(NULL, p, NULL, &b);
r = load_env_file(NULL, p, &b);
assert_se(r >= 0);
}
@ -157,7 +157,7 @@ static void test_parse_multiline_env_file(void) {
fflush(f);
fclose(f);
r = load_env_file(NULL, t, NULL, &a);
r = load_env_file(NULL, t, &a);
assert_se(r >= 0);
STRV_FOREACH(i, a)
@ -176,7 +176,7 @@ static void test_parse_multiline_env_file(void) {
r = write_env_file(p, a);
assert_se(r >= 0);
r = load_env_file(NULL, p, NULL, &b);
r = load_env_file(NULL, p, &b);
assert_se(r >= 0);
}
@ -467,7 +467,7 @@ static void test_load_env_file_pairs(void) {
f = fdopen(fd, "r");
assert_se(f);
r = load_env_file_pairs(f, fn, NULL, &l);
r = load_env_file_pairs(f, fn, &l);
assert_se(r >= 0);
assert_se(strv_length(l) == 14);

View File

@ -531,7 +531,7 @@ static void test_load_env_file_1(void) {
assert_se(fd >= 0);
assert_se(write(fd, env_file_1, sizeof(env_file_1)) == sizeof(env_file_1));
r = load_env_file(NULL, name, NULL, &data);
r = load_env_file(NULL, name, &data);
assert_se(r == 0);
assert_se(streq(data[0], "a=a"));
assert_se(streq(data[1], "b=bc"));
@ -553,7 +553,7 @@ static void test_load_env_file_2(void) {
assert_se(fd >= 0);
assert_se(write(fd, env_file_2, sizeof(env_file_2)) == sizeof(env_file_2));
r = load_env_file(NULL, name, NULL, &data);
r = load_env_file(NULL, name, &data);
assert_se(r == 0);
assert_se(streq(data[0], "a=a"));
assert_se(data[1] == NULL);
@ -570,7 +570,7 @@ static void test_load_env_file_3(void) {
assert_se(fd >= 0);
assert_se(write(fd, env_file_3, sizeof(env_file_3)) == sizeof(env_file_3));
r = load_env_file(NULL, name, NULL, &data);
r = load_env_file(NULL, name, &data);
assert_se(r == 0);
assert_se(data == NULL);
}
@ -585,7 +585,7 @@ static void test_load_env_file_4(void) {
assert_se(fd >= 0);
assert_se(write(fd, env_file_4, sizeof(env_file_4)) == sizeof(env_file_4));
r = load_env_file(NULL, name, NULL, &data);
r = load_env_file(NULL, name, &data);
assert_se(r == 0);
assert_se(streq(data[0], "HWMON_MODULES=coretemp f71882fg"));
assert_se(streq(data[1], "MODULE_0=coretemp"));
@ -604,7 +604,7 @@ static void test_load_env_file_5(void) {
assert_se(fd >= 0);
assert_se(write(fd, env_file_5, sizeof(env_file_5)) == sizeof(env_file_5));
r = load_env_file(NULL, name, NULL, &data);
r = load_env_file(NULL, name, &data);
assert_se(r == 0);
assert_se(streq(data[0], "a="));
assert_se(streq(data[1], "b="));

View File

@ -418,7 +418,7 @@ int main(int argc, char **argv) {
utf8 = is_locale_utf8();
r = parse_env_file(NULL, "/etc/vconsole.conf", NEWLINE,
r = parse_env_file(NULL, "/etc/vconsole.conf",
"KEYMAP", &vc_keymap,
"KEYMAP_TOGGLE", &vc_keymap_toggle,
"FONT", &vc_font,