mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
tree-wide: use TAKE_PTR() and TAKE_FD() macros
This commit is contained in:
parent
3d282fff06
commit
1cc6c93a95
@ -491,8 +491,7 @@ static int acquire_host_info(sd_bus *bus, struct host_info **hi) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to get host information from systemd: %s", bus_error_message(&error, r));
|
||||
|
||||
*hi = host;
|
||||
host = NULL;
|
||||
*hi = TAKE_PTR(host);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ int bpf_program_new(uint32_t prog_type, BPFProgram **ret) {
|
||||
p->prog_type = prog_type;
|
||||
p->kernel_fd = -1;
|
||||
|
||||
*ret = p;
|
||||
p = NULL;
|
||||
*ret = TAKE_PTR(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1841,8 +1841,7 @@ int btrfs_qgroup_find_parents(int fd, uint64_t qgroupid, uint64_t **ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
*ret = items;
|
||||
items = NULL;
|
||||
*ret = TAKE_PTR(items);
|
||||
|
||||
return (int) n_items;
|
||||
}
|
||||
|
@ -2448,8 +2448,7 @@ int cg_kernel_controllers(Set **ret) {
|
||||
return r;
|
||||
}
|
||||
|
||||
*ret = controllers;
|
||||
controllers = NULL;
|
||||
*ret = TAKE_PTR(controllers);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -111,10 +111,8 @@ int parse_cpu_set_internal(
|
||||
}
|
||||
|
||||
/* On success, sets *cpu_set and returns ncpus for the system. */
|
||||
if (c) {
|
||||
*cpu_set = c;
|
||||
c = NULL;
|
||||
}
|
||||
if (c)
|
||||
*cpu_set = TAKE_PTR(c);
|
||||
|
||||
return (int) ncpus;
|
||||
}
|
||||
|
@ -1606,8 +1606,7 @@ int read_line(FILE *f, size_t limit, char **ret) {
|
||||
if (ret) {
|
||||
buffer[n] = 0;
|
||||
|
||||
*ret = buffer;
|
||||
buffer = NULL;
|
||||
*ret = TAKE_PTR(buffer);
|
||||
}
|
||||
|
||||
return (int) count;
|
||||
|
@ -125,8 +125,7 @@ int unhexmem(const char *p, size_t l, void **mem, size_t *len) {
|
||||
|
||||
*z = 0;
|
||||
|
||||
*mem = r;
|
||||
r = NULL;
|
||||
*mem = TAKE_PTR(r);
|
||||
*len = (l + 1) / 2;
|
||||
|
||||
return 0;
|
||||
@ -482,8 +481,7 @@ int unbase32hexmem(const char *p, size_t l, bool padding, void **mem, size_t *_l
|
||||
|
||||
*z = 0;
|
||||
|
||||
*mem = r;
|
||||
r = NULL;
|
||||
*mem = TAKE_PTR(r);
|
||||
*_len = len;
|
||||
|
||||
return 0;
|
||||
@ -751,8 +749,7 @@ int unbase64mem(const char *p, size_t l, void **ret, size_t *ret_size) {
|
||||
if (ret_size)
|
||||
*ret_size = (size_t) (z - buf);
|
||||
|
||||
*ret = buf;
|
||||
buf = NULL;
|
||||
*ret = TAKE_PTR(buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -216,8 +216,7 @@ int khash_dup(khash *h, khash **ret) {
|
||||
if (copy->fd < 0)
|
||||
return -errno;
|
||||
|
||||
*ret = copy;
|
||||
copy = NULL;
|
||||
*ret = TAKE_PTR(copy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -196,8 +196,7 @@ int get_locales(char ***ret) {
|
||||
|
||||
strv_sort(l);
|
||||
|
||||
*ret = l;
|
||||
l = NULL;
|
||||
*ret = TAKE_PTR(l);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
along with systemd; If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "set.h"
|
||||
|
||||
int set_make(Set **ret, const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS, void *add, ...) {
|
||||
@ -55,8 +56,7 @@ int set_make(Set **ret, const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS, vo
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
*ret = s;
|
||||
s = NULL;
|
||||
*ret = TAKE_PTR(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1017,8 +1017,7 @@ int getpeergroups(int fd, gid_t **ret) {
|
||||
if ((socklen_t) (int) n != n)
|
||||
return -E2BIG;
|
||||
|
||||
*ret = d;
|
||||
d = NULL;
|
||||
*ret = TAKE_PTR(d);
|
||||
|
||||
return (int) n;
|
||||
}
|
||||
|
@ -1283,8 +1283,7 @@ int get_timezones(char ***ret) {
|
||||
} else if (errno != ENOENT)
|
||||
return -errno;
|
||||
|
||||
*ret = zones;
|
||||
zones = NULL;
|
||||
*ret = TAKE_PTR(zones);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -137,8 +137,7 @@ static int acquire_bus(bool set_monitor, sd_bus **ret) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to connect to bus: %m");
|
||||
|
||||
*ret = bus;
|
||||
bus = NULL;
|
||||
*ret = TAKE_PTR(bus);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -311,8 +311,7 @@ static int bpf_firewall_compile_bpf(
|
||||
return r;
|
||||
} while (false);
|
||||
|
||||
*ret = p;
|
||||
p = NULL;
|
||||
*ret = TAKE_PTR(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -290,8 +290,7 @@ static int bus_timer_set_transient_property(
|
||||
return -ENOMEM;
|
||||
|
||||
v->base = b;
|
||||
v->calendar_spec = c;
|
||||
c = NULL;
|
||||
v->calendar_spec = TAKE_PTR(c);
|
||||
|
||||
LIST_PREPEND(value, t->values, v);
|
||||
}
|
||||
@ -377,8 +376,7 @@ static int bus_timer_set_transient_property(
|
||||
return -ENOMEM;
|
||||
|
||||
v->base = TIMER_CALENDAR;
|
||||
v->calendar_spec = c;
|
||||
c = NULL;
|
||||
v->calendar_spec = TAKE_PTR(c);
|
||||
|
||||
LIST_PREPEND(value, t->values, v);
|
||||
}
|
||||
|
@ -914,8 +914,7 @@ int bus_init_api(Manager *m) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set up API bus: %m");
|
||||
|
||||
m->api_bus = bus;
|
||||
bus = NULL;
|
||||
m->api_bus = TAKE_PTR(bus);
|
||||
|
||||
r = manager_enqueue_sync_bus_names(m);
|
||||
if (r < 0)
|
||||
@ -976,8 +975,7 @@ int bus_init_system(Manager *m) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set up system bus: %m");
|
||||
|
||||
m->system_bus = bus;
|
||||
bus = NULL;
|
||||
m->system_bus = TAKE_PTR(bus);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1757,9 +1757,8 @@ static int build_pass_environment(const ExecContext *c, char ***ret) {
|
||||
if (!GREEDY_REALLOC(pass_env, n_bufsize, n_env + 2))
|
||||
return -ENOMEM;
|
||||
|
||||
pass_env[n_env++] = x;
|
||||
pass_env[n_env++] = TAKE_PTR(x);
|
||||
pass_env[n_env] = NULL;
|
||||
x = NULL;
|
||||
}
|
||||
|
||||
*ret = TAKE_PTR(pass_env);
|
||||
|
@ -1439,8 +1439,7 @@ int job_get_before(Job *j, Job*** ret) {
|
||||
|
||||
n = sort_job_list(list, n);
|
||||
|
||||
*ret = list;
|
||||
list = NULL;
|
||||
*ret = TAKE_PTR(list);
|
||||
|
||||
return (int) n;
|
||||
}
|
||||
@ -1489,8 +1488,7 @@ int job_get_after(Job *j, Job*** ret) {
|
||||
|
||||
n = sort_job_list(list, n);
|
||||
|
||||
*ret = list;
|
||||
list = NULL;
|
||||
*ret = TAKE_PTR(list);
|
||||
|
||||
return (int) n;
|
||||
}
|
||||
|
@ -146,10 +146,9 @@ int unit_load_dropin(Unit *u) {
|
||||
if (r <= 0)
|
||||
return 0;
|
||||
|
||||
if (!u->dropin_paths) {
|
||||
u->dropin_paths = l;
|
||||
l = NULL;
|
||||
} else {
|
||||
if (!u->dropin_paths)
|
||||
u->dropin_paths = TAKE_PTR(l);
|
||||
else {
|
||||
r = strv_extend_strv(&u->dropin_paths, l, true);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
@ -731,9 +731,9 @@ int config_parse_exec(
|
||||
|
||||
if (!GREEDY_REALLOC(n, nbufsize, nlen + 2))
|
||||
return log_oom();
|
||||
n[nlen++] = resolved;
|
||||
|
||||
n[nlen++] = TAKE_PTR(resolved);
|
||||
n[nlen] = NULL;
|
||||
resolved = NULL;
|
||||
}
|
||||
|
||||
if (!n || !n[0]) {
|
||||
@ -747,15 +747,13 @@ int config_parse_exec(
|
||||
if (!nce)
|
||||
return log_oom();
|
||||
|
||||
nce->argv = n;
|
||||
nce->path = path;
|
||||
nce->argv = TAKE_PTR(n);
|
||||
nce->path = TAKE_PTR(path);
|
||||
nce->flags = flags;
|
||||
|
||||
exec_command_append_list(e, nce);
|
||||
|
||||
/* Do not _cleanup_free_ these. */
|
||||
n = NULL;
|
||||
path = NULL;
|
||||
nce = NULL;
|
||||
|
||||
rvalue = p;
|
||||
@ -2397,9 +2395,8 @@ int config_parse_pass_environ(
|
||||
if (!GREEDY_REALLOC(n, nbufsize, nlen + 2))
|
||||
return log_oom();
|
||||
|
||||
n[nlen++] = k;
|
||||
n[nlen++] = TAKE_PTR(k);
|
||||
n[nlen] = NULL;
|
||||
k = NULL;
|
||||
}
|
||||
|
||||
if (n) {
|
||||
@ -2474,9 +2471,8 @@ int config_parse_unset_environ(
|
||||
if (!GREEDY_REALLOC(n, nbufsize, nlen + 2))
|
||||
return log_oom();
|
||||
|
||||
n[nlen++] = k;
|
||||
n[nlen++] = TAKE_PTR(k);
|
||||
n[nlen] = NULL;
|
||||
k = NULL;
|
||||
}
|
||||
|
||||
if (n) {
|
||||
@ -4762,9 +4758,7 @@ static int load_from_path(Unit *u, const char *path) {
|
||||
return r;
|
||||
}
|
||||
|
||||
free(u->fragment_path);
|
||||
u->fragment_path = filename;
|
||||
filename = NULL;
|
||||
free_and_replace(u->fragment_path, filename);
|
||||
|
||||
if (u->source_path) {
|
||||
if (stat(u->source_path, &st) >= 0)
|
||||
|
@ -1131,11 +1131,8 @@ static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds, bool switching
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to disable O_CLOEXEC for serialization fds: %m");
|
||||
|
||||
*_f = f;
|
||||
*_fds = fds;
|
||||
|
||||
f = NULL;
|
||||
fds = NULL;
|
||||
*_f = TAKE_PTR(f);
|
||||
*_fds = TAKE_PTR(fds);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -800,8 +800,8 @@ int manager_new(UnitFileScope scope, unsigned test_run_flags, Manager **_m) {
|
||||
/* Note that we do not set up the notify fd here. We do that after deserialization,
|
||||
* since they might have gotten serialized across the reexec. */
|
||||
|
||||
*_m = m;
|
||||
m = NULL;
|
||||
*_m = TAKE_PTR(m);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1894,8 +1894,7 @@ int manager_get_dump_string(Manager *m, char **ret) {
|
||||
|
||||
f = safe_fclose(f);
|
||||
|
||||
*ret = dump;
|
||||
dump = NULL;
|
||||
*ret = TAKE_PTR(dump);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1395,14 +1395,13 @@ int bind_mount_add(BindMount **b, unsigned *n, const BindMount *item) {
|
||||
*b = c;
|
||||
|
||||
c[(*n) ++] = (BindMount) {
|
||||
.source = s,
|
||||
.destination = d,
|
||||
.source = TAKE_PTR(s),
|
||||
.destination = TAKE_PTR(d),
|
||||
.read_only = item->read_only,
|
||||
.recursive = item->recursive,
|
||||
.ignore_enoent = item->ignore_enoent,
|
||||
};
|
||||
|
||||
s = d = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1449,11 +1448,10 @@ int temporary_filesystem_add(
|
||||
*t = c;
|
||||
|
||||
c[(*n) ++] = (TemporaryFileSystem) {
|
||||
.path = p,
|
||||
.options = o,
|
||||
.path = TAKE_PTR(p),
|
||||
.options = TAKE_PTR(o),
|
||||
};
|
||||
|
||||
p = o = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1491,8 +1489,7 @@ static int setup_one_tmp_dir(const char *id, const char *prefix, char **path) {
|
||||
return -errno;
|
||||
}
|
||||
|
||||
*path = x;
|
||||
x = NULL;
|
||||
*path = TAKE_PTR(x);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1250,10 +1250,8 @@ static int service_collect_fds(Service *s,
|
||||
continue;
|
||||
|
||||
if (!rfds) {
|
||||
rfds = cfds;
|
||||
rfds = TAKE_PTR(cfds);
|
||||
rn_socket_fds = cn_fds;
|
||||
|
||||
cfds = NULL;
|
||||
} else {
|
||||
int *t;
|
||||
|
||||
@ -1305,14 +1303,11 @@ static int service_collect_fds(Service *s,
|
||||
rfd_names[n_fds] = NULL;
|
||||
}
|
||||
|
||||
*fds = rfds;
|
||||
*fd_names = rfd_names;
|
||||
*fds = TAKE_PTR(rfds);
|
||||
*fd_names = TAKE_PTR(rfd_names);
|
||||
*n_socket_fds = rn_socket_fds;
|
||||
*n_storage_fds = rn_storage_fds;
|
||||
|
||||
rfds = NULL;
|
||||
rfd_names = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -629,8 +629,7 @@ int socket_acquire_peer(Socket *s, int fd, SocketPeer **p) {
|
||||
|
||||
remote->socket = s;
|
||||
|
||||
*p = remote;
|
||||
remote = NULL;
|
||||
*p = TAKE_PTR(remote);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -2365,8 +2364,7 @@ static void socket_enter_running(Socket *s, int cfd) {
|
||||
cfd = -1; /* We passed ownership of the fd to the service now. Forget it here. */
|
||||
s->n_connections++;
|
||||
|
||||
service->peer = p; /* Pass ownership of the peer reference */
|
||||
p = NULL;
|
||||
service->peer = TAKE_PTR(p); /* Pass ownership of the peer reference */
|
||||
|
||||
r = manager_add_job(UNIT(s)->manager, JOB_START, UNIT(service), JOB_REPLACE, &error, NULL);
|
||||
if (r < 0) {
|
||||
|
@ -139,8 +139,8 @@ int unit_new_for_name(Manager *m, size_t size, const char *name, Unit **ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = u;
|
||||
u = NULL;
|
||||
*ret = TAKE_PTR(u);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -266,13 +266,11 @@ int unit_add_name(Unit *u, const char *text) {
|
||||
if (u->type == _UNIT_TYPE_INVALID) {
|
||||
u->type = t;
|
||||
u->id = s;
|
||||
u->instance = i;
|
||||
u->instance = TAKE_PTR(i);
|
||||
|
||||
LIST_PREPEND(units_by_type, u->manager->units_by_type[t], u);
|
||||
|
||||
unit_init(u);
|
||||
|
||||
i = NULL;
|
||||
}
|
||||
|
||||
s = NULL;
|
||||
|
@ -227,8 +227,7 @@ int coredump_vacuum(int exclude_fd, uint64_t keep_free, uint64_t max_use) {
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
c = n;
|
||||
n = NULL;
|
||||
c = TAKE_PTR(n);
|
||||
}
|
||||
|
||||
c->n_files++;
|
||||
|
@ -432,14 +432,11 @@ static int save_external_coredump(
|
||||
if (tmp)
|
||||
unlink_noerrno(tmp);
|
||||
|
||||
*ret_filename = fn_compressed; /* compressed */
|
||||
*ret_node_fd = fd_compressed; /* compressed */
|
||||
*ret_data_fd = fd; /* uncompressed */
|
||||
*ret_filename = TAKE_PTR(fn_compressed); /* compressed */
|
||||
*ret_node_fd = TAKE_FD(fd_compressed); /* compressed */
|
||||
*ret_data_fd = TAKE_FD(fd); /* uncompressed */
|
||||
*ret_size = (uint64_t) st.st_size; /* uncompressed */
|
||||
|
||||
fn_compressed = NULL;
|
||||
fd = fd_compressed = -1;
|
||||
|
||||
return 0;
|
||||
|
||||
fail_compressed:
|
||||
@ -454,14 +451,11 @@ uncompressed:
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
*ret_filename = fn;
|
||||
*ret_data_fd = fd;
|
||||
*ret_filename = TAKE_PTR(fn);
|
||||
*ret_data_fd = TAKE_FD(fd);
|
||||
*ret_node_fd = -1;
|
||||
*ret_size = (uint64_t) st.st_size;
|
||||
|
||||
fn = NULL;
|
||||
fd = -1;
|
||||
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
@ -497,11 +491,9 @@ static int allocate_journal_field(int fd, size_t size, char **ret, size_t *ret_s
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
*ret = field;
|
||||
*ret = TAKE_PTR(field);
|
||||
*ret_size = size + 9;
|
||||
|
||||
field = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -146,8 +146,7 @@ static int acquire_journal(sd_journal **ret, char **matches) {
|
||||
log_debug("Journal filter: %s", filter);
|
||||
}
|
||||
|
||||
*ret = j;
|
||||
j = NULL;
|
||||
*ret = TAKE_PTR(j);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -688,8 +688,7 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to attach bus to event loop: %m");
|
||||
|
||||
*_bus = bus;
|
||||
bus = NULL;
|
||||
*_bus = TAKE_PTR(bus);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -272,8 +272,7 @@ int curl_glue_new(CurlGlue **glue, sd_event *event) {
|
||||
if (curl_multi_setopt(g->curl, CURLMOPT_TIMERFUNCTION, curl_glue_timer_callback) != CURLM_OK)
|
||||
return -EINVAL;
|
||||
|
||||
*glue = g;
|
||||
g = NULL;
|
||||
*glue = TAKE_PTR(g);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -122,8 +122,7 @@ int raw_export_new(
|
||||
return r;
|
||||
}
|
||||
|
||||
*ret = e;
|
||||
e = NULL;
|
||||
*ret = TAKE_PTR(e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -126,8 +126,7 @@ int tar_export_new(
|
||||
return r;
|
||||
}
|
||||
|
||||
*ret = e;
|
||||
e = NULL;
|
||||
*ret = TAKE_PTR(e);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -141,8 +141,7 @@ int raw_import_new(
|
||||
return r;
|
||||
}
|
||||
|
||||
*ret = i;
|
||||
i = NULL;
|
||||
*ret = TAKE_PTR(i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -148,8 +148,7 @@ int tar_import_new(
|
||||
return r;
|
||||
}
|
||||
|
||||
*ret = i;
|
||||
i = NULL;
|
||||
*ret = TAKE_PTR(i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -187,8 +187,7 @@ static int transfer_new(Manager *m, Transfer **ret) {
|
||||
t->manager = m;
|
||||
t->id = id;
|
||||
|
||||
*ret = t;
|
||||
t = NULL;
|
||||
*ret = TAKE_PTR(t);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -639,8 +638,7 @@ static int manager_new(Manager **ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = m;
|
||||
m = NULL;
|
||||
*ret = TAKE_PTR(m);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -258,8 +258,7 @@ int pull_make_auxiliary_job(
|
||||
job->on_finished = on_finished;
|
||||
job->compressed_max = job->uncompressed_max = 1ULL * 1024ULL * 1024ULL;
|
||||
|
||||
*ret = job;
|
||||
job = NULL;
|
||||
*ret = TAKE_PTR(job);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -581,8 +581,7 @@ int pull_job_new(PullJob **ret, const char *url, CurlGlue *glue, void *userdata)
|
||||
if (!j->url)
|
||||
return -ENOMEM;
|
||||
|
||||
*ret = j;
|
||||
j = NULL;
|
||||
*ret = TAKE_PTR(j);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -166,8 +166,7 @@ int raw_pull_new(
|
||||
i->glue->on_finished = pull_job_curl_on_finished;
|
||||
i->glue->userdata = i;
|
||||
|
||||
*ret = i;
|
||||
i = NULL;
|
||||
*ret = TAKE_PTR(i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -159,8 +159,7 @@ int tar_pull_new(
|
||||
i->glue->on_finished = pull_job_curl_on_finished;
|
||||
i->glue->userdata = i;
|
||||
|
||||
*ret = i;
|
||||
i = NULL;
|
||||
*ret = TAKE_PTR(i);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -259,8 +259,8 @@ static int get_writer(RemoteServer *s, const char *host,
|
||||
return r;
|
||||
}
|
||||
|
||||
*writer = w;
|
||||
w = NULL;
|
||||
*writer = TAKE_PTR(w);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -314,10 +314,8 @@ int check_permissions(struct MHD_Connection *connection, int *code, char **hostn
|
||||
|
||||
log_debug("Connection from %s", buf);
|
||||
|
||||
if (hostname) {
|
||||
*hostname = buf;
|
||||
buf = NULL;
|
||||
}
|
||||
if (hostname)
|
||||
*hostname = TAKE_PTR(buf);
|
||||
|
||||
r = verify_cert_authorized(session);
|
||||
if (r < 0) {
|
||||
|
@ -1939,8 +1939,7 @@ int journal_file_enable_post_change_timer(JournalFile *f, sd_event *e, usec_t t)
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
f->post_change_timer = timer;
|
||||
timer = NULL;
|
||||
f->post_change_timer = TAKE_PTR(timer);
|
||||
f->post_change_timer_period = t;
|
||||
|
||||
return r;
|
||||
|
@ -299,7 +299,7 @@ int journal_directory_vacuum(
|
||||
goto finish;
|
||||
}
|
||||
|
||||
list[n_list].filename = p;
|
||||
list[n_list].filename = TAKE_PTR(p);
|
||||
list[n_list].usage = size;
|
||||
list[n_list].seqnum = seqnum;
|
||||
list[n_list].realtime = realtime;
|
||||
@ -307,7 +307,6 @@ int journal_directory_vacuum(
|
||||
list[n_list].have_seqnum = have_seqnum;
|
||||
n_list++;
|
||||
|
||||
p = NULL;
|
||||
sum += size;
|
||||
}
|
||||
|
||||
|
@ -921,10 +921,9 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
if (!v)
|
||||
return log_oom();
|
||||
|
||||
if (!arg_output_fields) {
|
||||
arg_output_fields = v;
|
||||
v = NULL;
|
||||
} else {
|
||||
if (!arg_output_fields)
|
||||
arg_output_fields = TAKE_PTR(v);
|
||||
else {
|
||||
r = strv_extend_strv(&arg_output_fields, v, true);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
@ -1229,8 +1228,7 @@ static int discover_next_boot(sd_journal *j,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = next_boot;
|
||||
next_boot = NULL;
|
||||
*ret = TAKE_PTR(next_boot);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1342,8 +1340,7 @@ static int get_boots(
|
||||
}
|
||||
}
|
||||
LIST_INSERT_AFTER(boot_list, head, tail, current);
|
||||
tail = current;
|
||||
current = NULL;
|
||||
tail = TAKE_PTR(current);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@ -1508,8 +1505,8 @@ static int get_possible_units(
|
||||
}
|
||||
}
|
||||
|
||||
*units = found;
|
||||
found = NULL;
|
||||
*units = TAKE_PTR(found);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -439,14 +439,11 @@ static int client_context_read_extra_fields(
|
||||
free(c->extra_fields_iovec);
|
||||
free(c->extra_fields_data);
|
||||
|
||||
c->extra_fields_iovec = iovec;
|
||||
c->extra_fields_iovec = TAKE_PTR(iovec);
|
||||
c->extra_fields_n_iovec = n_iovec;
|
||||
c->extra_fields_data = data;
|
||||
c->extra_fields_data = TAKE_PTR(data);
|
||||
c->extra_fields_mtime = timespec_load_nsec(&st.st_mtim);
|
||||
|
||||
iovec = NULL;
|
||||
data = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -674,8 +674,7 @@ _public_ int sd_lldp_neighbor_from_raw(sd_lldp_neighbor **ret, const void *raw,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = n;
|
||||
n = NULL;
|
||||
*ret = TAKE_PTR(n);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -82,8 +82,7 @@ _public_ int sd_ndisc_router_from_raw(sd_ndisc_router **ret, const void *raw, si
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = rt;
|
||||
rt = NULL;
|
||||
*ret = TAKE_PTR(rt);
|
||||
|
||||
return r;
|
||||
}
|
||||
@ -765,8 +764,7 @@ _public_ int sd_ndisc_router_dnssl_get_domains(sd_ndisc_router *rt, char ***ret)
|
||||
return 0;
|
||||
}
|
||||
|
||||
*ret = l;
|
||||
l = NULL;
|
||||
*ret = TAKE_PTR(l);
|
||||
|
||||
return k;
|
||||
}
|
||||
|
@ -682,8 +682,7 @@ static int client_message_init(
|
||||
|
||||
*_optlen = optlen;
|
||||
*_optoffset = optoffset;
|
||||
*ret = packet;
|
||||
packet = NULL;
|
||||
*ret = TAKE_PTR(packet);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1288,8 +1287,7 @@ static int client_handle_offer(sd_dhcp_client *client, DHCPMessage *offer, size_
|
||||
}
|
||||
|
||||
sd_dhcp_lease_unref(client->lease);
|
||||
client->lease = lease;
|
||||
lease = NULL;
|
||||
client->lease = TAKE_PTR(lease);
|
||||
|
||||
log_dhcp_client(client, "OFFER");
|
||||
|
||||
@ -1370,8 +1368,7 @@ static int client_handle_ack(sd_dhcp_client *client, DHCPMessage *ack, size_t le
|
||||
client->lease = sd_dhcp_lease_unref(client->lease);
|
||||
}
|
||||
|
||||
client->lease = lease;
|
||||
lease = NULL;
|
||||
client->lease = TAKE_PTR(lease);
|
||||
|
||||
log_dhcp_client(client, "ACK");
|
||||
|
||||
@ -1966,8 +1963,7 @@ int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize) {
|
||||
if (!client->req_opts)
|
||||
return -ENOMEM;
|
||||
|
||||
*ret = client;
|
||||
client = NULL;
|
||||
*ret = TAKE_PTR(client);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1235,8 +1235,7 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
|
||||
return r;
|
||||
}
|
||||
|
||||
*ret = lease;
|
||||
lease = NULL;
|
||||
*ret = TAKE_PTR(lease);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -213,8 +213,7 @@ int sd_dhcp_server_new(sd_dhcp_server **ret, int ifindex) {
|
||||
server->default_lease_time = DIV_ROUND_UP(DHCP_DEFAULT_LEASE_TIME_USEC, USEC_PER_SEC);
|
||||
server->max_lease_time = DIV_ROUND_UP(DHCP_MAX_LEASE_TIME_USEC, USEC_PER_SEC);
|
||||
|
||||
*ret = server;
|
||||
server = NULL;
|
||||
*ret = TAKE_PTR(server);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -446,8 +445,7 @@ static int server_message_init(sd_dhcp_server *server, DHCPPacket **ret,
|
||||
memcpy(&packet->dhcp.chaddr, &req->message->chaddr, ETH_ALEN);
|
||||
|
||||
*_optoffset = optoffset;
|
||||
*ret = packet;
|
||||
packet = NULL;
|
||||
*ret = TAKE_PTR(packet);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1466,8 +1466,7 @@ int sd_dhcp6_client_new(sd_dhcp6_client **ret) {
|
||||
for (t = 0; t < client->req_opts_len; t++)
|
||||
client->req_opts[t] = htobe16(default_req_opts[t]);
|
||||
|
||||
*ret = client;
|
||||
client = NULL;
|
||||
*ret = TAKE_PTR(client);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -153,8 +153,7 @@ int sd_ipv4acd_new(sd_ipv4acd **ret) {
|
||||
acd->ifindex = -1;
|
||||
acd->fd = -1;
|
||||
|
||||
*ret = acd;
|
||||
acd = NULL;
|
||||
*ret = TAKE_PTR(acd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -207,8 +206,7 @@ static int ipv4acd_set_next_wakeup(sd_ipv4acd *acd, usec_t usec, usec_t random_u
|
||||
(void) sd_event_source_set_description(timer, "ipv4acd-timer");
|
||||
|
||||
sd_event_source_unref(acd->timer_event_source);
|
||||
acd->timer_event_source = timer;
|
||||
timer = NULL;
|
||||
acd->timer_event_source = TAKE_PTR(timer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -115,8 +115,7 @@ int sd_ipv4ll_new(sd_ipv4ll **ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = ll;
|
||||
ll = NULL;
|
||||
*ret = TAKE_PTR(ll);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -402,8 +402,7 @@ _public_ int sd_lldp_new(sd_lldp **ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = lldp;
|
||||
lldp = NULL;
|
||||
*ret = TAKE_PTR(lldp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -166,8 +166,7 @@ _public_ int sd_ndisc_new(sd_ndisc **ret) {
|
||||
nd->n_ref = 1;
|
||||
nd->fd = -1;
|
||||
|
||||
*ret = nd;
|
||||
nd = NULL;
|
||||
*ret = TAKE_PTR(nd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -51,8 +51,7 @@ _public_ int sd_radv_new(sd_radv **ret) {
|
||||
|
||||
LIST_HEAD_INIT(ra->prefixes);
|
||||
|
||||
*ret = ra;
|
||||
ra = NULL;
|
||||
*ret = TAKE_PTR(ra);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -670,9 +669,7 @@ _public_ int sd_radv_set_rdnss(sd_radv *ra, uint32_t lifetime,
|
||||
|
||||
memcpy(opt_rdnss + 1, dns, n_dns * sizeof(struct in6_addr));
|
||||
|
||||
free(ra->rdnss);
|
||||
ra->rdnss = opt_rdnss;
|
||||
opt_rdnss = NULL;
|
||||
free_and_replace(ra->rdnss, opt_rdnss);
|
||||
|
||||
ra->n_rdnss = n_dns;
|
||||
|
||||
@ -724,9 +721,7 @@ _public_ int sd_radv_set_dnssl(sd_radv *ra, uint32_t lifetime,
|
||||
len -= r;
|
||||
}
|
||||
|
||||
free(ra->dnssl);
|
||||
ra->dnssl = opt_dnssl;
|
||||
opt_dnssl = NULL;
|
||||
free_and_replace(ra->dnssl, opt_dnssl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -755,8 +750,7 @@ _public_ int sd_radv_prefix_new(sd_radv_prefix **ret) {
|
||||
|
||||
LIST_INIT(prefix, p);
|
||||
|
||||
*ret = p;
|
||||
p = NULL;
|
||||
*ret = TAKE_PTR(p);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -431,14 +431,11 @@ _public_ int sd_bus_list_names(sd_bus *bus, char ***acquired, char ***activatabl
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*activatable = y;
|
||||
y = NULL;
|
||||
*activatable = TAKE_PTR(y);
|
||||
}
|
||||
|
||||
if (acquired) {
|
||||
*acquired = x;
|
||||
x = NULL;
|
||||
}
|
||||
if (acquired)
|
||||
*acquired = TAKE_PTR(x);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -734,10 +731,8 @@ _public_ int sd_bus_get_name_creds(
|
||||
return r;
|
||||
}
|
||||
|
||||
if (creds) {
|
||||
*creds = c;
|
||||
c = NULL;
|
||||
}
|
||||
if (creds)
|
||||
*creds = TAKE_PTR(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -810,8 +805,8 @@ _public_ int sd_bus_get_owner_creds(sd_bus *bus, uint64_t mask, sd_bus_creds **r
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = c;
|
||||
c = NULL;
|
||||
*ret = TAKE_PTR(c);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1344,7 +1344,7 @@ int bus_creds_extend_by_pid(sd_bus_creds *c, uint64_t mask, sd_bus_creds **ret)
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = n;
|
||||
n = NULL;
|
||||
*ret = TAKE_PTR(n);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -903,11 +903,10 @@ int bus_match_parse(
|
||||
}
|
||||
|
||||
components[n_components].type = t;
|
||||
components[n_components].value_str = value;
|
||||
components[n_components].value_str = TAKE_PTR(value);
|
||||
components[n_components].value_u8 = u;
|
||||
n_components++;
|
||||
|
||||
value = NULL;
|
||||
|
||||
if (q[quoted] == 0)
|
||||
break;
|
||||
|
@ -513,8 +513,7 @@ int bus_message_from_header(
|
||||
}
|
||||
|
||||
m->bus = sd_bus_ref(bus);
|
||||
*ret = m;
|
||||
m = NULL;
|
||||
*ret = TAKE_PTR(m);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -5869,8 +5868,7 @@ int bus_message_remarshal(sd_bus *bus, sd_bus_message **m) {
|
||||
return r;
|
||||
|
||||
sd_bus_message_unref(*m);
|
||||
*m = n;
|
||||
n = NULL;
|
||||
*m = TAKE_PTR(n);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -524,8 +524,7 @@ static int synthesize_connected_signal(sd_bus *bus) {
|
||||
|
||||
/* Insert at the very front */
|
||||
memmove(bus->rqueue + 1, bus->rqueue, sizeof(sd_bus_message*) * bus->rqueue_size);
|
||||
bus->rqueue[0] = m;
|
||||
m = NULL;
|
||||
bus->rqueue[0] = TAKE_PTR(m);
|
||||
bus->rqueue_size++;
|
||||
|
||||
return 0;
|
||||
@ -2775,8 +2774,8 @@ static int process_running(sd_bus *bus, bool hint_priority, int64_t priority, sd
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = m;
|
||||
m = NULL;
|
||||
*ret = TAKE_PTR(m);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -2935,10 +2934,8 @@ static int process_closing(sd_bus *bus, sd_bus_message **ret) {
|
||||
bus->exit_triggered = true;
|
||||
(void) bus_exit_now(bus);
|
||||
|
||||
if (ret) {
|
||||
*ret = m;
|
||||
m = NULL;
|
||||
}
|
||||
if (ret)
|
||||
*ret = TAKE_PTR(m);
|
||||
|
||||
r = 1;
|
||||
|
||||
|
@ -71,8 +71,7 @@ _public_ int sd_device_enumerator_new(sd_device_enumerator **ret) {
|
||||
enumerator->n_ref = 1;
|
||||
enumerator->type = _DEVICE_ENUMERATION_TYPE_INVALID;
|
||||
|
||||
*ret = enumerator;
|
||||
enumerator = NULL;
|
||||
*ret = TAKE_PTR(enumerator);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -586,8 +586,7 @@ int device_new_from_strv(sd_device **ret, char **strv) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = device;
|
||||
device = NULL;
|
||||
*ret = TAKE_PTR(device);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -635,8 +634,7 @@ int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = device;
|
||||
device = NULL;
|
||||
*ret = TAKE_PTR(device);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -812,8 +810,7 @@ int device_shallow_clone(sd_device *old_device, sd_device **new_device) {
|
||||
|
||||
ret->devnum = old_device->devnum;
|
||||
|
||||
*new_device = ret;
|
||||
ret = NULL;
|
||||
*new_device = TAKE_PTR(ret);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -835,8 +832,7 @@ int device_clone_with_db(sd_device *old_device, sd_device **new_device) {
|
||||
|
||||
ret->sealed = true;
|
||||
|
||||
*new_device = ret;
|
||||
ret = NULL;
|
||||
*new_device = TAKE_PTR(ret);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -861,8 +857,7 @@ int device_new_from_synthetic_event(sd_device **new_device, const char *syspath,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*new_device = ret;
|
||||
ret = NULL;
|
||||
*new_device = TAKE_PTR(ret);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include "util.h"
|
||||
|
||||
int device_new_aux(sd_device **ret) {
|
||||
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
|
||||
sd_device *device = NULL;
|
||||
|
||||
assert(ret);
|
||||
|
||||
@ -58,7 +58,6 @@ int device_new_aux(sd_device **ret) {
|
||||
device->watch_handle = -1;
|
||||
|
||||
*ret = device;
|
||||
device = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -247,8 +246,7 @@ _public_ int sd_device_new_from_syspath(sd_device **ret, const char *syspath) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = device;
|
||||
device = NULL;
|
||||
*ret = TAKE_PTR(device);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -659,8 +657,7 @@ _public_ int sd_device_new_from_device_id(sd_device **ret, const char *id) {
|
||||
if (ifr.ifr_ifindex != ifindex)
|
||||
return -ENODEV;
|
||||
|
||||
*ret = device;
|
||||
device = NULL;
|
||||
*ret = TAKE_PTR(device);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1833,8 +1830,7 @@ _public_ int sd_device_get_sysattr_value(sd_device *device, const char *sysattr,
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*_value = value;
|
||||
value = NULL;
|
||||
*_value = TAKE_PTR(value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -373,8 +373,7 @@ _public_ int sd_hwdb_new(sd_hwdb **ret) {
|
||||
log_debug("strings %8"PRIu64" bytes", le64toh(hwdb->head->strings_len));
|
||||
log_debug("nodes %8"PRIu64" bytes", le64toh(hwdb->head->nodes_len));
|
||||
|
||||
*ret = hwdb;
|
||||
hwdb = NULL;
|
||||
*ret = TAKE_PTR(hwdb);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -741,15 +741,11 @@ _public_ int sd_seat_get_sessions(const char *seat, char ***sessions, uid_t **ui
|
||||
|
||||
r = strv_length(a);
|
||||
|
||||
if (sessions) {
|
||||
*sessions = a;
|
||||
a = NULL;
|
||||
}
|
||||
if (sessions)
|
||||
*sessions = TAKE_PTR(a);
|
||||
|
||||
if (uids) {
|
||||
*uids = b;
|
||||
b = NULL;
|
||||
}
|
||||
if (uids)
|
||||
*uids = TAKE_PTR(b);
|
||||
|
||||
if (n_uids)
|
||||
*n_uids = n;
|
||||
@ -864,10 +860,8 @@ _public_ int sd_get_uids(uid_t **users) {
|
||||
r++;
|
||||
}
|
||||
|
||||
if (users) {
|
||||
*users = l;
|
||||
l = NULL;
|
||||
}
|
||||
if (users)
|
||||
*users = TAKE_PTR(l);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
@ -58,8 +58,7 @@ static int genl_message_new(sd_netlink *nl, sd_genl_family family, uint16_t nlms
|
||||
genl->cmd = cmd;
|
||||
genl->version = genl_families[family].version;
|
||||
|
||||
*ret = m;
|
||||
m = NULL;
|
||||
*ret = TAKE_PTR(m);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -158,8 +158,7 @@ int local_addresses(sd_netlink *context, int ifindex, int af, struct local_addre
|
||||
|
||||
qsort_safe(list, n_list, sizeof(struct local_address), address_compare);
|
||||
|
||||
*ret = list;
|
||||
list = NULL;
|
||||
*ret = TAKE_PTR(list);
|
||||
|
||||
return (int) n_list;
|
||||
}
|
||||
@ -271,8 +270,7 @@ int local_gateways(sd_netlink *context, int ifindex, int af, struct local_addres
|
||||
if (n_list > 0)
|
||||
qsort(list, n_list, sizeof(struct local_address), address_compare);
|
||||
|
||||
*ret = list;
|
||||
list = NULL;
|
||||
*ret = TAKE_PTR(list);
|
||||
|
||||
return (int) n_list;
|
||||
}
|
||||
|
@ -98,8 +98,7 @@ int message_new(sd_netlink *rtnl, sd_netlink_message **ret, uint16_t type) {
|
||||
m->hdr->nlmsg_len = size;
|
||||
m->hdr->nlmsg_type = type;
|
||||
|
||||
*ret = m;
|
||||
m = NULL;
|
||||
*ret = TAKE_PTR(m);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -433,8 +433,7 @@ int socket_read_message(sd_netlink *rtnl) {
|
||||
/* push the message onto the multi-part message stack */
|
||||
if (first)
|
||||
m->next = first;
|
||||
first = m;
|
||||
m = NULL;
|
||||
first = TAKE_PTR(m);
|
||||
}
|
||||
|
||||
if (len > 0)
|
||||
@ -449,8 +448,7 @@ int socket_read_message(sd_netlink *rtnl) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
rtnl->rqueue[rtnl->rqueue_size++] = first;
|
||||
first = NULL;
|
||||
rtnl->rqueue[rtnl->rqueue_size++] = TAKE_PTR(first);
|
||||
|
||||
if (multi_part && (i < rtnl->rqueue_partial_size)) {
|
||||
/* remove the message form the partial read queue */
|
||||
@ -464,15 +462,14 @@ int socket_read_message(sd_netlink *rtnl) {
|
||||
/* we only got a partial multi-part message, push it on the
|
||||
partial read queue */
|
||||
if (i < rtnl->rqueue_partial_size)
|
||||
rtnl->rqueue_partial[i] = first;
|
||||
rtnl->rqueue_partial[i] = TAKE_PTR(first);
|
||||
else {
|
||||
r = rtnl_rqueue_partial_make_room(rtnl);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
rtnl->rqueue_partial[rtnl->rqueue_partial_size++] = first;
|
||||
rtnl->rqueue_partial[rtnl->rqueue_partial_size++] = TAKE_PTR(first);
|
||||
}
|
||||
first = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -62,8 +62,7 @@ static int sd_netlink_new(sd_netlink **ret) {
|
||||
* responses with notifications from the kernel */
|
||||
rtnl->serial = 1;
|
||||
|
||||
*ret = rtnl;
|
||||
rtnl = NULL;
|
||||
*ret = TAKE_PTR(rtnl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -90,8 +89,7 @@ int sd_netlink_new_from_netlink(sd_netlink **ret, int fd) {
|
||||
|
||||
rtnl->fd = fd;
|
||||
|
||||
*ret = rtnl;
|
||||
rtnl = NULL;
|
||||
*ret = TAKE_PTR(rtnl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -133,8 +131,7 @@ int sd_netlink_open_fd(sd_netlink **ret, int fd) {
|
||||
return r;
|
||||
}
|
||||
|
||||
*ret = rtnl;
|
||||
rtnl = NULL;
|
||||
*ret = TAKE_PTR(rtnl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -425,8 +422,7 @@ static int process_running(sd_netlink *rtnl, sd_netlink_message **ret) {
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
*ret = m;
|
||||
m = NULL;
|
||||
*ret = TAKE_PTR(m);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -669,10 +665,8 @@ int sd_netlink_call(sd_netlink *rtnl,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ret) {
|
||||
*ret = incoming;
|
||||
incoming = NULL;
|
||||
}
|
||||
if (ret)
|
||||
*ret = TAKE_PTR(incoming);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -73,8 +73,7 @@ _public_ struct udev_hwdb *udev_hwdb_new(struct udev *udev) {
|
||||
}
|
||||
|
||||
hwdb->refcount = 1;
|
||||
hwdb->hwdb = hwdb_internal;
|
||||
hwdb_internal = NULL;
|
||||
hwdb->hwdb = TAKE_PTR(hwdb_internal);
|
||||
|
||||
udev_list_init(udev, &hwdb->properties_list, true);
|
||||
|
||||
|
@ -666,8 +666,7 @@ int find_language_fallback(const char *lang, char **language) {
|
||||
|
||||
if (streq(lang, a[0])) {
|
||||
assert(strv_length(a) == 2);
|
||||
*language = a[1];
|
||||
a[1] = NULL;
|
||||
*language = TAKE_PTR(a[1]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -660,8 +660,7 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to attach bus to event loop: %m");
|
||||
|
||||
*_bus = bus;
|
||||
bus = NULL;
|
||||
*_bus = TAKE_PTR(bus);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -419,8 +419,7 @@ int seat_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***
|
||||
}
|
||||
}
|
||||
|
||||
*nodes = l;
|
||||
l = NULL;
|
||||
*nodes = TAKE_PTR(l);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -666,8 +666,7 @@ int session_node_enumerator(sd_bus *bus, const char *path, void *userdata, char
|
||||
}
|
||||
}
|
||||
|
||||
*nodes = l;
|
||||
l = NULL;
|
||||
*nodes = TAKE_PTR(l);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -354,8 +354,7 @@ int user_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***
|
||||
}
|
||||
}
|
||||
|
||||
*nodes = l;
|
||||
l = NULL;
|
||||
*nodes = TAKE_PTR(l);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -100,8 +100,8 @@ int user_new(User **out, Manager *m, uid_t uid, gid_t gid, const char *name) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*out = u;
|
||||
u = NULL;
|
||||
*out = TAKE_PTR(u);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -507,8 +507,7 @@ int image_node_enumerator(sd_bus *bus, const char *path, void *userdata, char **
|
||||
return r;
|
||||
}
|
||||
|
||||
*nodes = l;
|
||||
l = NULL;
|
||||
*nodes = TAKE_PTR(l);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -522,8 +522,7 @@ static int container_bus_new(Machine *m, sd_bus_error *error, sd_bus **ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = bus;
|
||||
bus = NULL;
|
||||
*ret = TAKE_PTR(bus);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -647,8 +646,7 @@ int bus_machine_method_open_shell(sd_bus_message *message, void *userdata, sd_bu
|
||||
} else {
|
||||
if (!path_is_absolute(path))
|
||||
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Specified path '%s' is not absolute", path);
|
||||
args = args_wire;
|
||||
args_wire = NULL;
|
||||
args = TAKE_PTR(args_wire);
|
||||
if (strv_isempty(args)) {
|
||||
args = strv_free(args);
|
||||
|
||||
@ -1506,8 +1504,7 @@ int machine_send_create_reply(Machine *m, sd_bus_error *error) {
|
||||
if (!m->create_message)
|
||||
return 0;
|
||||
|
||||
c = m->create_message;
|
||||
m->create_message = NULL;
|
||||
c = TAKE_PTR(m->create_message);
|
||||
|
||||
if (error)
|
||||
return sd_bus_reply_method_error(c, error);
|
||||
|
@ -124,9 +124,8 @@ static int manager_add_host_machine(Manager *m) {
|
||||
t->leader = 1;
|
||||
t->id = mid;
|
||||
|
||||
t->root_directory = rd;
|
||||
t->unit = unit;
|
||||
rd = unit = NULL;
|
||||
t->root_directory = TAKE_PTR(rd);
|
||||
t->unit = TAKE_PTR(unit);
|
||||
|
||||
dual_timestamp_from_boottime_or_monotonic(&t->timestamp, 0);
|
||||
|
||||
|
@ -626,15 +626,11 @@ int config_parse_wireguard_endpoint(const char *unit,
|
||||
if (!port)
|
||||
return log_oom();
|
||||
|
||||
endpoint->peer = peer;
|
||||
endpoint->host = host;
|
||||
endpoint->port = port;
|
||||
endpoint->peer = TAKE_PTR(peer);
|
||||
endpoint->host = TAKE_PTR(host);
|
||||
endpoint->port = TAKE_PTR(port);
|
||||
endpoint->netdev = netdev_ref(data);
|
||||
LIST_PREPEND(endpoints, w->unresolved_endpoints, endpoint);
|
||||
|
||||
peer = NULL;
|
||||
host = NULL;
|
||||
port = NULL;
|
||||
endpoint = NULL;
|
||||
|
||||
return 0;
|
||||
|
@ -210,8 +210,7 @@ static int acquire_link_info_strv(sd_netlink *rtnl, char **l, LinkInfo **ret) {
|
||||
|
||||
qsort_safe(links, c, sizeof(LinkInfo), link_info_compare);
|
||||
|
||||
*ret = links;
|
||||
links = NULL;
|
||||
*ret = TAKE_PTR(links);
|
||||
|
||||
return (int) c;
|
||||
}
|
||||
@ -251,8 +250,7 @@ static int acquire_link_info_all(sd_netlink *rtnl, LinkInfo **ret) {
|
||||
|
||||
qsort_safe(links, c, sizeof(LinkInfo), link_info_compare);
|
||||
|
||||
*ret = links;
|
||||
links = NULL;
|
||||
*ret = TAKE_PTR(links);
|
||||
|
||||
return (int) c;
|
||||
}
|
||||
|
@ -36,8 +36,7 @@ int address_label_new(AddressLabel **ret) {
|
||||
if (!addrlabel)
|
||||
return -ENOMEM;
|
||||
|
||||
*ret = addrlabel;
|
||||
addrlabel = NULL;
|
||||
*ret = TAKE_PTR(addrlabel);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -75,8 +74,7 @@ static int address_label_new_static(Network *network, const char *filename, unsi
|
||||
|
||||
label = hashmap_get(network->address_labels_by_section, n);
|
||||
if (label) {
|
||||
*ret = label;
|
||||
label = NULL;
|
||||
*ret = TAKE_PTR(label);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -85,8 +83,7 @@ static int address_label_new_static(Network *network, const char *filename, unsi
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
label->section = n;
|
||||
n = NULL;
|
||||
label->section = TAKE_PTR(n);
|
||||
|
||||
r = hashmap_put(network->address_labels_by_section, label->section, label);
|
||||
if (r < 0)
|
||||
@ -96,8 +93,7 @@ static int address_label_new_static(Network *network, const char *filename, unsi
|
||||
LIST_APPEND(labels, network->address_labels, label);
|
||||
network->n_address_labels++;
|
||||
|
||||
*ret = label;
|
||||
label = NULL;
|
||||
*ret = TAKE_PTR(label);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -48,8 +48,7 @@ int address_new(Address **ret) {
|
||||
address->cinfo.ifa_prefered = CACHE_INFO_INFINITY_LIFE_TIME;
|
||||
address->cinfo.ifa_valid = CACHE_INFO_INFINITY_LIFE_TIME;
|
||||
|
||||
*ret = address;
|
||||
address = NULL;
|
||||
*ret = TAKE_PTR(address);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -70,8 +69,7 @@ int address_new_static(Network *network, const char *filename, unsigned section_
|
||||
|
||||
address = hashmap_get(network->addresses_by_section, n);
|
||||
if (address) {
|
||||
*ret = address;
|
||||
address = NULL;
|
||||
*ret = TAKE_PTR(address);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -85,8 +83,7 @@ int address_new_static(Network *network, const char *filename, unsigned section_
|
||||
return r;
|
||||
|
||||
if (filename) {
|
||||
address->section = n;
|
||||
n = NULL;
|
||||
address->section = TAKE_PTR(n);
|
||||
|
||||
r = hashmap_put(network->addresses_by_section, address->section, address);
|
||||
if (r < 0)
|
||||
@ -97,8 +94,7 @@ int address_new_static(Network *network, const char *filename, unsigned section_
|
||||
LIST_APPEND(addresses, network->static_addresses, address);
|
||||
network->n_static_addresses++;
|
||||
|
||||
*ret = address;
|
||||
address = NULL;
|
||||
*ret = TAKE_PTR(address);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -541,8 +537,7 @@ static int address_acquire(Link *link, Address *original, Address **ret) {
|
||||
|
||||
LIST_PREPEND(addresses, link->pool_addresses, na);
|
||||
|
||||
*ret = na;
|
||||
na = NULL;
|
||||
*ret = TAKE_PTR(na);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -48,8 +48,7 @@ int fdb_entry_new_static(
|
||||
if (section) {
|
||||
fdb_entry = hashmap_get(network->fdb_entries_by_section, UINT_TO_PTR(section));
|
||||
if (fdb_entry) {
|
||||
*ret = fdb_entry;
|
||||
fdb_entry = NULL;
|
||||
*ret = TAKE_PTR(fdb_entry);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -85,8 +84,7 @@ int fdb_entry_new_static(
|
||||
}
|
||||
|
||||
/* return allocated FDB structure. */
|
||||
*ret = fdb_entry;
|
||||
fdb_entry = NULL;
|
||||
*ret = TAKE_PTR(fdb_entry);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -501,8 +501,7 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = link;
|
||||
link = NULL;
|
||||
*ret = TAKE_PTR(link);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2973,8 +2972,7 @@ network_file_fail:
|
||||
|
||||
route->lifetime = lifetime;
|
||||
sd_event_source_unref(route->expire);
|
||||
route->expire = expire;
|
||||
expire = NULL;
|
||||
route->expire = TAKE_PTR(expire);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -198,10 +198,9 @@ static int lldp_make_packet(
|
||||
|
||||
assert(p == (uint8_t*) packet + l);
|
||||
|
||||
*ret = packet;
|
||||
*ret = TAKE_PTR(packet);
|
||||
*sz = l;
|
||||
|
||||
packet = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1444,8 +1444,7 @@ int manager_new(Manager **ret, sd_event *event) {
|
||||
|
||||
(void) routing_policy_load_rules(m->state_file, &m->rules_saved);
|
||||
|
||||
*ret = m;
|
||||
m = NULL;
|
||||
*ret = TAKE_PTR(m);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -149,8 +149,7 @@ int prefix_new_static(Network *network, const char *filename,
|
||||
if (section_line) {
|
||||
prefix = hashmap_get(network->prefixes_by_section, n);
|
||||
if (prefix) {
|
||||
*ret = prefix;
|
||||
prefix = NULL;
|
||||
*ret = TAKE_PTR(prefix);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -162,8 +161,7 @@ int prefix_new_static(Network *network, const char *filename,
|
||||
return r;
|
||||
|
||||
if (filename) {
|
||||
prefix->section = n;
|
||||
n = NULL;
|
||||
prefix->section = TAKE_PTR(n);
|
||||
|
||||
r = hashmap_put(network->prefixes_by_section, prefix->section,
|
||||
prefix);
|
||||
@ -175,8 +173,7 @@ int prefix_new_static(Network *network, const char *filename,
|
||||
LIST_APPEND(prefixes, network->static_prefixes, prefix);
|
||||
network->n_static_prefixes++;
|
||||
|
||||
*ret = prefix;
|
||||
prefix = NULL;
|
||||
*ret = TAKE_PTR(prefix);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -76,8 +76,7 @@ int route_new(Route **ret) {
|
||||
route->lifetime = USEC_INFINITY;
|
||||
route->quickack = -1;
|
||||
|
||||
*ret = route;
|
||||
route = NULL;
|
||||
*ret = TAKE_PTR(route);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -98,8 +97,7 @@ int route_new_static(Network *network, const char *filename, unsigned section_li
|
||||
|
||||
route = hashmap_get(network->routes_by_section, n);
|
||||
if (route) {
|
||||
*ret = route;
|
||||
route = NULL;
|
||||
*ret = TAKE_PTR(route);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -115,8 +113,7 @@ int route_new_static(Network *network, const char *filename, unsigned section_li
|
||||
route->protocol = RTPROT_STATIC;
|
||||
|
||||
if (filename) {
|
||||
route->section = n;
|
||||
n = NULL;
|
||||
route->section = TAKE_PTR(n);
|
||||
|
||||
r = hashmap_put(network->routes_by_section, route->section, route);
|
||||
if (r < 0)
|
||||
@ -127,8 +124,7 @@ int route_new_static(Network *network, const char *filename, unsigned section_li
|
||||
LIST_PREPEND(routes, network->static_routes, route);
|
||||
network->n_static_routes++;
|
||||
|
||||
*ret = route;
|
||||
route = NULL;
|
||||
*ret = TAKE_PTR(route);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -689,8 +685,7 @@ int route_configure(
|
||||
}
|
||||
|
||||
sd_event_source_unref(route->expire);
|
||||
route->expire = expire;
|
||||
expire = NULL;
|
||||
route->expire = TAKE_PTR(expire);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -406,8 +406,7 @@ static int routing_policy_rule_new_static(Network *network, const char *filename
|
||||
|
||||
rule = hashmap_get(network->rules_by_section, n);
|
||||
if (rule) {
|
||||
*ret = rule;
|
||||
rule = NULL;
|
||||
*ret = TAKE_PTR(rule);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -427,8 +426,7 @@ static int routing_policy_rule_new_static(Network *network, const char *filename
|
||||
LIST_APPEND(rules, network->rules, rule);
|
||||
network->n_rules++;
|
||||
|
||||
*ret = rule;
|
||||
rule = NULL;
|
||||
*ret = TAKE_PTR(rule);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -303,8 +303,7 @@ int manager_new(Manager **ret, char **interfaces, char **ignore, usec_t timeout)
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
*ret = m;
|
||||
m = NULL;
|
||||
*ret = TAKE_PTR(m);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -239,8 +239,7 @@ int expose_port_watch_rtnl(
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add to even loop: %m");
|
||||
|
||||
*ret = rtnl;
|
||||
rtnl = NULL;
|
||||
*ret = TAKE_PTR(rtnl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -282,10 +282,9 @@ int tmpfs_mount_parse(CustomMount **l, unsigned *n, const char *s) {
|
||||
if (!m)
|
||||
return -ENOMEM;
|
||||
|
||||
m->destination = path;
|
||||
m->options = opts;
|
||||
m->destination = TAKE_PTR(path);
|
||||
m->options = TAKE_PTR(opts);
|
||||
|
||||
path = opts = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -341,14 +340,11 @@ int overlay_mount_parse(CustomMount **l, unsigned *n, const char *s, bool read_o
|
||||
if (!m)
|
||||
return -ENOMEM;
|
||||
|
||||
m->destination = destination;
|
||||
m->source = upper;
|
||||
m->lower = lower;
|
||||
m->destination = TAKE_PTR(destination);
|
||||
m->source = TAKE_PTR(upper);
|
||||
m->lower = TAKE_PTR(lower);
|
||||
m->read_only = read_only;
|
||||
|
||||
upper = destination = NULL;
|
||||
lower = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -867,8 +863,7 @@ static int get_process_controllers(Set **ret) {
|
||||
return r;
|
||||
}
|
||||
|
||||
*ret = controllers;
|
||||
controllers = NULL;
|
||||
*ret = TAKE_PTR(controllers);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -175,8 +175,7 @@ static int shift_acl(acl_t acl, uid_t shift, acl_t *ret) {
|
||||
return -errno;
|
||||
}
|
||||
|
||||
*ret = copy;
|
||||
copy = NULL;
|
||||
*ret = TAKE_PTR(copy);
|
||||
|
||||
return !!*ret;
|
||||
}
|
||||
|
@ -75,8 +75,7 @@ int settings_load(FILE *f, const char *path, Settings **ret) {
|
||||
if (s->userns_chown >= 0 && s->userns_mode == _USER_NAMESPACE_MODE_INVALID)
|
||||
s->userns_mode = USER_NAMESPACE_NO;
|
||||
|
||||
*ret = s;
|
||||
s = NULL;
|
||||
*ret = TAKE_PTR(s);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -243,10 +243,8 @@ int change_uid_gid(const char *user, char **_home) {
|
||||
if (setresuid(uid, uid, uid) < 0)
|
||||
return log_error_errno(errno, "setresuid() failed: %m");
|
||||
|
||||
if (_home) {
|
||||
*_home = home;
|
||||
home = NULL;
|
||||
}
|
||||
if (_home)
|
||||
*_home = TAKE_PTR(home);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -3074,8 +3074,7 @@ static int load_settings(void) {
|
||||
|
||||
f = fopen(j, "re");
|
||||
if (f) {
|
||||
p = j;
|
||||
j = NULL;
|
||||
p = TAKE_PTR(j);
|
||||
|
||||
/* By default, we trust configuration from /etc and /run */
|
||||
if (arg_settings_trusted < 0)
|
||||
@ -3130,8 +3129,7 @@ static int load_settings(void) {
|
||||
arg_start_mode = settings->start_mode;
|
||||
|
||||
strv_free(arg_parameters);
|
||||
arg_parameters = settings->parameters;
|
||||
settings->parameters = NULL;
|
||||
arg_parameters = TAKE_PTR(settings->parameters);
|
||||
}
|
||||
|
||||
if ((arg_settings_mask & SETTING_PIVOT_ROOT) == 0 &&
|
||||
@ -3141,25 +3139,18 @@ static int load_settings(void) {
|
||||
}
|
||||
|
||||
if ((arg_settings_mask & SETTING_WORKING_DIRECTORY) == 0 &&
|
||||
settings->working_directory) {
|
||||
free(arg_chdir);
|
||||
arg_chdir = settings->working_directory;
|
||||
settings->working_directory = NULL;
|
||||
}
|
||||
settings->working_directory)
|
||||
free_and_replace(arg_chdir, settings->working_directory);
|
||||
|
||||
if ((arg_settings_mask & SETTING_ENVIRONMENT) == 0 &&
|
||||
settings->environment) {
|
||||
strv_free(arg_setenv);
|
||||
arg_setenv = settings->environment;
|
||||
settings->environment = NULL;
|
||||
arg_setenv = TAKE_PTR(settings->environment);
|
||||
}
|
||||
|
||||
if ((arg_settings_mask & SETTING_USER) == 0 &&
|
||||
settings->user) {
|
||||
free(arg_user);
|
||||
arg_user = settings->user;
|
||||
settings->user = NULL;
|
||||
}
|
||||
settings->user)
|
||||
free_and_replace(arg_user, settings->user);
|
||||
|
||||
if ((arg_settings_mask & SETTING_CAPABILITY) == 0) {
|
||||
uint64_t plus;
|
||||
@ -3209,10 +3200,8 @@ static int load_settings(void) {
|
||||
log_warning("Ignoring TemporaryFileSystem=, Bind= and BindReadOnly= settings, file %s is not trusted.", p);
|
||||
else {
|
||||
custom_mount_free_all(arg_custom_mounts, arg_n_custom_mounts);
|
||||
arg_custom_mounts = settings->custom_mounts;
|
||||
arg_custom_mounts = TAKE_PTR(settings->custom_mounts);
|
||||
arg_n_custom_mounts = settings->n_custom_mounts;
|
||||
|
||||
settings->custom_mounts = NULL;
|
||||
settings->n_custom_mounts = 0;
|
||||
}
|
||||
}
|
||||
@ -3234,28 +3223,19 @@ static int load_settings(void) {
|
||||
arg_private_network = settings_private_network(settings);
|
||||
|
||||
strv_free(arg_network_interfaces);
|
||||
arg_network_interfaces = settings->network_interfaces;
|
||||
settings->network_interfaces = NULL;
|
||||
arg_network_interfaces = TAKE_PTR(settings->network_interfaces);
|
||||
|
||||
strv_free(arg_network_macvlan);
|
||||
arg_network_macvlan = settings->network_macvlan;
|
||||
settings->network_macvlan = NULL;
|
||||
arg_network_macvlan = TAKE_PTR(settings->network_macvlan);
|
||||
|
||||
strv_free(arg_network_ipvlan);
|
||||
arg_network_ipvlan = settings->network_ipvlan;
|
||||
settings->network_ipvlan = NULL;
|
||||
arg_network_ipvlan = TAKE_PTR(settings->network_ipvlan);
|
||||
|
||||
strv_free(arg_network_veth_extra);
|
||||
arg_network_veth_extra = settings->network_veth_extra;
|
||||
settings->network_veth_extra = NULL;
|
||||
arg_network_veth_extra = TAKE_PTR(settings->network_veth_extra);
|
||||
|
||||
free(arg_network_bridge);
|
||||
arg_network_bridge = settings->network_bridge;
|
||||
settings->network_bridge = NULL;
|
||||
|
||||
free(arg_network_zone);
|
||||
arg_network_zone = settings->network_zone;
|
||||
settings->network_zone = NULL;
|
||||
free_and_replace(arg_network_bridge, settings->network_bridge);
|
||||
free_and_replace(arg_network_zone, settings->network_zone);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3266,8 +3246,7 @@ static int load_settings(void) {
|
||||
log_warning("Ignoring Port= setting, file %s is not trusted.", p);
|
||||
else {
|
||||
expose_port_free_all(arg_expose_ports);
|
||||
arg_expose_ports = settings->expose_ports;
|
||||
settings->expose_ports = NULL;
|
||||
arg_expose_ports = TAKE_PTR(settings->expose_ports);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3295,10 +3274,8 @@ static int load_settings(void) {
|
||||
strv_free(arg_syscall_whitelist);
|
||||
strv_free(arg_syscall_blacklist);
|
||||
|
||||
arg_syscall_whitelist = settings->syscall_whitelist;
|
||||
arg_syscall_blacklist = settings->syscall_blacklist;
|
||||
|
||||
settings->syscall_whitelist = settings->syscall_blacklist = NULL;
|
||||
arg_syscall_whitelist = TAKE_PTR(settings->syscall_whitelist);
|
||||
arg_syscall_blacklist = TAKE_PTR(settings->syscall_blacklist);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3917,9 +3894,7 @@ int main(int argc, char *argv[]) {
|
||||
goto finish;
|
||||
}
|
||||
|
||||
free(arg_directory);
|
||||
arg_directory = np;
|
||||
np = NULL;
|
||||
free_and_replace(arg_directory, np);
|
||||
|
||||
remove_directory = true;
|
||||
|
||||
@ -4009,9 +3984,7 @@ int main(int argc, char *argv[]) {
|
||||
goto finish;
|
||||
}
|
||||
|
||||
free(arg_image);
|
||||
arg_image = np;
|
||||
np = NULL;
|
||||
free_and_replace(arg_image, np);
|
||||
|
||||
remove_image = true;
|
||||
} else {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user