X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fcore%2Fload-fragment.c;h=72c46371e47eefb0d33165ec8375f983ec97fcd7;hb=e48614c4b268d9e7ecbd478d1d2410f9e92095e0;hp=44920d6449c862d90d7e5e0134032dcb4406fe00;hpb=8a7935a23bfec14beb73e004beb01273254cf789;p=elogind.git diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 44920d644..72c46371e 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -34,8 +34,7 @@ #include #include -#include - +#include "sd-messages.h" #include "unit.h" #include "strv.h" #include "conf-parser.h" @@ -300,10 +299,10 @@ int config_parse_socket_listen(const char *unit, p->fd = -1; if (s->ports) { - LIST_FIND_TAIL(SocketPort, port, s->ports, tail); - LIST_INSERT_AFTER(SocketPort, port, s->ports, tail, p); + LIST_FIND_TAIL(port, s->ports, tail); + LIST_INSERT_AFTER(port, s->ports, tail, p); } else - LIST_PREPEND(SocketPort, port, s->ports, p); + LIST_PREPEND(port, s->ports, p); return 0; } @@ -1033,35 +1032,6 @@ int config_parse_sysv_priority(const char *unit, } #endif -int config_parse_fsck_passno(const char *unit, - const char *filename, - unsigned line, - const char *section, - const char *lvalue, - int ltype, - const char *rvalue, - void *data, - void *userdata) { - - int *passno = data; - int i, r; - - assert(filename); - assert(lvalue); - assert(rvalue); - assert(data); - - r = safe_atoi(rvalue, &i); - if (r || i < 0) { - log_syntax(unit, LOG_ERR, filename, line, -r, - "Failed to parse fsck pass number, ignoring: %s", rvalue); - return 0; - } - - *passno = (int) i; - return 0; -} - DEFINE_CONFIG_PARSE_ENUM(config_parse_kill_mode, kill_mode, KillMode, "Failed to parse kill mode"); int config_parse_kill_signal(const char *unit, @@ -1203,7 +1173,7 @@ int config_parse_timer(const char *unit, v->value = u; v->calendar_spec = c; - LIST_PREPEND(TimerValue, value, t->values, v); + LIST_PREPEND(value, t->values, v); return 0; } @@ -1323,7 +1293,7 @@ int config_parse_path_spec(const char *unit, s->type = b; s->inotify_fd = -1; - LIST_PREPEND(PathSpec, spec, p->specs, s); + LIST_PREPEND(spec, p->specs, s); return 0; } @@ -1657,7 +1627,7 @@ int config_parse_unit_condition_path(const char *unit, if (!c) return log_oom(); - LIST_PREPEND(Condition, conditions, u->conditions, c); + LIST_PREPEND(conditions, u->conditions, c); return 0; } @@ -1712,7 +1682,7 @@ int config_parse_unit_condition_string(const char *unit, if (!c) return log_oom(); - LIST_PREPEND(Condition, conditions, u->conditions, c); + LIST_PREPEND(conditions, u->conditions, c); return 0; } @@ -1766,7 +1736,7 @@ int config_parse_unit_condition_null(const char *unit, if (!c) return log_oom(); - LIST_PREPEND(Condition, conditions, u->conditions, c); + LIST_PREPEND(conditions, u->conditions, c); return 0; } @@ -1860,7 +1830,8 @@ int config_parse_documentation(const char *unit, free(*a); } } - *b = NULL; + if (b) + *b = NULL; return r; } @@ -2127,7 +2098,7 @@ int config_parse_device_allow( a->w = !!strchr(m, 'w'); a->m = !!strchr(m, 'm'); - LIST_PREPEND(CGroupDeviceAllow, device_allow, c->device_allow, a); + LIST_PREPEND(device_allow, c->device_allow, a); return 0; } @@ -2233,7 +2204,7 @@ int config_parse_blockio_device_weight( w->weight = lu; - LIST_PREPEND(CGroupBlockIODeviceWeight, device_weights, c->blockio_device_weights, w); + LIST_PREPEND(device_weights, c->blockio_device_weights, w); return 0; } @@ -2309,7 +2280,7 @@ int config_parse_blockio_bandwidth( b->bandwidth = (uint64_t) bytes; b->read = read; - LIST_PREPEND(CGroupBlockIODeviceBandwidth, device_bandwidths, c->blockio_device_bandwidths, b); + LIST_PREPEND(device_bandwidths, c->blockio_device_bandwidths, b); return 0; } @@ -2432,9 +2403,10 @@ static int merge_by_names(Unit **u, Set *names, const char *id) { static int load_from_path(Unit *u, const char *path) { int r; - Set *symlink_names; - FILE *f = NULL; - char *filename = NULL, *id = NULL; + _cleanup_set_free_free_ Set *symlink_names = NULL; + _cleanup_fclose_ FILE *f = NULL; + _cleanup_free_ char *filename = NULL; + char *id = NULL; Unit *merged; struct stat st; @@ -2448,10 +2420,8 @@ static int load_from_path(Unit *u, const char *path) { if (path_is_absolute(path)) { filename = strdup(path); - if (!filename) { - r = -ENOMEM; - goto finish; - } + if (!filename) + return -ENOMEM; r = open_follow(&filename, &f, symlink_names, &id); if (r < 0) { @@ -2459,7 +2429,7 @@ static int load_from_path(Unit *u, const char *path) { filename = NULL; if (r != -ENOENT) - goto finish; + return r; } } else { @@ -2471,10 +2441,8 @@ static int load_from_path(Unit *u, const char *path) { * follow all symlinks and add their name to our unit * name set while doing so */ filename = path_make_absolute(path, *p); - if (!filename) { - r = -ENOMEM; - goto finish; - } + if (!filename) + return -ENOMEM; if (u->manager->unit_path_cache && !set_get(u->manager->unit_path_cache, filename)) @@ -2487,7 +2455,7 @@ static int load_from_path(Unit *u, const char *path) { filename = NULL; if (r != -ENOENT) - goto finish; + return r; /* Empty the symlink names for the next run */ set_clear_free(symlink_names); @@ -2498,27 +2466,22 @@ static int load_from_path(Unit *u, const char *path) { } } - if (!filename) { + if (!filename) /* Hmm, no suitable file found? */ - r = 0; - goto finish; - } + return 0; merged = u; r = merge_by_names(&merged, symlink_names, id); if (r < 0) - goto finish; + return r; if (merged != u) { u->load_state = UNIT_MERGED; - r = 0; - goto finish; + return 0; } - if (fstat(fileno(f), &st) < 0) { - r = -errno; - goto finish; - } + if (fstat(fileno(f), &st) < 0) + return -errno; if (null_or_empty(&st)) u->load_state = UNIT_MASKED; @@ -2530,7 +2493,7 @@ static int load_from_path(Unit *u, const char *path) { config_item_perf_lookup, (void*) load_fragment_gperf_lookup, false, true, u); if (r < 0) - goto finish; + return r; } free(u->fragment_path); @@ -2546,16 +2509,7 @@ static int load_from_path(Unit *u, const char *path) { u->source_mtime = 0; } - r = 0; - -finish: - set_free_free(symlink_names); - free(filename); - - if (f) - fclose(f); - - return r; + return 0; } int unit_load_fragment(Unit *u) { @@ -2707,7 +2661,6 @@ void unit_dump_config_items(FILE *f) { { config_parse_start_limit_action, "ACTION" }, { config_parse_set_status, "STATUS" }, { config_parse_service_sockets, "SOCKETS" }, - { config_parse_fsck_passno, "PASSNO" }, { config_parse_environ, "ENVIRON" }, { config_parse_syscall_filter, "SYSCALL" }, { config_parse_cpu_shares, "SHARES" },