tree-wide: use ASSERT_PTR more

This commit is contained in:
David Tardon 2022-08-09 14:35:15 +02:00
parent 6d64cb0625
commit 995340074e
220 changed files with 1071 additions and 2323 deletions

View File

@ -53,12 +53,10 @@ static int parse_condition(Unit *u, const char *line) {
_printf_(7, 8)
static int log_helper(void *userdata, int level, int error, const char *file, int line, const char *func, const char *format, ...) {
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
va_list ap;
int r;
assert(u);
/* "upgrade" debug messages */
level = MIN(LOG_INFO, level);

View File

@ -199,9 +199,8 @@ static int assess_bool(
uint64_t *ret_badness,
char **ret_description) {
const bool *b = data;
const bool *b = ASSERT_PTR(data);
assert(b);
assert(ret_badness);
assert(ret_description);
@ -1960,14 +1959,13 @@ static int property_read_restrict_namespaces(
sd_bus_error *error,
void *userdata) {
SecurityInfo *info = userdata;
SecurityInfo *info = ASSERT_PTR(userdata);
int r;
uint64_t namespaces;
assert(bus);
assert(member);
assert(m);
assert(info);
r = sd_bus_message_read(m, "t", &namespaces);
if (r < 0)
@ -1985,14 +1983,13 @@ static int property_read_umask(
sd_bus_error *error,
void *userdata) {
SecurityInfo *info = userdata;
SecurityInfo *info = ASSERT_PTR(userdata);
int r;
uint32_t umask;
assert(bus);
assert(member);
assert(m);
assert(info);
r = sd_bus_message_read(m, "u", &umask);
if (r < 0)
@ -2070,13 +2067,12 @@ static int property_read_syscall_archs(
sd_bus_error *error,
void *userdata) {
SecurityInfo *info = userdata;
SecurityInfo *info = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(member);
assert(m);
assert(info);
r = sd_bus_message_enter_container(m, 'a', "s");
if (r < 0)

View File

@ -17,10 +17,9 @@
#include "unit-serialize.h"
static void log_syntax_callback(const char *unit, int level, void *userdata) {
Set **s = userdata;
Set **s = ASSERT_PTR(userdata);
int r;
assert(userdata);
assert(unit);
if (level > LOG_WARNING)

View File

@ -443,11 +443,9 @@ static int merge_env_file_push(
const char *key, char *value,
void *userdata) {
char ***env = userdata;
char ***env = ASSERT_PTR(userdata);
char *expanded_value;
assert(env);
if (!value) {
log_error("%s:%u: invalid syntax (around \"%s\"), ignoring.", strna(filename), line, key);
return 0;

View File

@ -1882,11 +1882,10 @@ int _set_put_strdupv_full(Set **s, const struct hash_ops *hash_ops, char **l HA
}
int set_put_strsplit(Set *s, const char *v, const char *separators, ExtractFlags flags) {
const char *p = v;
const char *p = ASSERT_PTR(v);
int r;
assert(s);
assert(v);
for (;;) {
char *word;

View File

@ -49,11 +49,10 @@ int flush_fd(int fd) {
}
ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll) {
uint8_t *p = buf;
uint8_t *p = ASSERT_PTR(buf);
ssize_t n = 0;
assert(fd >= 0);
assert(buf);
/* If called with nbytes == 0, let's call read() at least
* once, to validate the operation */
@ -108,10 +107,9 @@ int loop_read_exact(int fd, void *buf, size_t nbytes, bool do_poll) {
}
int loop_write(int fd, const void *buf, size_t nbytes, bool do_poll) {
const uint8_t *p = buf;
const uint8_t *p = ASSERT_PTR(buf);
assert(fd >= 0);
assert(buf);
if (_unlikely_(nbytes > (size_t) SSIZE_MAX))
return -EINVAL;

View File

@ -338,11 +338,9 @@ char **path_strv_resolve_uniq(char **l, const char *root) {
char *path_simplify(char *path) {
bool add_slash = false;
char *f = path;
char *f = ASSERT_PTR(path);
int r;
assert(path);
/* Removes redundant inner and trailing slashes. Also removes unnecessary dots.
* Modifies the passed string in-place.
*

View File

@ -72,12 +72,11 @@ void siphash24_init(struct siphash *state, const uint8_t k[static 16]) {
void siphash24_compress(const void *_in, size_t inlen, struct siphash *state) {
const uint8_t *in = _in;
const uint8_t *in = ASSERT_PTR(_in);
const uint8_t *end = in + inlen;
size_t left = state->inlen & 7;
uint64_t m;
assert(in);
assert(state);
/* Update total length */

View File

@ -513,10 +513,9 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) {
{ "us", 1 },
};
char *p = buf;
char *p = ASSERT_PTR(buf);
bool something = false;
assert(buf);
assert(l > 0);
if (t == USEC_INFINITY) {

View File

@ -82,8 +82,7 @@ DEFINE_STRNCASECMP(char16_t, strncasecmp16, true);
#define DEFINE_STRCPY(type, name) \
type *name(type * restrict dest, const type * restrict src) { \
assert(dest); \
type *ret = dest; \
type *ret = ASSERT_PTR(dest); \
\
if (!src) { \
*dest = '\0'; \

View File

@ -178,11 +178,10 @@ static int parse_xml_node(Context *context, const char *prefix, unsigned n_depth
} state = STATE_NODE;
_cleanup_free_ char *node_path = NULL, *argument_type = NULL, *argument_direction = NULL;
const char *np = prefix;
const char *np = ASSERT_PTR(prefix);
int r;
assert(context);
assert(prefix);
if (n_depth > NODE_DEPTH_MAX)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "<node> depth too high.");

View File

@ -417,11 +417,9 @@ static void print_tree(char **l) {
}
static int on_path(const char *path, void *userdata) {
Set *paths = userdata;
Set *paths = ASSERT_PTR(userdata);
int r;
assert(paths);
r = set_put_strdup(&paths, path);
if (r < 0)
return log_oom();
@ -796,11 +794,10 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Set*, member_set_free);
static int on_interface(const char *interface, uint64_t flags, void *userdata) {
_cleanup_(member_freep) Member *m = NULL;
Set *members = userdata;
Set *members = ASSERT_PTR(userdata);
int r;
assert(interface);
assert(members);
m = new(Member, 1);
if (!m)

View File

@ -2984,12 +2984,11 @@ int unit_watch_all_pids(Unit *u) {
}
static int on_cgroup_empty_event(sd_event_source *s, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Unit *u;
int r;
assert(s);
assert(m);
u = m->cgroup_empty_queue;
if (!u)
@ -3165,12 +3164,11 @@ int unit_check_oom(Unit *u) {
}
static int on_cgroup_oom_event(sd_event_source *s, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Unit *u;
int r;
assert(s);
assert(m);
u = m->cgroup_oom_queue;
if (!u)
@ -3268,11 +3266,10 @@ static int unit_check_cgroup_events(Unit *u) {
}
static int on_cgroup_inotify_event(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(s);
assert(fd >= 0);
assert(m);
for (;;) {
union inotify_event_buffer buffer;

View File

@ -202,11 +202,10 @@ static int vl_method_subscribe_managed_oom_cgroups(
void *userdata) {
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(link);
assert(m);
if (json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
@ -261,12 +260,11 @@ static int vl_method_get_user_record(Varlink *link, JsonVariant *parameters, Var
};
_cleanup_free_ char *found_name = NULL;
uid_t found_uid = UID_INVALID, uid;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *un;
int r;
assert(parameters);
assert(m);
r = json_dispatch(parameters, dispatch_table, NULL, 0, &p);
if (r < 0)
@ -369,12 +367,11 @@ static int vl_method_get_group_record(Varlink *link, JsonVariant *parameters, Va
};
_cleanup_free_ char *found_name = NULL;
uid_t found_gid = GID_INVALID, gid;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *gn;
int r;
assert(parameters);
assert(m);
r = json_dispatch(parameters, dispatch_table, NULL, 0, &p);
if (r < 0)
@ -464,9 +461,8 @@ static int vl_method_get_memberships(Varlink *link, JsonVariant *parameters, Var
}
static void vl_disconnect(VarlinkServer *s, Varlink *link, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(s);
assert(link);
@ -526,11 +522,9 @@ static int manager_varlink_init_system(Manager *m) {
}
static int vl_reply(Varlink *link, JsonVariant *parameters, const char *error_id, VarlinkReplyFlags flags, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(m);
if (error_id)
log_debug("varlink systemd-oomd client error: %s", error_id);

View File

@ -69,11 +69,10 @@ static int property_get_delegate_controllers(
void *userdata,
sd_bus_error *error) {
CGroupContext *c = userdata;
CGroupContext *c = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(c);
if (!c->delegate)
return sd_bus_message_append(reply, "as", 0);
@ -90,13 +89,12 @@ static int property_get_cpuset(
void *userdata,
sd_bus_error *error) {
CPUSet *cpus = userdata;
CPUSet *cpus = ASSERT_PTR(userdata);
_cleanup_free_ uint8_t *array = NULL;
size_t allocated;
assert(bus);
assert(reply);
assert(cpus);
(void) cpu_set_to_dbus(cpus, &array, &allocated);
return sd_bus_message_append_array(reply, 'y', array, allocated);
@ -111,12 +109,11 @@ static int property_get_io_device_weight(
void *userdata,
sd_bus_error *error) {
CGroupContext *c = userdata;
CGroupContext *c = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(c);
r = sd_bus_message_open_container(reply, 'a', "(st)");
if (r < 0)
@ -140,12 +137,11 @@ static int property_get_io_device_limits(
void *userdata,
sd_bus_error *error) {
CGroupContext *c = userdata;
CGroupContext *c = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(c);
r = sd_bus_message_open_container(reply, 'a', "(st)");
if (r < 0)
@ -175,12 +171,11 @@ static int property_get_io_device_latency(
void *userdata,
sd_bus_error *error) {
CGroupContext *c = userdata;
CGroupContext *c = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(c);
r = sd_bus_message_open_container(reply, 'a', "(st)");
if (r < 0)
@ -204,12 +199,11 @@ static int property_get_blockio_device_weight(
void *userdata,
sd_bus_error *error) {
CGroupContext *c = userdata;
CGroupContext *c = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(c);
r = sd_bus_message_open_container(reply, 'a', "(st)");
if (r < 0)
@ -233,12 +227,11 @@ static int property_get_blockio_device_bandwidths(
void *userdata,
sd_bus_error *error) {
CGroupContext *c = userdata;
CGroupContext *c = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(c);
r = sd_bus_message_open_container(reply, 'a', "(st)");
if (r < 0)
@ -272,12 +265,11 @@ static int property_get_device_allow(
void *userdata,
sd_bus_error *error) {
CGroupContext *c = userdata;
CGroupContext *c = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(c);
r = sd_bus_message_open_container(reply, 'a', "(ss)");
if (r < 0)
@ -313,12 +305,10 @@ static int property_get_ip_address_access(
void *userdata,
sd_bus_error *error) {
Set **prefixes = userdata;
Set **prefixes = ASSERT_PTR(userdata);
struct in_addr_prefix *i;
int r;
assert(prefixes);
r = sd_bus_message_open_container(reply, 'a', "(iayu)");
if (r < 0)
return r;
@ -384,11 +374,9 @@ static int property_get_socket_bind(
void *userdata,
sd_bus_error *error) {
CGroupSocketBindItem **items = userdata;
CGroupSocketBindItem **items = ASSERT_PTR(userdata);
int r;
assert(items);
r = sd_bus_message_open_container(reply, 'a', "(iiqq)");
if (r < 0)
return r;
@ -411,12 +399,11 @@ static int property_get_restrict_network_interfaces(
void *userdata,
sd_bus_error *error) {
int r;
CGroupContext *c = userdata;
CGroupContext *c = ASSERT_PTR(userdata);
char *iface;
assert(bus);
assert(reply);
assert(c);
r = sd_bus_message_open_container(reply, 'r', "bas");
if (r < 0)

View File

@ -73,12 +73,11 @@ static int property_get_environment_files(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(c);
r = sd_bus_message_open_container(reply, 'a', "(sb)");
if (r < 0)
@ -104,12 +103,11 @@ static int property_get_oom_score_adjust(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
int r, n;
assert(bus);
assert(reply);
assert(c);
if (c->oom_score_adjust_set)
n = c->oom_score_adjust;
@ -132,13 +130,12 @@ static int property_get_coredump_filter(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
uint64_t n;
int r;
assert(bus);
assert(reply);
assert(c);
if (c->coredump_filter_set)
n = c->coredump_filter;
@ -168,12 +165,11 @@ static int property_get_nice(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
int32_t n;
assert(bus);
assert(reply);
assert(c);
if (c->nice_set)
n = c->nice;
@ -196,12 +192,11 @@ static int property_get_cpu_sched_policy(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
int32_t n;
assert(bus);
assert(reply);
assert(c);
if (c->cpu_sched_set)
n = c->cpu_sched_policy;
@ -223,12 +218,11 @@ static int property_get_cpu_sched_priority(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
int32_t n;
assert(bus);
assert(reply);
assert(c);
if (c->cpu_sched_set)
n = c->cpu_sched_priority;
@ -253,14 +247,13 @@ static int property_get_cpu_affinity(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
_cleanup_(cpu_set_reset) CPUSet s = {};
_cleanup_free_ uint8_t *array = NULL;
size_t allocated;
assert(bus);
assert(reply);
assert(c);
if (c->cpu_affinity_from_numa) {
int r;
@ -284,13 +277,12 @@ static int property_get_numa_mask(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
_cleanup_free_ uint8_t *array = NULL;
size_t allocated;
assert(bus);
assert(reply);
assert(c);
(void) cpu_set_to_dbus(&c->numa_policy.nodes, &array, &allocated);
@ -305,12 +297,11 @@ static int property_get_numa_policy(
sd_bus_message *reply,
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
int32_t policy;
assert(bus);
assert(reply);
assert(c);
policy = numa_policy_get_type(&c->numa_policy);
@ -326,12 +317,11 @@ static int property_get_timer_slack_nsec(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
uint64_t u;
assert(bus);
assert(reply);
assert(c);
if (c->timer_slack_nsec != NSEC_INFINITY)
u = (uint64_t) c->timer_slack_nsec;
@ -350,13 +340,12 @@ static int property_get_syscall_filter(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
_cleanup_strv_free_ char **l = NULL;
int r;
assert(bus);
assert(reply);
assert(c);
r = sd_bus_message_open_container(reply, 'r', "bas");
if (r < 0)
@ -420,13 +409,12 @@ static int property_get_syscall_log(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
_cleanup_strv_free_ char **l = NULL;
int r;
assert(bus);
assert(reply);
assert(c);
r = sd_bus_message_open_container(reply, 'r', "bas");
if (r < 0)
@ -469,13 +457,12 @@ static int property_get_syscall_archs(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
_cleanup_strv_free_ char **l = NULL;
int r;
assert(bus);
assert(reply);
assert(c);
#if HAVE_SECCOMP
void *id;
@ -510,11 +497,10 @@ static int property_get_selinux_context(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(c);
return sd_bus_message_append(reply, "(bs)", c->selinux_context_ignore, c->selinux_context);
}
@ -528,11 +514,10 @@ static int property_get_apparmor_profile(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(c);
return sd_bus_message_append(reply, "(bs)", c->apparmor_profile_ignore, c->apparmor_profile);
}
@ -546,11 +531,10 @@ static int property_get_smack_process_label(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(c);
return sd_bus_message_append(reply, "(bs)", c->smack_process_label_ignore, c->smack_process_label);
}
@ -564,14 +548,13 @@ static int property_get_address_families(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
_cleanup_strv_free_ char **l = NULL;
void *af;
int r;
assert(bus);
assert(reply);
assert(c);
r = sd_bus_message_open_container(reply, 'r', "bas");
if (r < 0)
@ -611,12 +594,11 @@ static int property_get_working_directory(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
const char *wd;
assert(bus);
assert(reply);
assert(c);
if (c->working_directory_home)
wd = "~";
@ -638,11 +620,10 @@ static int property_get_stdio_fdname(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
int fileno;
assert(bus);
assert(c);
assert(property);
assert(reply);
@ -667,10 +648,9 @@ static int property_get_input_data(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
assert(bus);
assert(c);
assert(property);
assert(reply);
@ -686,13 +666,12 @@ static int property_get_restrict_filesystems(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
_cleanup_free_ char **l = NULL;
int r;
assert(bus);
assert(reply);
assert(c);
r = sd_bus_message_open_container(reply, 'r', "bas");
if (r < 0)
@ -726,12 +705,11 @@ static int property_get_bind_paths(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
bool ro;
int r;
assert(bus);
assert(c);
assert(property);
assert(reply);
@ -768,11 +746,10 @@ static int property_get_temporary_filesystems(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(c);
assert(property);
assert(reply);
@ -803,11 +780,10 @@ static int property_get_log_extra_fields(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(c);
assert(property);
assert(reply);
@ -833,12 +809,11 @@ static int property_get_set_credential(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
ExecSetCredential *sc;
int r;
assert(bus);
assert(c);
assert(property);
assert(reply);
@ -880,12 +855,11 @@ static int property_get_load_credential(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
ExecLoadCredential *lc;
int r;
assert(bus);
assert(c);
assert(property);
assert(reply);
@ -915,10 +889,9 @@ static int property_get_root_hash(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
assert(bus);
assert(c);
assert(property);
assert(reply);
@ -934,10 +907,9 @@ static int property_get_root_hash_sig(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
assert(bus);
assert(c);
assert(property);
assert(reply);
@ -953,11 +925,10 @@ static int property_get_root_image_options(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(c);
assert(property);
assert(reply);
@ -985,11 +956,10 @@ static int property_get_mount_images(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(c);
assert(property);
assert(reply);
@ -1038,11 +1008,10 @@ static int property_get_extension_images(
void *userdata,
sd_bus_error *error) {
ExecContext *c = userdata;
ExecContext *c = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(c);
assert(property);
assert(reply);
@ -1090,11 +1059,10 @@ static int bus_property_get_exec_dir(
void *userdata,
sd_bus_error *error) {
ExecDirectory *d = userdata;
ExecDirectory *d = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(d);
assert(property);
assert(reply);
@ -1120,11 +1088,10 @@ static int bus_property_get_exec_dir_symlink(
void *userdata,
sd_bus_error *error) {
ExecDirectory *d = userdata;
ExecDirectory *d = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(d);
assert(property);
assert(reply);

View File

@ -28,11 +28,10 @@ static int property_get_unit(
sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Job *j = userdata;
Job *j = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(j);
p = unit_dbus_path(j->unit);
if (!p)
@ -42,11 +41,10 @@ static int property_get_unit(
}
int bus_job_method_cancel(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Job *j = userdata;
Job *j = ASSERT_PTR(userdata);
int r;
assert(message);
assert(j);
r = mac_selinux_unit_access_check(j->unit, message, "stop", error);
if (r < 0)
@ -142,7 +140,7 @@ const sd_bus_vtable bus_job_vtable[] = {
};
static int bus_job_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Job *j;
int r;
@ -150,7 +148,6 @@ static int bus_job_find(sd_bus *bus, const char *path, const char *interface, vo
assert(path);
assert(interface);
assert(found);
assert(m);
r = manager_get_job_from_dbus_path(m, path, &j);
if (r < 0)
@ -195,11 +192,10 @@ const BusObjectImplementation job_object = {
static int send_new_signal(sd_bus *bus, void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *p = NULL;
Job *j = userdata;
Job *j = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(j);
p = job_dbus_path(j);
if (!p)
@ -223,10 +219,9 @@ static int send_new_signal(sd_bus *bus, void *userdata) {
static int send_changed_signal(sd_bus *bus, void *userdata) {
_cleanup_free_ char *p = NULL;
Job *j = userdata;
Job *j = ASSERT_PTR(userdata);
assert(bus);
assert(j);
p = job_dbus_path(j);
if (!p)
@ -273,11 +268,10 @@ void bus_job_send_pending_change_signal(Job *j, bool including_new) {
static int send_removed_signal(sd_bus *bus, void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *p = NULL;
Job *j = userdata;
Job *j = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(j);
p = job_dbus_path(j);
if (!p)
@ -316,10 +310,9 @@ void bus_job_send_removed_signal(Job *j) {
}
static int bus_job_track_handler(sd_bus_track *t, void *userdata) {
Job *j = userdata;
Job *j = ASSERT_PTR(userdata);
assert(t);
assert(j);
j->bus_track = sd_bus_track_unref(j->bus_track); /* make sure we aren't called again */

View File

@ -16,11 +16,9 @@ static int property_get_restart_kill_signal(
sd_bus_message *reply,
void *userdata,
sd_bus_error *error) {
KillContext *c = userdata;
KillContext *c = ASSERT_PTR(userdata);
int s;
assert(c);
s = restart_kill_signal(c);
return sd_bus_message_append_basic(reply, 'i', &s);
}

View File

@ -98,11 +98,10 @@ static int property_get_tainted(
sd_bus_error *error) {
_cleanup_free_ char *s = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(m);
s = manager_taint_string(m);
if (!s)
@ -190,12 +189,11 @@ static int property_get_progress(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
double d;
assert(bus);
assert(reply);
assert(m);
if (MANAGER_IS_FINISHED(m))
d = 1.0;
@ -215,12 +213,11 @@ static int property_get_environment(
sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(m);
r = manager_get_effective_environment(m, &l);
if (r < 0)
@ -238,9 +235,8 @@ static int property_get_show_status(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(bus);
assert(reply);
@ -256,9 +252,8 @@ static int property_get_runtime_watchdog(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(bus);
assert(reply);
@ -274,9 +269,8 @@ static int property_get_pretimeout_watchdog(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(bus);
assert(reply);
@ -292,9 +286,8 @@ static int property_get_pretimeout_watchdog_governor(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(bus);
assert(reply);
@ -310,9 +303,8 @@ static int property_get_reboot_watchdog(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(bus);
assert(reply);
@ -328,9 +320,8 @@ static int property_get_kexec_watchdog(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(bus);
assert(reply);
@ -387,12 +378,10 @@ static int property_set_pretimeout_watchdog_governor(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
char *governor;
int r;
assert(m);
r = sd_bus_message_read(value, "s", &governor);
if (r < 0)
return r;
@ -423,9 +412,8 @@ static int property_set_kexec_watchdog(
void *userdata,
sd_bus_error *error) {
_unused_ Manager *m = userdata;
_unused_ Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(bus);
assert(value);
@ -441,10 +429,9 @@ static int property_get_oom_score_adjust(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r, n;
assert(m);
assert(bus);
assert(reply);
@ -528,13 +515,12 @@ static int reply_unit_path(Unit *u, sd_bus_message *message, sd_bus_error *error
}
static int method_get_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *name;
Unit *u;
int r;
assert(message);
assert(m);
/* Anyone can call this method */
@ -550,13 +536,12 @@ static int method_get_unit(sd_bus_message *message, void *userdata, sd_bus_error
}
static int method_get_unit_by_pid(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
pid_t pid;
Unit *u;
int r;
assert(message);
assert(m);
assert_cc(sizeof(pid_t) == sizeof(uint32_t));
@ -589,7 +574,7 @@ static int method_get_unit_by_pid(sd_bus_message *message, void *userdata, sd_bu
static int method_get_unit_by_invocation_id(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *path = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
sd_id128_t id;
const void *a;
Unit *u;
@ -597,7 +582,6 @@ static int method_get_unit_by_invocation_id(sd_bus_message *message, void *userd
int r;
assert(message);
assert(m);
/* Anyone can call this method */
@ -667,13 +651,12 @@ static int method_get_unit_by_control_group(sd_bus_message *message, void *userd
}
static int method_load_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *name;
Unit *u;
int r;
assert(message);
assert(m);
/* Anyone can call this method */
@ -783,13 +766,12 @@ static int method_enqueue_unit_job(sd_bus_message *message, void *userdata, sd_b
}
static int method_start_unit_replace(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *old_name;
Unit *u;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &old_name);
if (r < 0)
@ -888,12 +870,11 @@ static int reply_unit_info(sd_bus_message *reply, Unit *u) {
static int method_list_units_by_names(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
_cleanup_strv_free_ char **units = NULL;
assert(message);
assert(m);
r = sd_bus_message_read_strv(message, &units);
if (r < 0)
@ -1044,13 +1025,12 @@ static int transient_aux_units_from_message(
static int method_start_transient_unit(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *name, *smode;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
JobMode mode;
Unit *u;
int r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "start", error);
if (r < 0)
@ -1084,13 +1064,12 @@ static int method_start_transient_unit(sd_bus_message *message, void *userdata,
static int method_get_job(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *path = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
uint32_t id;
Job *j;
int r;
assert(message);
assert(m);
/* Anyone can call this method */
@ -1114,13 +1093,12 @@ static int method_get_job(sd_bus_message *message, void *userdata, sd_bus_error
}
static int method_cancel_job(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
uint32_t id;
Job *j;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "u", &id);
if (r < 0)
@ -1134,11 +1112,10 @@ static int method_cancel_job(sd_bus_message *message, void *userdata, sd_bus_err
}
static int method_clear_jobs(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "reload", error);
if (r < 0)
@ -1156,11 +1133,10 @@ static int method_clear_jobs(sd_bus_message *message, void *userdata, sd_bus_err
}
static int method_reset_failed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "reload", error);
if (r < 0)
@ -1179,13 +1155,12 @@ static int method_reset_failed(sd_bus_message *message, void *userdata, sd_bus_e
static int list_units_filtered(sd_bus_message *message, void *userdata, sd_bus_error *error, char **states, char **patterns) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *k;
Unit *u;
int r;
assert(message);
assert(m);
/* Anyone can call this method */
@ -1260,12 +1235,11 @@ static int method_list_units_by_patterns(sd_bus_message *message, void *userdata
static int method_list_jobs(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Job *j;
int r;
assert(message);
assert(m);
/* Anyone can call this method */
@ -1312,11 +1286,10 @@ static int method_list_jobs(sd_bus_message *message, void *userdata, sd_bus_erro
}
static int method_subscribe(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
/* Anyone can call this method */
@ -1346,11 +1319,10 @@ static int method_subscribe(sd_bus_message *message, void *userdata, sd_bus_erro
}
static int method_unsubscribe(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
/* Anyone can call this method */
@ -1371,11 +1343,10 @@ static int method_unsubscribe(sd_bus_message *message, void *userdata, sd_bus_er
static int dump_impl(sd_bus_message *message, void *userdata, sd_bus_error *error, int (*reply)(sd_bus_message *, char *)) {
_cleanup_free_ char *dump = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
/* Anyone can call this method */
@ -1449,11 +1420,10 @@ int verify_run_space_and_log(const char *message) {
}
static int method_reload(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = verify_run_space("Refusing to reload", error);
if (r < 0)
@ -1485,11 +1455,10 @@ static int method_reload(sd_bus_message *message, void *userdata, sd_bus_error *
}
static int method_reexecute(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = verify_run_space("Refusing to reexecute", error);
if (r < 0)
@ -1513,11 +1482,10 @@ static int method_reexecute(sd_bus_message *message, void *userdata, sd_bus_erro
}
static int method_exit(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "halt", error);
if (r < 0)
@ -1534,11 +1502,10 @@ static int method_exit(sd_bus_message *message, void *userdata, sd_bus_error *er
}
static int method_reboot(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "reboot", error);
if (r < 0)
@ -1554,11 +1521,10 @@ static int method_reboot(sd_bus_message *message, void *userdata, sd_bus_error *
}
static int method_poweroff(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "halt", error);
if (r < 0)
@ -1574,11 +1540,10 @@ static int method_poweroff(sd_bus_message *message, void *userdata, sd_bus_error
}
static int method_halt(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "halt", error);
if (r < 0)
@ -1594,11 +1559,10 @@ static int method_halt(sd_bus_message *message, void *userdata, sd_bus_error *er
}
static int method_kexec(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "reboot", error);
if (r < 0)
@ -1616,13 +1580,12 @@ static int method_kexec(sd_bus_message *message, void *userdata, sd_bus_error *e
static int method_switch_root(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *ri = NULL, *rt = NULL;
const char *root, *init;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
struct statvfs svfs;
uint64_t available;
int r;
assert(message);
assert(m);
if (statvfs("/run/systemd", &svfs) < 0)
return sd_bus_error_set_errnof(error, errno, "Failed to statvfs(/run/systemd): %m");
@ -1710,11 +1673,10 @@ static int method_switch_root(sd_bus_message *message, void *userdata, sd_bus_er
static int method_set_environment(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_strv_free_ char **plus = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "reload", error);
if (r < 0)
@ -1741,11 +1703,10 @@ static int method_set_environment(sd_bus_message *message, void *userdata, sd_bu
static int method_unset_environment(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_strv_free_ char **minus = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "reload", error);
if (r < 0)
@ -1774,11 +1735,10 @@ static int method_unset_environment(sd_bus_message *message, void *userdata, sd_
static int method_unset_and_set_environment(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_strv_free_ char **minus = NULL, **plus = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "reload", error);
if (r < 0)
@ -1813,12 +1773,11 @@ static int method_unset_and_set_environment(sd_bus_message *message, void *userd
}
static int method_set_exit_code(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
uint8_t code;
int r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "exit", error);
if (r < 0)
@ -1837,13 +1796,12 @@ static int method_set_exit_code(sd_bus_message *message, void *userdata, sd_bus_
}
static int method_lookup_dynamic_user_by_name(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *name;
uid_t uid;
int r;
assert(message);
assert(m);
r = sd_bus_message_read_basic(message, 's', &name);
if (r < 0)
@ -1868,12 +1826,11 @@ static int method_lookup_dynamic_user_by_name(sd_bus_message *message, void *use
static int method_lookup_dynamic_user_by_uid(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *name = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
uid_t uid;
int r;
assert(message);
assert(m);
assert_cc(sizeof(uid_t) == sizeof(uint32_t));
r = sd_bus_message_read_basic(message, 'u', &uid);
@ -1899,12 +1856,11 @@ static int method_lookup_dynamic_user_by_uid(sd_bus_message *message, void *user
static int method_get_dynamic_users(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
DynamicUser *d;
int r;
assert(message);
assert(m);
assert_cc(sizeof(uid_t) == sizeof(uint32_t));
@ -1943,11 +1899,10 @@ static int method_get_dynamic_users(sd_bus_message *message, void *userdata, sd_
}
static int method_enqueue_marked_jobs(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "start", error);
if (r < 0)
@ -2013,13 +1968,12 @@ static int method_enqueue_marked_jobs(sd_bus_message *message, void *userdata, s
static int list_unit_files_by_patterns(sd_bus_message *message, void *userdata, sd_bus_error *error, char **states, char **patterns) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
UnitFileList *item;
Hashmap *h;
int r;
assert(message);
assert(m);
/* Anyone can call this method */
@ -2084,13 +2038,12 @@ static int method_list_unit_files_by_patterns(sd_bus_message *message, void *use
}
static int method_get_unit_file_state(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *name;
UnitFileState state;
int r;
assert(message);
assert(m);
/* Anyone can call this method */
@ -2111,11 +2064,10 @@ static int method_get_unit_file_state(sd_bus_message *message, void *userdata, s
static int method_get_default_target(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *default_target = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
/* Anyone can call this method */
@ -2369,14 +2321,13 @@ static int method_preset_unit_files_with_mode(sd_bus_message *message, void *use
_cleanup_strv_free_ char **l = NULL;
UnitFileChange *changes = NULL;
size_t n_changes = 0;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
UnitFilePresetMode preset_mode;
int runtime, force, r;
UnitFileFlags flags;
const char *mode;
assert(message);
assert(m);
r = sd_bus_message_read_strv(message, &l);
if (r < 0)
@ -2476,11 +2427,10 @@ static int method_revert_unit_files(sd_bus_message *message, void *userdata, sd_
_cleanup_strv_free_ char **l = NULL;
UnitFileChange *changes = NULL;
size_t n_changes = 0;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = sd_bus_message_read_strv(message, &l);
if (r < 0)
@ -2502,12 +2452,11 @@ static int method_revert_unit_files(sd_bus_message *message, void *userdata, sd_
static int method_set_default_target(sd_bus_message *message, void *userdata, sd_bus_error *error) {
UnitFileChange *changes = NULL;
size_t n_changes = 0;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *name;
int force, r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "enable", error);
if (r < 0)
@ -2533,14 +2482,13 @@ static int method_set_default_target(sd_bus_message *message, void *userdata, sd
static int method_preset_all_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) {
UnitFileChange *changes = NULL;
size_t n_changes = 0;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
UnitFilePresetMode preset_mode;
const char *mode;
UnitFileFlags flags;
int force, runtime, r;
assert(message);
assert(m);
r = mac_selinux_access_check(message, "enable", error);
if (r < 0)
@ -2575,7 +2523,7 @@ static int method_preset_all_unit_files(sd_bus_message *message, void *userdata,
static int method_add_dependency_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
UnitFileChange *changes = NULL;
size_t n_changes = 0;
int runtime, force, r;
@ -2584,7 +2532,6 @@ static int method_add_dependency_unit_files(sd_bus_message *message, void *userd
UnitFileFlags flags;
assert(message);
assert(m);
r = bus_verify_manage_unit_files_async(m, message, error);
if (r < 0)
@ -2657,13 +2604,12 @@ static int method_get_unit_file_links(sd_bus_message *message, void *userdata, s
}
static int method_get_job_waiting(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
uint32_t id;
Job *j;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "u", &id);
if (r < 0)
@ -2677,13 +2623,12 @@ static int method_get_job_waiting(sd_bus_message *message, void *userdata, sd_bu
}
static int method_abandon_scope(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *name;
Unit *u;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &name);
if (r < 0)
@ -2701,12 +2646,11 @@ static int method_abandon_scope(sd_bus_message *message, void *userdata, sd_bus_
}
static int method_set_show_status(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
ShowStatus mode = _SHOW_STATUS_INVALID;
const char *t;
int r;
assert(m);
assert(message);
r = mac_selinux_access_check(message, "reload", error);
@ -3291,11 +3235,10 @@ const sd_bus_vtable bus_manager_log_control_vtable[] = {
static int send_finished(sd_bus *bus, void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL;
usec_t *times = userdata;
usec_t *times = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(times);
r = sd_bus_message_new_signal(bus,
&message,

View File

@ -21,12 +21,11 @@ static int property_get_paths(
void *userdata,
sd_bus_error *error) {
Path *p = userdata;
Path *p = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(p);
r = sd_bus_message_open_container(reply, 'a', "(ss)");
if (r < 0)

View File

@ -14,11 +14,10 @@
#include "unit.h"
int bus_scope_method_abandon(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Scope *s = userdata;
Scope *s = ASSERT_PTR(userdata);
int r;
assert(message);
assert(s);
r = mac_selinux_unit_access_check(UNIT(s), message, "stop", error);
if (r < 0)

View File

@ -45,13 +45,12 @@ static int property_get_exit_status_set(
void *userdata,
sd_bus_error *error) {
const ExitStatusSet *status_set = userdata;
const ExitStatusSet *status_set = ASSERT_PTR(userdata);
unsigned n;
int r;
assert(bus);
assert(reply);
assert(status_set);
r = sd_bus_message_open_container(reply, 'r', "aiai");
if (r < 0)
@ -100,13 +99,12 @@ static int bus_service_method_mount(sd_bus_message *message, void *userdata, sd_
_cleanup_(mount_options_free_allp) MountOptions *options = NULL;
const char *dest, *src, *propagate_directory;
int read_only, make_file_or_directory;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
ExecContext *c;
pid_t unit_pid;
int r;
assert(message);
assert(u);
if (!MANAGER_IS_SYSTEM(u->manager))
return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Adding bind mounts at runtime is only supported for system managers.");

View File

@ -19,12 +19,11 @@ static int property_get_monotonic_timers(
void *userdata,
sd_bus_error *error) {
Timer *t = userdata;
Timer *t = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(t);
r = sd_bus_message_open_container(reply, 'a', "(stt)");
if (r < 0)
@ -67,12 +66,11 @@ static int property_get_calendar_timers(
void *userdata,
sd_bus_error *error) {
Timer *t = userdata;
Timer *t = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(t);
r = sd_bus_message_open_container(reply, 'a', "(sst)");
if (r < 0)
@ -105,11 +103,10 @@ static int property_get_next_elapse_monotonic(
void *userdata,
sd_bus_error *error) {
Timer *t = userdata;
Timer *t = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(t);
return sd_bus_message_append(reply, "t",
(uint64_t) usec_shift_clock(t->next_elapse_monotonic_or_boottime,

View File

@ -102,13 +102,12 @@ static int property_get_names(
void *userdata,
sd_bus_error *error) {
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
const char *t;
int r;
assert(bus);
assert(reply);
assert(u);
r = sd_bus_message_open_container(reply, 'a', "s");
if (r < 0)
@ -192,14 +191,13 @@ static int property_get_requires_mounts_for(
void *userdata,
sd_bus_error *error) {
Hashmap **h = userdata;
Hashmap **h = ASSERT_PTR(userdata);
const char *p;
void *v;
int r;
assert(bus);
assert(reply);
assert(h);
r = sd_bus_message_open_container(reply, 'a', "s");
if (r < 0)
@ -223,12 +221,11 @@ static int property_get_unit_file_preset(
void *userdata,
sd_bus_error *error) {
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(u);
r = unit_get_unit_file_preset(u);
@ -247,11 +244,10 @@ static int property_get_job(
sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Job **j = userdata;
Job **j = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(j);
if (!*j)
return sd_bus_message_append(reply, "(uo)", 0, "/");
@ -273,12 +269,11 @@ static int property_get_conditions(
sd_bus_error *error) {
const char *(*to_string)(ConditionType type) = NULL;
Condition **list = userdata;
Condition **list = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(list);
to_string = streq(property, "Asserts") ? assert_type_to_string : condition_type_to_string;
@ -315,12 +310,11 @@ static int property_get_load_error(
sd_bus_error *error) {
_cleanup_(sd_bus_error_free) sd_bus_error e = SD_BUS_ERROR_NULL;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(u);
r = bus_unit_validate_load_state(u, &e);
if (r < 0)
@ -338,12 +332,11 @@ static int property_get_markers(
void *userdata,
sd_bus_error *error) {
unsigned *markers = userdata;
unsigned *markers = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(markers);
r = sd_bus_message_open_container(reply, 'a', "s");
if (r < 0)
@ -466,13 +459,12 @@ static int bus_unit_method_reload_or_try_restart(sd_bus_message *message, void *
int bus_unit_method_enqueue_job(sd_bus_message *message, void *userdata, sd_bus_error *error) {
BusUnitQueueFlags flags = BUS_UNIT_QUEUE_VERBOSE_REPLY;
const char *jtype, *smode;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
JobType type;
JobMode mode;
int r;
assert(message);
assert(u);
r = sd_bus_message_read(message, "ss", &jtype, &smode);
if (r < 0)
@ -520,14 +512,13 @@ int bus_unit_method_enqueue_job(sd_bus_message *message, void *userdata, sd_bus_
}
int bus_unit_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
const char *swho;
int32_t signo;
KillWho who;
int r;
assert(message);
assert(u);
r = mac_selinux_unit_access_check(u, message, "stop", error);
if (r < 0)
@ -569,11 +560,10 @@ int bus_unit_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *
}
int bus_unit_method_reset_failed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(message);
assert(u);
r = mac_selinux_unit_access_check(u, message, "reload", error);
if (r < 0)
@ -598,11 +588,10 @@ int bus_unit_method_reset_failed(sd_bus_message *message, void *userdata, sd_bus
}
int bus_unit_method_set_properties(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int runtime, r;
assert(message);
assert(u);
r = mac_selinux_unit_access_check(u, message, "start", error);
if (r < 0)
@ -633,11 +622,10 @@ int bus_unit_method_set_properties(sd_bus_message *message, void *userdata, sd_b
}
int bus_unit_method_ref(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(message);
assert(u);
r = mac_selinux_unit_access_check(u, message, "start", error);
if (r < 0)
@ -664,11 +652,10 @@ int bus_unit_method_ref(sd_bus_message *message, void *userdata, sd_bus_error *e
}
int bus_unit_method_unref(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(message);
assert(u);
r = bus_unit_track_remove_sender(u, message);
if (r == -EUNATCH)
@ -681,11 +668,10 @@ int bus_unit_method_unref(sd_bus_message *message, void *userdata, sd_bus_error
int bus_unit_method_clean(sd_bus_message *message, void *userdata, sd_bus_error *error) {
ExecCleanMask mask = 0;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(message);
assert(u);
r = mac_selinux_unit_access_check(u, message, "stop", error);
if (r < 0)
@ -750,12 +736,11 @@ int bus_unit_method_clean(sd_bus_message *message, void *userdata, sd_bus_error
static int bus_unit_method_freezer_generic(sd_bus_message *message, void *userdata, sd_bus_error *error, FreezerAction action) {
const char* perm;
int (*method)(Unit*);
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
bool reply_no_delay = false;
int r;
assert(message);
assert(u);
assert(IN_SET(action, FREEZER_FREEZE, FREEZER_THAW));
if (action == FREEZER_FREEZE) {
@ -1055,11 +1040,10 @@ static int property_get_slice(
void *userdata,
sd_bus_error *error) {
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(u);
return sd_bus_message_append(reply, "s", unit_slice_name(u));
}
@ -1074,12 +1058,11 @@ static int property_get_current_memory(
sd_bus_error *error) {
uint64_t sz = UINT64_MAX;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(u);
r = unit_get_memory_current(u, &sz);
if (r < 0 && r != -ENODATA)
@ -1098,12 +1081,11 @@ static int property_get_available_memory(
sd_bus_error *error) {
uint64_t sz = UINT64_MAX;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(u);
r = unit_get_memory_available(u, &sz);
if (r < 0 && r != -ENODATA)
@ -1122,12 +1104,11 @@ static int property_get_current_tasks(
sd_bus_error *error) {
uint64_t cn = UINT64_MAX;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(u);
r = unit_get_tasks_current(u, &cn);
if (r < 0 && r != -ENODATA)
@ -1146,12 +1127,11 @@ static int property_get_cpu_usage(
sd_bus_error *error) {
nsec_t ns = NSEC_INFINITY;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(u);
r = unit_get_cpu_usage(u, &ns);
if (r < 0 && r != -ENODATA)
@ -1169,14 +1149,13 @@ static int property_get_cpuset_cpus(
void *userdata,
sd_bus_error *error) {
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
_cleanup_(cpu_set_reset) CPUSet cpus = {};
_cleanup_free_ uint8_t *array = NULL;
size_t allocated;
assert(bus);
assert(reply);
assert(u);
(void) unit_get_cpuset(u, &cpus, "cpuset.cpus.effective");
(void) cpu_set_to_dbus(&cpus, &array, &allocated);
@ -1192,14 +1171,13 @@ static int property_get_cpuset_mems(
void *userdata,
sd_bus_error *error) {
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
_cleanup_(cpu_set_reset) CPUSet mems = {};
_cleanup_free_ uint8_t *array = NULL;
size_t allocated;
assert(bus);
assert(reply);
assert(u);
(void) unit_get_cpuset(u, &mems, "cpuset.mems.effective");
(void) cpu_set_to_dbus(&mems, &array, &allocated);
@ -1215,12 +1193,11 @@ static int property_get_cgroup(
void *userdata,
sd_bus_error *error) {
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
const char *t = NULL;
assert(bus);
assert(reply);
assert(u);
/* Three cases: a) u->cgroup_path is NULL, in which case the
* unit has no control group, which we report as the empty
@ -1400,13 +1377,12 @@ static int property_get_ip_counter(
};
uint64_t value = UINT64_MAX;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
ssize_t metric;
assert(bus);
assert(reply);
assert(property);
assert(u);
assert_se((metric = string_table_lookup(table, ELEMENTSOF(table), property)) >= 0);
(void) unit_get_ip_accounting(u, metric, &value);
@ -1430,13 +1406,12 @@ static int property_get_io_counter(
};
uint64_t value = UINT64_MAX;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
ssize_t metric;
assert(bus);
assert(reply);
assert(property);
assert(u);
assert_se((metric = string_table_lookup(table, ELEMENTSOF(table), property)) >= 0);
(void) unit_get_io_accounting(u, metric, false, &value);
@ -1593,11 +1568,10 @@ const sd_bus_vtable bus_unit_cgroup_vtable[] = {
static int send_new_signal(sd_bus *bus, void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *p = NULL;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(u);
p = unit_dbus_path(u);
if (!p)
@ -1621,11 +1595,10 @@ static int send_new_signal(sd_bus *bus, void *userdata) {
static int send_changed_signal(sd_bus *bus, void *userdata) {
_cleanup_free_ char *p = NULL;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(u);
p = unit_dbus_path(u);
if (!p)
@ -1708,11 +1681,10 @@ int bus_unit_send_pending_freezer_message(Unit *u) {
static int send_removed_signal(sd_bus *bus, void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *p = NULL;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(u);
p = unit_dbus_path(u);
if (!p)
@ -2512,10 +2484,9 @@ int bus_unit_validate_load_state(Unit *u, sd_bus_error *error) {
}
static int bus_unit_track_handler(sd_bus_track *t, void *userdata) {
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
assert(t);
assert(u);
u->bus_track = sd_bus_track_unref(u->bus_track); /* make sure we aren't called again */

View File

@ -97,13 +97,12 @@ int bus_forward_agent_released(Manager *m, const char *path) {
static int signal_agent_released(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *cgroup;
uid_t sender_uid;
int r;
assert(message);
assert(m);
/* only accept org.freedesktop.systemd1.Agent from UID=0 */
r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_EUID, &creds);
@ -126,11 +125,10 @@ static int signal_agent_released(sd_bus_message *message, void *userdata, sd_bus
}
static int signal_disconnected(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
sd_bus *bus;
assert(message);
assert(m);
assert_se(bus = sd_bus_message_get_bus(message));
if (bus == m->api_bus)
@ -149,13 +147,12 @@ static int signal_disconnected(sd_bus_message *message, void *userdata, sd_bus_e
static int signal_activation_request(sd_bus_message *message, void *userdata, sd_bus_error *ret_error) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *name;
Unit *u;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &name);
if (r < 0) {
@ -315,19 +312,18 @@ static int find_unit(Manager *m, sd_bus *bus, const char *path, Unit **unit, sd_
}
static int bus_unit_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(bus);
assert(path);
assert(interface);
assert(found);
assert(m);
return find_unit(m, bus, path, (Unit**) found, error);
}
static int bus_unit_interface_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Unit *u;
int r;
@ -335,7 +331,6 @@ static int bus_unit_interface_find(sd_bus *bus, const char *path, const char *in
assert(path);
assert(interface);
assert(found);
assert(m);
r = find_unit(m, bus, path, &u, error);
if (r <= 0)
@ -349,7 +344,7 @@ static int bus_unit_interface_find(sd_bus *bus, const char *path, const char *in
}
static int bus_unit_cgroup_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Unit *u;
int r;
@ -357,7 +352,6 @@ static int bus_unit_cgroup_find(sd_bus *bus, const char *path, const char *inter
assert(path);
assert(interface);
assert(found);
assert(m);
r = find_unit(m, bus, path, &u, error);
if (r <= 0)
@ -374,7 +368,7 @@ static int bus_unit_cgroup_find(sd_bus *bus, const char *path, const char *inter
}
static int bus_cgroup_context_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
CGroupContext *c;
Unit *u;
int r;
@ -383,7 +377,6 @@ static int bus_cgroup_context_find(sd_bus *bus, const char *path, const char *in
assert(path);
assert(interface);
assert(found);
assert(m);
r = find_unit(m, bus, path, &u, error);
if (r <= 0)
@ -401,7 +394,7 @@ static int bus_cgroup_context_find(sd_bus *bus, const char *path, const char *in
}
static int bus_exec_context_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
ExecContext *c;
Unit *u;
int r;
@ -410,7 +403,6 @@ static int bus_exec_context_find(sd_bus *bus, const char *path, const char *inte
assert(path);
assert(interface);
assert(found);
assert(m);
r = find_unit(m, bus, path, &u, error);
if (r <= 0)
@ -428,7 +420,7 @@ static int bus_exec_context_find(sd_bus *bus, const char *path, const char *inte
}
static int bus_kill_context_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
KillContext *c;
Unit *u;
int r;
@ -437,7 +429,6 @@ static int bus_kill_context_find(sd_bus *bus, const char *path, const char *inte
assert(path);
assert(interface);
assert(found);
assert(m);
r = find_unit(m, bus, path, &u, error);
if (r <= 0)
@ -659,12 +650,11 @@ static int bus_setup_disconnected_match(Manager *m, sd_bus *bus) {
static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
_cleanup_(sd_bus_close_unrefp) sd_bus *bus = NULL;
_cleanup_close_ int nfd = -1;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
sd_id128_t id;
int r;
assert(s);
assert(m);
nfd = accept4(fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
if (nfd < 0) {

View File

@ -6869,11 +6869,10 @@ int exec_runtime_deserialize_one(Manager *m, const char *value, FDSet *fds) {
_cleanup_free_ char *tmp_dir = NULL, *var_tmp_dir = NULL;
char *id = NULL;
int r, netns_fdpair[] = {-1, -1}, ipcns_fdpair[] = {-1, -1};
const char *p, *v = value;
const char *p, *v = ASSERT_PTR(value);
size_t n;
assert(m);
assert(value);
assert(fds);
n = strcspn(v, " ");

View File

@ -1057,10 +1057,9 @@ finish:
}
static int job_dispatch_timer(sd_event_source *s, uint64_t monotonic, void *userdata) {
Job *j = userdata;
Job *j = ASSERT_PTR(userdata);
Unit *u;
assert(j);
assert(s == j->timer_event_source);
log_unit_warning(j->unit, "Job %s/%s timed out.", j->unit->id, job_type_to_string(j->type));

File diff suppressed because it is too large Load Diff

View File

@ -308,9 +308,7 @@ static int have_ask_password(void) {
static int manager_dispatch_ask_password_fd(sd_event_source *source,
int fd, uint32_t revents, void *userdata) {
Manager *m = userdata;
assert(m);
Manager *m = ASSERT_PTR(userdata);
(void) flush_fd(fd);
@ -2265,11 +2263,10 @@ void manager_unwatch_pid(Manager *m, pid_t pid) {
}
static int manager_dispatch_run_queue(sd_event_source *source, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Job *j;
assert(source);
assert(m);
while ((j = prioq_peek(m->run_queue))) {
assert(j->installed);
@ -2450,7 +2447,7 @@ static void manager_invoke_notify_message(
static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
_cleanup_fdset_free_ FDSet *fds = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
char buf[NOTIFY_BUFFER_MAX+1];
struct iovec iovec = {
.iov_base = buf,
@ -2475,7 +2472,6 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
bool found = false;
ssize_t n;
assert(m);
assert(m->notify_fd == fd);
if (revents != EPOLLIN) {
@ -2618,12 +2614,11 @@ static void manager_invoke_sigchld_event(
}
static int manager_dispatch_sigchld(sd_event_source *source, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
siginfo_t si = {};
int r;
assert(source);
assert(m);
/* First we call waitid() for a PID and do not reap the zombie. That way we can still access
* /proc/$PID for it while it is a zombie. */
@ -2740,12 +2735,11 @@ static void manager_handle_ctrl_alt_del(Manager *m) {
}
static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
ssize_t n;
struct signalfd_siginfo sfsi;
int r;
assert(m);
assert(m->signal_fd == fd);
if (revents != EPOLLIN) {
@ -2936,11 +2930,9 @@ static int manager_dispatch_signal_fd(sd_event_source *source, int fd, uint32_t
}
static int manager_dispatch_time_change_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Unit *u;
assert(m);
log_struct(LOG_DEBUG,
"MESSAGE_ID=" SD_MESSAGE_TIME_CHANGE_STR,
LOG_MESSAGE("Time has been changed"));
@ -2960,12 +2952,10 @@ static int manager_dispatch_timezone_change(
const struct inotify_event *e,
void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int changed;
Unit *u;
assert(m);
log_debug("inotify event for /etc/localtime");
changed = manager_read_timezone_stat(m);
@ -2988,9 +2978,8 @@ static int manager_dispatch_timezone_change(
}
static int manager_dispatch_idle_pipe_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(m->idle_pipe[2] == fd);
/* There's at least one Type=idle child that just gave up on us waiting for the boot process to
@ -3008,10 +2997,9 @@ static int manager_dispatch_idle_pipe_fd(sd_event_source *source, int fd, uint32
}
static int manager_dispatch_jobs_in_progress(sd_event_source *source, usec_t usec, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(m);
assert(source);
manager_print_jobs_in_progress(m);

View File

@ -1886,11 +1886,9 @@ static bool mount_is_mounted(Mount *m) {
}
static int mount_on_ratelimit_expire(sd_event_source *s, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Job *j;
assert(m);
/* Let's enqueue all start jobs that were previously skipped because of active ratelimit. */
HASHMAP_FOREACH(j, m->jobs) {
if (j->unit->type != UNIT_MOUNT)
@ -2115,9 +2113,8 @@ static int mount_process_proc_self_mountinfo(Manager *m) {
}
static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(revents & EPOLLIN);
return mount_process_proc_self_mountinfo(m);

View File

@ -406,10 +406,9 @@ static void service_done(Unit *u) {
}
static int on_fd_store_io(sd_event_source *e, int fd, uint32_t revents, void *userdata) {
ServiceFDStore *fs = userdata;
ServiceFDStore *fs = ASSERT_PTR(userdata);
assert(e);
assert(fs);
/* If we get either EPOLLHUP or EPOLLERR, it's time to remove this entry from the fd store */
log_unit_debug(UNIT(fs->service),
@ -3251,11 +3250,9 @@ static int service_demand_pid_file(Service *s) {
}
static int service_dispatch_inotify_io(sd_event_source *source, int fd, uint32_t events, void *userdata) {
PathSpec *p = userdata;
PathSpec *p = ASSERT_PTR(userdata);
Service *s;
assert(p);
s = SERVICE(p->unit);
assert(s);
@ -4315,13 +4312,12 @@ static bool pick_up_pid_from_bus_name(Service *s) {
static int bus_name_pid_lookup_callback(sd_bus_message *reply, void *userdata, sd_bus_error *ret_error) {
const sd_bus_error *e;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
uint32_t pid;
Service *s;
int r;
assert(reply);
assert(u);
s = SERVICE(u);
s->bus_name_pid_lookup_slot = sd_bus_slot_unref(s->bus_name_pid_lookup_slot);

View File

@ -2978,10 +2978,9 @@ shortcut:
}
static int socket_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
SocketPort *p = userdata;
SocketPort *p = ASSERT_PTR(userdata);
int cfd = -1;
assert(p);
assert(fd >= 0);
if (p->socket->state != SOCKET_LISTENING)

View File

@ -1282,9 +1282,8 @@ static int swap_process_proc_swaps(Manager *m) {
}
static int swap_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(revents & EPOLLPRI);
return swap_process_proc_swaps(m);

View File

@ -2925,10 +2925,9 @@ static void unit_tidy_watch_pids(Unit *u) {
}
static int on_rewatch_pids_event(sd_event_source *s, void *userdata) {
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
assert(s);
assert(u);
unit_tidy_watch_pids(u);
unit_watch_all_pids(u);
@ -3441,11 +3440,10 @@ int unit_load_related_unit(Unit *u, const char *type, Unit **_found) {
static int signal_name_owner_changed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *new_owner;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(message);
assert(u);
r = sd_bus_message_read(message, "sss", NULL, NULL, &new_owner);
if (r < 0) {
@ -3462,11 +3460,10 @@ static int signal_name_owner_changed(sd_bus_message *message, void *userdata, sd
static int get_name_owner_handler(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const sd_bus_error *e;
const char *new_owner;
Unit *u = userdata;
Unit *u = ASSERT_PTR(userdata);
int r;
assert(message);
assert(u);
u->get_name_owner_slot = sd_bus_slot_unref(u->get_name_owner_slot);
@ -3850,9 +3847,7 @@ static Set *unit_pid_set(pid_t main_pid, pid_t control_pid) {
static int kill_common_log(pid_t pid, int signo, void *userdata) {
_cleanup_free_ char *comm = NULL;
Unit *u = userdata;
assert(u);
Unit *u = ASSERT_PTR(userdata);
(void) get_process_comm(pid, &comm);
log_unit_info(u, "Sending signal SIG%s to process " PID_FMT " (%s) on client request.",

View File

@ -36,13 +36,12 @@ static int luks2_pkcs11_callback(
CK_TOKEN_INFO updated_token_info;
int r;
_cleanup_free_ char *token_label = NULL;
struct luks2_pkcs11_callback_data *data = userdata;
struct luks2_pkcs11_callback_data *data = ASSERT_PTR(userdata);
assert(m);
assert(slot_info);
assert(token_info);
assert(uri);
assert(data);
token_label = pkcs11_token_label(token_info);
if (!token_label)

View File

@ -197,10 +197,9 @@ void sha256_process_bytes(const void *buffer, size_t len, struct sha256_ctx *ctx
/* Process LEN bytes of BUFFER, accumulating context into CTX.
It is assumed that LEN % 64 == 0. */
static void sha256_process_block(const void *buffer, size_t len, struct sha256_ctx *ctx) {
const uint32_t *words = buffer;
const uint32_t *words = ASSERT_PTR(buffer);
size_t nwords = len / sizeof(uint32_t);
assert(buffer);
assert(ctx);
uint32_t a = ctx->H[0];

View File

@ -23,12 +23,11 @@ static int reply_callback(Varlink *v, JsonVariant *p, const char *error_id, Varl
}
static int io_callback(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
struct iovec *iov = userdata;
struct iovec *iov = ASSERT_PTR(userdata);
bool write_eof = false, read_eof = false;
assert(s);
assert(fd >= 0);
assert(iov);
if ((revents & (EPOLLOUT|EPOLLHUP|EPOLLERR)) && iov->iov_len > 0) {
ssize_t n;

View File

@ -39,10 +39,9 @@ int config_parse_default_file_system_type(
void *data,
void *userdata) {
char **s = data;
char **s = ASSERT_PTR(data);
assert(rvalue);
assert(s);
if (!isempty(rvalue) && !supported_fstype(rvalue)) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Unsupported file system, ignoring: %s", rvalue);

View File

@ -21,11 +21,10 @@ static int property_get_unix_record(
void *userdata,
sd_bus_error *error) {
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(h);
return sd_bus_message_append(
reply, "(suusss)",
@ -46,11 +45,10 @@ static int property_get_state(
void *userdata,
sd_bus_error *error) {
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(h);
return sd_bus_message_append(reply, "s", home_state_to_string(home_get_state(h)));
}
@ -125,13 +123,12 @@ static int property_get_user_record(
sd_bus_error *error) {
_cleanup_free_ char *json = NULL;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
bool incomplete;
int r;
assert(bus);
assert(reply);
assert(h);
r = bus_home_get_record_json(h, sd_bus_get_current_message(bus), &json, &incomplete);
if (r < 0)
@ -146,11 +143,10 @@ int bus_home_method_activate(
sd_bus_error *error) {
_cleanup_(user_record_unrefp) UserRecord *secret = NULL;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
int r;
assert(message);
assert(h);
r = bus_message_read_secret(message, &secret, error);
if (r < 0)
@ -176,11 +172,10 @@ int bus_home_method_deactivate(
void *userdata,
sd_bus_error *error) {
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
int r;
assert(message);
assert(h);
r = home_deactivate(h, false, error);
if (r < 0)
@ -201,11 +196,10 @@ int bus_home_method_unregister(
void *userdata,
sd_bus_error *error) {
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
int r;
assert(message);
assert(h);
r = bus_verify_polkit_async(
message,
@ -238,11 +232,10 @@ int bus_home_method_realize(
sd_bus_error *error) {
_cleanup_(user_record_unrefp) UserRecord *secret = NULL;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
int r;
assert(message);
assert(h);
r = bus_message_read_secret(message, &secret, error);
if (r < 0)
@ -283,11 +276,10 @@ int bus_home_method_remove(
void *userdata,
sd_bus_error *error) {
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
int r;
assert(message);
assert(h);
r = bus_verify_polkit_async(
message,
@ -324,11 +316,10 @@ int bus_home_method_fixate(
sd_bus_error *error) {
_cleanup_(user_record_unrefp) UserRecord *secret = NULL;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
int r;
assert(message);
assert(h);
r = bus_message_read_secret(message, &secret, error);
if (r < 0)
@ -354,11 +345,10 @@ int bus_home_method_authenticate(
sd_bus_error *error) {
_cleanup_(user_record_unrefp) UserRecord *secret = NULL;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
int r;
assert(message);
assert(h);
r = bus_message_read_secret(message, &secret, error);
if (r < 0)
@ -437,11 +427,10 @@ int bus_home_method_update(
sd_bus_error *error) {
_cleanup_(user_record_unrefp) UserRecord *hr = NULL;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
int r;
assert(message);
assert(h);
r = bus_message_read_home_record(message, USER_RECORD_REQUIRE_REGULAR|USER_RECORD_REQUIRE_SECRET|USER_RECORD_ALLOW_PRIVILEGED|USER_RECORD_ALLOW_PER_MACHINE|USER_RECORD_ALLOW_SIGNATURE|USER_RECORD_PERMISSIVE, &hr, error);
if (r < 0)
@ -456,12 +445,11 @@ int bus_home_method_resize(
sd_bus_error *error) {
_cleanup_(user_record_unrefp) UserRecord *secret = NULL;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
uint64_t sz;
int r;
assert(message);
assert(h);
r = sd_bus_message_read(message, "t", &sz);
if (r < 0)
@ -505,11 +493,10 @@ int bus_home_method_change_password(
sd_bus_error *error) {
_cleanup_(user_record_unrefp) UserRecord *new_secret = NULL, *old_secret = NULL;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
int r;
assert(message);
assert(h);
r = bus_message_read_secret(message, &new_secret, error);
if (r < 0)
@ -552,11 +539,10 @@ int bus_home_method_lock(
void *userdata,
sd_bus_error *error) {
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
int r;
assert(message);
assert(h);
r = home_lock(h, error);
if (r < 0)
@ -580,11 +566,10 @@ int bus_home_method_unlock(
sd_bus_error *error) {
_cleanup_(user_record_unrefp) UserRecord *secret = NULL;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
int r;
assert(message);
assert(h);
r = bus_message_read_secret(message, &secret, error);
if (r < 0)
@ -614,10 +599,9 @@ int bus_home_method_acquire(
_cleanup_(operation_unrefp) Operation *o = NULL;
_cleanup_close_ int fd = -1;
int r, please_suspend;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
assert(message);
assert(h);
r = bus_message_read_secret(message, &secret, error);
if (r < 0)
@ -652,12 +636,11 @@ int bus_home_method_ref(
sd_bus_error *error) {
_cleanup_close_ int fd = -1;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
HomeState state;
int please_suspend, r;
assert(message);
assert(h);
r = sd_bus_message_read(message, "b", &please_suspend);
if (r < 0)
@ -693,11 +676,10 @@ int bus_home_method_release(
sd_bus_error *error) {
_cleanup_(operation_unrefp) Operation *o = NULL;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
int r;
assert(message);
assert(h);
o = operation_new(OPERATION_RELEASE, message);
if (!o)
@ -867,11 +849,9 @@ const BusObjectImplementation home_object = {
static int on_deferred_change(sd_event_source *s, void *userdata) {
_cleanup_free_ char *path = NULL;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
int r;
assert(h);
h->deferred_change_event_source = sd_event_source_disable_unref(h->deferred_change_event_source);
r = bus_home_path(h, &path);

View File

@ -414,11 +414,10 @@ static int home_deactivate_internal(Home *h, bool force, sd_bus_error *error);
static void home_start_retry_deactivate(Home *h);
static int home_on_retry_deactivate(sd_event_source *s, uint64_t usec, void *userdata) {
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
HomeState state;
assert(s);
assert(h);
/* 15s after the last attempt to deactivate the home directory passed. Let's try it one more time. */
@ -1050,12 +1049,11 @@ finish:
static int home_on_worker_process(sd_event_source *s, const siginfo_t *si, void *userdata) {
_cleanup_(user_record_unrefp) UserRecord *hr = NULL;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
int ret;
assert(s);
assert(si);
assert(h);
assert(h->worker_pid == si->si_pid);
assert(h->worker_event_source);
@ -2607,10 +2605,9 @@ int home_augment_status(
static int on_home_ref_eof(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
_cleanup_(operation_unrefp) Operation *o = NULL;
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
assert(s);
assert(h);
if (h->ref_event_source_please_suspend == s)
h->ref_event_source_please_suspend = sd_event_source_disable_unref(h->ref_event_source_please_suspend);
@ -2969,12 +2966,11 @@ static int home_dispatch_deactivate_force(Home *h, Operation *o) {
}
static int on_pending(sd_event_source *s, void *userdata) {
Home *h = userdata;
Home *h = ASSERT_PTR(userdata);
Operation *o;
int r;
assert(s);
assert(h);
o = ordered_set_first(h->pending_operations);
if (o) {

View File

@ -24,13 +24,12 @@ static int property_get_auto_login(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Home *h;
int r;
assert(bus);
assert(reply);
assert(m);
r = sd_bus_message_open_container(reply, 'a', "(sso)");
if (r < 0)
@ -69,12 +68,11 @@ static int method_get_home_by_name(
_cleanup_free_ char *path = NULL;
const char *user_name;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Home *h;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &user_name);
if (r < 0)
@ -107,13 +105,12 @@ static int method_get_home_by_uid(
sd_bus_error *error) {
_cleanup_free_ char *path = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
uint32_t uid;
int r;
Home *h;
assert(message);
assert(m);
r = sd_bus_message_read(message, "u", &uid);
if (r < 0)
@ -148,12 +145,11 @@ static int method_list_homes(
sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Home *h;
int r;
assert(message);
assert(m);
r = sd_bus_message_new_method_return(message, &reply);
if (r < 0)
@ -197,14 +193,13 @@ static int method_get_user_record_by_name(
sd_bus_error *error) {
_cleanup_free_ char *json = NULL, *path = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *user_name;
bool incomplete;
Home *h;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &user_name);
if (r < 0)
@ -237,14 +232,13 @@ static int method_get_user_record_by_uid(
sd_bus_error *error) {
_cleanup_free_ char *json = NULL, *path = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
bool incomplete;
uint32_t uid;
Home *h;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "u", &uid);
if (r < 0)
@ -390,12 +384,11 @@ static int method_register_home(
sd_bus_error *error) {
_cleanup_(user_record_unrefp) UserRecord *hr = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Home *h;
int r;
assert(message);
assert(m);
r = bus_message_read_home_record(message, USER_RECORD_LOAD_EMBEDDED|USER_RECORD_PERMISSIVE, &hr, error);
if (r < 0)
@ -438,12 +431,11 @@ static int method_create_home(
sd_bus_error *error) {
_cleanup_(user_record_unrefp) UserRecord *hr = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Home *h;
int r;
assert(message);
assert(m);
r = bus_message_read_home_record(message, USER_RECORD_REQUIRE_REGULAR|USER_RECORD_ALLOW_SECRET|USER_RECORD_ALLOW_PRIVILEGED|USER_RECORD_ALLOW_PER_MACHINE|USER_RECORD_ALLOW_SIGNATURE, &hr, error);
if (r < 0)
@ -505,12 +497,11 @@ static int method_authenticate_home(sd_bus_message *message, void *userdata, sd_
static int method_update_home(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(user_record_unrefp) UserRecord *hr = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Home *h;
int r;
assert(message);
assert(m);
r = bus_message_read_home_record(message, USER_RECORD_REQUIRE_REGULAR|USER_RECORD_ALLOW_SECRET|USER_RECORD_ALLOW_PRIVILEGED|USER_RECORD_ALLOW_PER_MACHINE|USER_RECORD_ALLOW_SIGNATURE|USER_RECORD_PERMISSIVE, &hr, error);
if (r < 0)
@ -556,12 +547,10 @@ static int method_release_home(sd_bus_message *message, void *userdata, sd_bus_e
static int method_lock_all_homes(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(operation_unrefp) Operation *o = NULL;
bool waiting = false;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Home *h;
int r;
assert(m);
/* This is called from logind when we are preparing for system suspend. We enqueue a lock operation
* for every suitable home we have and only when all of them completed we send a reply indicating
* completion. */
@ -599,12 +588,10 @@ static int method_lock_all_homes(sd_bus_message *message, void *userdata, sd_bus
static int method_deactivate_all_homes(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(operation_unrefp) Operation *o = NULL;
bool waiting = false;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Home *h;
int r;
assert(m);
/* This is called from systemd-homed-activate.service's ExecStop= command to ensure that all home
* directories are shutdown before the system goes down. Note that we don't do this from
* systemd-homed.service itself since we want to allow restarting of it without tearing down all home
@ -635,11 +622,9 @@ static int method_deactivate_all_homes(sd_bus_message *message, void *userdata,
}
static int method_rebalance(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(m);
r = manager_schedule_rebalance(m, /* immediately= */ true);
if (r == 0)
return sd_bus_reply_method_errorf(message, BUS_ERROR_REBALANCE_NOT_NEEDED, "No home directories need rebalancing.");
@ -832,11 +817,9 @@ const BusObjectImplementation manager_object = {
};
static int on_deferred_auto_login(sd_event_source *s, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(m);
m->deferred_auto_login_event_source = sd_event_source_disable_unref(m->deferred_auto_login_event_source);
r = sd_bus_emit_properties_changed(

View File

@ -121,10 +121,9 @@ static void manager_watch_home(Manager *m) {
static int on_home_inotify(sd_event_source *s, const struct inotify_event *event, void *userdata) {
_cleanup_free_ char *j = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *e, *n;
assert(m);
assert(event);
if ((event->mask & (IN_Q_OVERFLOW|IN_MOVE_SELF|IN_DELETE_SELF|IN_IGNORED|IN_UNMOUNT)) != 0) {
@ -1122,12 +1121,11 @@ static int on_notify_socket(sd_event_source *s, int fd, uint32_t revents, void *
_cleanup_free_ void *datagram = NULL;
_cleanup_close_ int passed_fd = -1;
struct ucred sender = UCRED_INVALID;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
ssize_t n;
Home *h;
assert(s);
assert(m);
n = read_datagram(fd, &sender, &datagram, &passed_fd);
if (n < 0) {
@ -1271,10 +1269,9 @@ static int manager_add_device(Manager *m, sd_device *d) {
}
static int manager_on_device(sd_device_monitor *monitor, sd_device *d, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(m);
assert(d);
if (device_for_action(d, SD_DEVICE_REMOVE)) {
@ -1698,9 +1695,7 @@ int manager_gc_images(Manager *m) {
}
static int on_deferred_rescan(sd_event_source *s, void *userdata) {
Manager *m = userdata;
assert(m);
Manager *m = ASSERT_PTR(userdata);
m->deferred_rescan_event_source = sd_event_source_disable_unref(m->deferred_rescan_event_source);
@ -1736,9 +1731,7 @@ int manager_enqueue_rescan(Manager *m) {
}
static int on_deferred_gc(sd_event_source *s, void *userdata) {
Manager *m = userdata;
assert(m);
Manager *m = ASSERT_PTR(userdata);
m->deferred_gc_event_source = sd_event_source_disable_unref(m->deferred_gc_event_source);
@ -2095,10 +2088,9 @@ finish:
}
static int on_rebalance_timer(sd_event_source *s, usec_t t, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(s);
assert(m);
assert(IN_SET(m->rebalance_state, REBALANCE_WAITING, REBALANCE_PENDING, REBALANCE_SHRINKING, REBALANCE_GROWING));
(void) manager_rebalance_now(m);

View File

@ -83,13 +83,12 @@ int vl_method_get_user_record(Varlink *link, JsonVariant *parameters, VarlinkMet
LookupParameters p = {
.uid = UID_INVALID,
};
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
bool trusted;
Home *h;
int r;
assert(parameters);
assert(m);
r = json_dispatch(parameters, dispatch_table, NULL, 0, &p);
if (r < 0)
@ -199,12 +198,11 @@ int vl_method_get_group_record(Varlink *link, JsonVariant *parameters, VarlinkMe
LookupParameters p = {
.gid = GID_INVALID,
};
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Home *h;
int r;
assert(parameters);
assert(m);
r = json_dispatch(parameters, dispatch_table, NULL, 0, &p);
if (r < 0)
@ -265,13 +263,12 @@ int vl_method_get_memberships(Varlink *link, JsonVariant *parameters, VarlinkMet
{}
};
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
LookupParameters p = {};
Home *h;
int r;
assert(parameters);
assert(m);
r = json_dispatch(parameters, dispatch_table, NULL, 0, &p);
if (r < 0)

View File

@ -3736,11 +3736,9 @@ static int device_is_gone(HomeSetup *setup) {
}
static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device, void *userdata) {
HomeSetup *setup = userdata;
HomeSetup *setup = ASSERT_PTR(userdata);
int r;
assert(setup);
if (!device_for_action(device, SD_DEVICE_REMOVE))
return 0;

View File

@ -15,7 +15,7 @@ int pkcs11_callback(
void *userdata) {
_cleanup_(erase_and_freep) void *decrypted_key = NULL;
struct pkcs11_callback_data *data = userdata;
struct pkcs11_callback_data *data = ASSERT_PTR(userdata);
_cleanup_free_ char *token_label = NULL;
CK_TOKEN_INFO updated_token_info;
size_t decrypted_key_size;
@ -27,7 +27,6 @@ int pkcs11_callback(
assert(slot_info);
assert(token_info);
assert(uri);
assert(data);
/* Special return values:
*

View File

@ -663,8 +663,7 @@ static int property_get_static_hostname(
void *userdata,
sd_bus_error *error) {
Context *c = userdata;
assert(c);
Context *c = ASSERT_PTR(userdata);
context_read_etc_hostname(c);
@ -730,8 +729,7 @@ static int property_get_hostname_source(
void *userdata,
sd_bus_error *error) {
Context *c = userdata;
assert(c);
Context *c = ASSERT_PTR(userdata);
context_read_etc_hostname(c);
context_determine_hostname_source(c);
@ -851,12 +849,11 @@ static int property_get_uname_field(
}
static int method_set_hostname(sd_bus_message *m, void *userdata, sd_bus_error *error) {
Context *c = userdata;
Context *c = ASSERT_PTR(userdata);
const char *name;
int interactive, r;
assert(m);
assert(c);
r = sd_bus_message_read(m, "sb", &name, &interactive);
if (r < 0)
@ -898,13 +895,12 @@ static int method_set_hostname(sd_bus_message *m, void *userdata, sd_bus_error *
}
static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_error *error) {
Context *c = userdata;
Context *c = ASSERT_PTR(userdata);
const char *name;
int interactive;
int r;
assert(m);
assert(c);
r = sd_bus_message_read(m, "sb", &name, &interactive);
if (r < 0)
@ -1068,12 +1064,11 @@ static int method_set_location(sd_bus_message *m, void *userdata, sd_bus_error *
static int method_get_product_uuid(sd_bus_message *m, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Context *c = userdata;
Context *c = ASSERT_PTR(userdata);
int interactive, r;
sd_id128_t uuid;
assert(m);
assert(c);
r = sd_bus_message_read(m, "b", &interactive);
if (r < 0)
@ -1119,11 +1114,10 @@ static int method_get_product_uuid(sd_bus_message *m, void *userdata, sd_bus_err
static int method_get_hardware_serial(sd_bus_message *m, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_free_ char *serial = NULL;
Context *c = userdata;
Context *c = ASSERT_PTR(userdata);
int r;
assert(m);
assert(c);
r = bus_verify_polkit_async(
m,
@ -1160,13 +1154,12 @@ static int method_describe(sd_bus_message *m, void *userdata, sd_bus_error *erro
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
sd_id128_t product_uuid = SD_ID128_NULL;
Context *c = userdata;
Context *c = ASSERT_PTR(userdata);
bool privileged;
struct utsname u;
int r;
assert(m);
assert(c);
r = bus_verify_polkit_async(
m,

View File

@ -27,11 +27,10 @@ static void curl_glue_check_finished(CurlGlue *g) {
}
static int curl_glue_on_io(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
CurlGlue *g = userdata;
CurlGlue *g = ASSERT_PTR(userdata);
int action, k = 0;
assert(s);
assert(g);
if (FLAGS_SET(revents, EPOLLIN | EPOLLOUT))
action = CURL_POLL_INOUT;
@ -52,12 +51,11 @@ static int curl_glue_on_io(sd_event_source *s, int fd, uint32_t revents, void *u
static int curl_glue_socket_callback(CURL *curl, curl_socket_t s, int action, void *userdata, void *socketp) {
sd_event_source *io = socketp;
CurlGlue *g = userdata;
CurlGlue *g = ASSERT_PTR(userdata);
uint32_t events = 0;
int r;
assert(curl);
assert(g);
if (action == CURL_POLL_REMOVE) {
if (io) {
@ -109,11 +107,10 @@ static int curl_glue_socket_callback(CURL *curl, curl_socket_t s, int action, vo
}
static int curl_glue_on_timer(sd_event_source *s, uint64_t usec, void *userdata) {
CurlGlue *g = userdata;
CurlGlue *g = ASSERT_PTR(userdata);
int k = 0;
assert(s);
assert(g);
if (curl_multi_socket_action(g->curl, CURL_SOCKET_TIMEOUT, 0, &k) != CURLM_OK)
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
@ -124,11 +121,10 @@ static int curl_glue_on_timer(sd_event_source *s, uint64_t usec, void *userdata)
}
static int curl_glue_timer_callback(CURLM *curl, long timeout_ms, void *userdata) {
CurlGlue *g = userdata;
CurlGlue *g = ASSERT_PTR(userdata);
usec_t usec;
assert(curl);
assert(g);
if (timeout_ms < 0) {
if (g->timer) {

View File

@ -70,11 +70,9 @@ static void progress_show(ProgressInfo *p) {
}
static int progress_path(const char *path, const struct stat *st, void *userdata) {
ProgressInfo *p = userdata;
ProgressInfo *p = ASSERT_PTR(userdata);
int r;
assert(p);
r = free_and_strdup(&p->path, path);
if (r < 0)
return r;
@ -86,9 +84,8 @@ static int progress_path(const char *path, const struct stat *st, void *userdata
}
static int progress_bytes(uint64_t nbytes, void *userdata) {
ProgressInfo *p = userdata;
ProgressInfo *p = ASSERT_PTR(userdata);
assert(p);
assert(p->size != UINT64_MAX);
p->size += nbytes;

View File

@ -345,11 +345,10 @@ static int raw_import_try_reflink(RawImport *i) {
}
static int raw_import_write(const void *p, size_t sz, void *userdata) {
RawImport *i = userdata;
RawImport *i = ASSERT_PTR(userdata);
bool too_much = false;
int r;
assert(i);
assert(p);
assert(sz > 0);

View File

@ -306,11 +306,10 @@ static int transfer_cancel(Transfer *t) {
}
static int transfer_on_pid(sd_event_source *s, const siginfo_t *si, void *userdata) {
Transfer *t = userdata;
Transfer *t = ASSERT_PTR(userdata);
bool success = false;
assert(s);
assert(t);
if (si->si_code == CLD_EXITED) {
if (si->si_status != 0)
@ -331,11 +330,10 @@ static int transfer_on_pid(sd_event_source *s, const siginfo_t *si, void *userda
}
static int transfer_on_log(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
Transfer *t = userdata;
Transfer *t = ASSERT_PTR(userdata);
ssize_t l;
assert(s);
assert(t);
l = read(fd, t->log_message + t->log_message_size, sizeof(t->log_message) - t->log_message_size);
if (l < 0)
@ -687,13 +685,12 @@ static int method_import_tar_or_raw(sd_bus_message *msg, void *userdata, sd_bus_
_cleanup_(transfer_unrefp) Transfer *t = NULL;
int fd, force, read_only, r;
const char *local, *object;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
TransferType type;
struct stat st;
uint32_t id;
assert(msg);
assert(m);
r = bus_verify_polkit_async(
msg,
@ -761,11 +758,10 @@ static int method_import_fs(sd_bus_message *msg, void *userdata, sd_bus_error *e
_cleanup_(transfer_unrefp) Transfer *t = NULL;
int fd, force, read_only, r;
const char *local, *object;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
uint32_t id;
assert(msg);
assert(m);
r = bus_verify_polkit_async(
msg,
@ -828,13 +824,12 @@ static int method_export_tar_or_raw(sd_bus_message *msg, void *userdata, sd_bus_
_cleanup_(transfer_unrefp) Transfer *t = NULL;
int fd, r;
const char *local, *object, *format;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
TransferType type;
struct stat st;
uint32_t id;
assert(msg);
assert(m);
r = bus_verify_polkit_async(
msg,
@ -901,14 +896,13 @@ static int method_export_tar_or_raw(sd_bus_message *msg, void *userdata, sd_bus_
static int method_pull_tar_or_raw(sd_bus_message *msg, void *userdata, sd_bus_error *error) {
_cleanup_(transfer_unrefp) Transfer *t = NULL;
const char *remote, *local, *verify, *object;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
ImportVerify v;
TransferType type;
int force, r;
uint32_t id;
assert(msg);
assert(m);
r = bus_verify_polkit_async(
msg,
@ -988,12 +982,11 @@ static int method_pull_tar_or_raw(sd_bus_message *msg, void *userdata, sd_bus_er
static int method_list_transfers(sd_bus_message *msg, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Transfer *t;
int r;
assert(msg);
assert(m);
r = sd_bus_message_new_method_return(msg, &reply);
if (r < 0)
@ -1026,11 +1019,10 @@ static int method_list_transfers(sd_bus_message *msg, void *userdata, sd_bus_err
}
static int method_cancel(sd_bus_message *msg, void *userdata, sd_bus_error *error) {
Transfer *t = userdata;
Transfer *t = ASSERT_PTR(userdata);
int r;
assert(msg);
assert(t);
r = bus_verify_polkit_async(
msg,
@ -1054,13 +1046,12 @@ static int method_cancel(sd_bus_message *msg, void *userdata, sd_bus_error *erro
}
static int method_cancel_transfer(sd_bus_message *msg, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Transfer *t;
uint32_t id;
int r;
assert(msg);
assert(m);
r = bus_verify_polkit_async(
msg,
@ -1102,11 +1093,10 @@ static int property_get_progress(
void *userdata,
sd_bus_error *error) {
Transfer *t = userdata;
Transfer *t = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(t);
return sd_bus_message_append(reply, "d", transfer_percent_as_double(t));
}
@ -1122,7 +1112,7 @@ static int transfer_object_find(
void **found,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Transfer *t;
const char *p;
uint32_t id;
@ -1132,7 +1122,6 @@ static int transfer_object_find(
assert(path);
assert(interface);
assert(found);
assert(m);
p = startswith(path, "/org/freedesktop/import1/transfer/_");
if (!p)

View File

@ -303,11 +303,10 @@ finish:
}
static int pull_job_write_uncompressed(const void *p, size_t sz, void *userdata) {
PullJob *j = userdata;
PullJob *j = ASSERT_PTR(userdata);
bool too_much = false;
int r;
assert(j);
assert(p);
assert(sz > 0);
@ -480,12 +479,11 @@ static int pull_job_detect_compression(PullJob *j) {
}
static size_t pull_job_write_callback(void *contents, size_t size, size_t nmemb, void *userdata) {
PullJob *j = userdata;
PullJob *j = ASSERT_PTR(userdata);
size_t sz = size * nmemb;
int r;
assert(contents);
assert(j);
switch (j->state) {
@ -543,13 +541,12 @@ static int http_status_etag_exists(CURLcode status) {
static size_t pull_job_header_callback(void *contents, size_t size, size_t nmemb, void *userdata) {
_cleanup_free_ char *length = NULL, *last_modified = NULL, *etag = NULL;
size_t sz = size * nmemb;
PullJob *j = userdata;
PullJob *j = ASSERT_PTR(userdata);
CURLcode code;
long status;
int r;
assert(contents);
assert(j);
if (IN_SET(j->state, PULL_JOB_DONE, PULL_JOB_FAILED)) {
r = -ESTALE;
@ -634,12 +631,10 @@ fail:
}
static int pull_job_progress_callback(void *userdata, curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) {
PullJob *j = userdata;
PullJob *j = ASSERT_PTR(userdata);
unsigned percent;
usec_t n;
assert(j);
if (dltotal <= 0)
return 0;

View File

@ -147,11 +147,10 @@ static ssize_t request_reader_entries(
char *buf,
size_t max) {
RequestMeta *m = cls;
RequestMeta *m = ASSERT_PTR(cls);
int r;
size_t n, k;
assert(m);
assert(buf);
assert(max > 0);
assert(pos >= m->delta);
@ -359,12 +358,10 @@ static mhd_result request_parse_arguments_iterator(
const char *key,
const char *value) {
RequestMeta *m = cls;
RequestMeta *m = ASSERT_PTR(cls);
_cleanup_free_ char *p = NULL;
int r;
assert(m);
if (isempty(key)) {
m->argument_parse_error = -EINVAL;
return MHD_NO;
@ -467,11 +464,10 @@ static int request_handler_entries(
void *connection_cls) {
_cleanup_(MHD_destroy_responsep) struct MHD_Response *response = NULL;
RequestMeta *m = connection_cls;
RequestMeta *m = ASSERT_PTR(connection_cls);
int r;
assert(connection);
assert(m);
r = open_journal(m);
if (r < 0)
@ -541,11 +537,10 @@ static ssize_t request_reader_fields(
char *buf,
size_t max) {
RequestMeta *m = cls;
RequestMeta *m = ASSERT_PTR(cls);
int r;
size_t n, k;
assert(m);
assert(buf);
assert(max > 0);
assert(pos >= m->delta);
@ -616,11 +611,10 @@ static int request_handler_fields(
void *connection_cls) {
_cleanup_(MHD_destroy_responsep) struct MHD_Response *response = NULL;
RequestMeta *m = connection_cls;
RequestMeta *m = ASSERT_PTR(connection_cls);
int r;
assert(connection);
assert(m);
r = open_journal(m);
if (r < 0)
@ -734,7 +728,7 @@ static int request_handler_machine(
void *connection_cls) {
_cleanup_(MHD_destroy_responsep) struct MHD_Response *response = NULL;
RequestMeta *m = connection_cls;
RequestMeta *m = ASSERT_PTR(connection_cls);
int r;
_cleanup_free_ char* hostname = NULL, *os_name = NULL;
uint64_t cutoff_from = 0, cutoff_to = 0, usage = 0;
@ -742,7 +736,6 @@ static int request_handler_machine(
_cleanup_free_ char *v = NULL, *json = NULL;
assert(connection);
assert(m);
r = open_journal(m);
if (r < 0)

View File

@ -530,12 +530,10 @@ static int dispatch_http_event(sd_event_source *event,
int fd,
uint32_t revents,
void *userdata) {
MHDDaemonWrapper *d = userdata;
MHDDaemonWrapper *d = ASSERT_PTR(userdata);
int r;
MHD_UNSIGNED_LONG_LONG timeout = ULLONG_MAX;
assert(d);
r = MHD_run(d->daemon);
if (r == MHD_NO)
// FIXME: unregister daemon

View File

@ -251,13 +251,12 @@ static void check_update_watchdog(Uploader *u) {
}
static size_t journal_input_callback(void *buf, size_t size, size_t nmemb, void *userp) {
Uploader *u = userp;
Uploader *u = ASSERT_PTR(userp);
int r;
sd_journal *j;
size_t filled = 0;
ssize_t w;
assert(u);
assert(nmemb <= SSIZE_MAX / size);
check_update_watchdog(u);
@ -356,9 +355,7 @@ static int dispatch_journal_input(sd_event_source *event,
int fd,
uint32_t revents,
void *userp) {
Uploader *u = userp;
assert(u);
Uploader *u = ASSERT_PTR(userp);
if (u->uploading)
return 0;

View File

@ -79,9 +79,7 @@ static size_t output_callback(char *buf,
size_t size,
size_t nmemb,
void *userp) {
Uploader *u = userp;
assert(u);
Uploader *u = ASSERT_PTR(userp);
log_debug("The server answers (%zu bytes): %.*s",
size*nmemb, (int)(size*nmemb), buf);
@ -291,10 +289,9 @@ int start_upload(Uploader *u,
}
static size_t fd_input_callback(void *buf, size_t size, size_t nmemb, void *userp) {
Uploader *u = userp;
Uploader *u = ASSERT_PTR(userp);
ssize_t n;
assert(u);
assert(nmemb < SSIZE_MAX / size);
if (u->input < 0)
@ -329,9 +326,8 @@ static int dispatch_fd_input(sd_event_source *event,
int fd,
uint32_t revents,
void *userp) {
Uploader *u = userp;
Uploader *u = ASSERT_PTR(userp);
assert(u);
assert(fd >= 0);
if (revents & EPOLLHUP) {
@ -384,9 +380,7 @@ static int open_file_for_upload(Uploader *u, const char *filename) {
static int dispatch_sigterm(sd_event_source *event,
const struct signalfd_siginfo *si,
void *userdata) {
Uploader *u = userdata;
assert(u);
Uploader *u = ASSERT_PTR(userdata);
log_received_signal(LOG_INFO, si);
@ -540,13 +534,12 @@ static int config_parse_path_or_ignore(
_cleanup_free_ char *n = NULL;
bool fatal = ltype;
char **s = data;
char **s = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
if (isempty(rvalue))
goto finalize;

View File

@ -362,11 +362,10 @@ int server_flush_dev_kmsg(Server *s) {
}
static int dispatch_dev_kmsg(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
Server *s = userdata;
Server *s = ASSERT_PTR(userdata);
assert(es);
assert(fd == s->dev_kmsg_fd);
assert(s);
if (revents & EPOLLERR)
log_warning("/dev/kmsg buffer overrun, some messages lost.");

View File

@ -1291,7 +1291,7 @@ int server_process_datagram(
void *userdata) {
size_t label_len = 0, m;
Server *s = userdata;
Server *s = ASSERT_PTR(userdata);
struct ucred *ucred = NULL;
struct timeval *tv = NULL;
struct cmsghdr *cmsg;
@ -1324,7 +1324,6 @@ int server_process_datagram(
.msg_namelen = sizeof(sa),
};
assert(s);
assert(fd == s->native_fd || fd == s->syslog_fd || fd == s->audit_fd);
if (revents != EPOLLIN)
@ -1425,9 +1424,7 @@ static void server_full_flush(Server *s) {
}
static int dispatch_sigusr1(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
Server *s = userdata;
assert(s);
Server *s = ASSERT_PTR(userdata);
if (s->namespace) {
log_error("Received SIGUSR1 signal from PID %u, but flushing runtime journals not supported for namespaced instances.", si->ssi_pid);
@ -1462,9 +1459,7 @@ static void server_full_rotate(Server *s) {
}
static int dispatch_sigusr2(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
Server *s = userdata;
assert(s);
Server *s = ASSERT_PTR(userdata);
log_info("Received SIGUSR2 signal from PID %u, as request to rotate journal, rotating.", si->ssi_pid);
server_full_rotate(s);
@ -1474,11 +1469,9 @@ static int dispatch_sigusr2(sd_event_source *es, const struct signalfd_siginfo *
static int dispatch_sigterm(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
_cleanup_(sd_event_source_disable_unrefp) sd_event_source *news = NULL;
Server *s = userdata;
Server *s = ASSERT_PTR(userdata);
int r;
assert(s);
log_received_signal(LOG_INFO, si);
(void) sd_event_source_set_enabled(es, SD_EVENT_OFF); /* Make sure this handler is called at most once */
@ -1571,9 +1564,7 @@ static void server_full_sync(Server *s) {
}
static int dispatch_sigrtmin1(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
Server *s = userdata;
assert(s);
Server *s = ASSERT_PTR(userdata);
log_debug("Received SIGRTMIN1 signal from PID %u, as request to sync.", si->ssi_pid);
server_full_sync(s);
@ -1630,11 +1621,9 @@ static int setup_signals(Server *s) {
}
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
Server *s = data;
Server *s = ASSERT_PTR(data);
int r;
assert(s);
if (proc_cmdline_key_streq(key, "systemd.journald.forward_to_syslog")) {
r = value ? parse_boolean(value) : true;
@ -1763,9 +1752,7 @@ static int server_parse_config_file(Server *s) {
}
static int server_dispatch_sync(sd_event_source *es, usec_t t, void *userdata) {
Server *s = userdata;
assert(s);
Server *s = ASSERT_PTR(userdata);
server_sync(s);
return 0;
@ -1815,9 +1802,7 @@ int server_schedule_sync(Server *s, int priority) {
}
static int dispatch_hostname_change(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
Server *s = userdata;
assert(s);
Server *s = ASSERT_PTR(userdata);
server_cache_hostname(s);
return 0;
@ -1854,10 +1839,9 @@ static int server_open_hostname(Server *s) {
}
static int dispatch_notify_event(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
Server *s = userdata;
Server *s = ASSERT_PTR(userdata);
int r;
assert(s);
assert(s->notify_event_source == es);
assert(s->notify_fd == fd);
@ -1911,11 +1895,9 @@ static int dispatch_notify_event(sd_event_source *es, int fd, uint32_t revents,
}
static int dispatch_watchdog(sd_event_source *es, uint64_t usec, void *userdata) {
Server *s = userdata;
Server *s = ASSERT_PTR(userdata);
int r;
assert(s);
s->send_watchdog = true;
r = sd_event_source_set_enabled(s->notify_event_source, SD_EVENT_ON);
@ -1993,11 +1975,10 @@ static int server_connect_notify(Server *s) {
}
static int synchronize_second_half(sd_event_source *event_source, void *userdata) {
Varlink *link = userdata;
Varlink *link = ASSERT_PTR(userdata);
Server *s;
int r;
assert(link);
assert_se(s = varlink_get_userdata(link));
/* This is the "second half" of the Synchronize() varlink method. This function is called as deferred
@ -2021,11 +2002,10 @@ static void synchronize_destroy(void *userdata) {
static int vl_method_synchronize(Varlink *link, JsonVariant *parameters, VarlinkMethodFlags flags, void *userdata) {
_cleanup_(sd_event_source_unrefp) sd_event_source *event_source = NULL;
Server *s = userdata;
Server *s = ASSERT_PTR(userdata);
int r;
assert(link);
assert(s);
if (json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
@ -2062,10 +2042,9 @@ static int vl_method_synchronize(Varlink *link, JsonVariant *parameters, Varlink
}
static int vl_method_rotate(Varlink *link, JsonVariant *parameters, VarlinkMethodFlags flags, void *userdata) {
Server *s = userdata;
Server *s = ASSERT_PTR(userdata);
assert(link);
assert(s);
if (json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
@ -2077,10 +2056,9 @@ static int vl_method_rotate(Varlink *link, JsonVariant *parameters, VarlinkMetho
}
static int vl_method_flush_to_var(Varlink *link, JsonVariant *parameters, VarlinkMethodFlags flags, void *userdata) {
Server *s = userdata;
Server *s = ASSERT_PTR(userdata);
assert(link);
assert(s);
if (json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
@ -2094,10 +2072,9 @@ static int vl_method_flush_to_var(Varlink *link, JsonVariant *parameters, Varlin
}
static int vl_method_relinquish_var(Varlink *link, JsonVariant *parameters, VarlinkMethodFlags flags, void *userdata) {
Server *s = userdata;
Server *s = ASSERT_PTR(userdata);
assert(link);
assert(s);
if (json_variant_elements(parameters) > 0)
return varlink_error_invalid_parameter(link, parameters);
@ -2111,11 +2088,10 @@ static int vl_method_relinquish_var(Varlink *link, JsonVariant *parameters, Varl
}
static int vl_connect(VarlinkServer *server, Varlink *link, void *userdata) {
Server *s = userdata;
Server *s = ASSERT_PTR(userdata);
assert(server);
assert(link);
assert(s);
(void) server_start_or_stop_idle_timer(s); /* maybe we are no longer idle */
@ -2123,11 +2099,10 @@ static int vl_connect(VarlinkServer *server, Varlink *link, void *userdata) {
}
static void vl_disconnect(VarlinkServer *server, Varlink *link, void *userdata) {
Server *s = userdata;
Server *s = ASSERT_PTR(userdata);
assert(server);
assert(link);
assert(s);
(void) server_start_or_stop_idle_timer(s); /* maybe we are idle now */
}
@ -2198,10 +2173,9 @@ static bool server_is_idle(Server *s) {
}
static int server_idle_handler(sd_event_source *source, uint64_t usec, void *userdata) {
Server *s = userdata;
Server *s = ASSERT_PTR(userdata);
assert(source);
assert(s);
log_debug("Server is idle, exiting.");
sd_event_exit(s->event, 0);
@ -2645,13 +2619,12 @@ int config_parse_line_max(
void *data,
void *userdata) {
size_t *sz = data;
size_t *sz = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
if (isempty(rvalue))
/* Empty assignment means default */

View File

@ -548,7 +548,7 @@ static int stdout_stream_scan(
static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct ucred))) control;
size_t limit, consumed, allocated;
StdoutStream *s = userdata;
StdoutStream *s = ASSERT_PTR(userdata);
struct ucred *ucred;
struct iovec iovec;
ssize_t l;
@ -562,8 +562,6 @@ static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents,
.msg_controllen = sizeof(control),
};
assert(s);
if ((revents|EPOLLIN|EPOLLHUP) != (EPOLLIN|EPOLLHUP)) {
log_error("Got invalid event from epoll for stdout stream: %"PRIx32, revents);
goto terminate;
@ -705,11 +703,9 @@ int stdout_stream_install(Server *s, int fd, StdoutStream **ret) {
static int stdout_stream_new(sd_event_source *es, int listen_fd, uint32_t revents, void *userdata) {
_cleanup_close_ int fd = -1;
Server *s = userdata;
Server *s = ASSERT_PTR(userdata);
int r;
assert(s);
if (revents != EPOLLIN)
return log_error_errno(SYNTHETIC_ERRNO(EIO),
"Got invalid event from epoll for stdout server fd: %" PRIx32,

View File

@ -1184,14 +1184,13 @@ static int client_timeout_resend(
uint64_t usec,
void *userdata) {
sd_dhcp_client *client = userdata;
sd_dhcp_client *client = ASSERT_PTR(userdata);
DHCP_CLIENT_DONT_DESTROY(client);
usec_t next_timeout;
uint64_t time_now;
int r;
assert(s);
assert(client);
assert(client->event);
r = sd_event_now(client->event, CLOCK_BOOTTIME, &time_now);
@ -1415,12 +1414,10 @@ static int client_timeout_expire(sd_event_source *s, uint64_t usec, void *userda
}
static int client_timeout_t2(sd_event_source *s, uint64_t usec, void *userdata) {
sd_dhcp_client *client = userdata;
sd_dhcp_client *client = ASSERT_PTR(userdata);
DHCP_CLIENT_DONT_DESTROY(client);
int r;
assert(client);
client->receive_message = sd_event_source_disable_unref(client->receive_message);
client->fd = safe_close(client->fd);
@ -1840,14 +1837,13 @@ static int client_receive_message_udp(
uint32_t revents,
void *userdata) {
sd_dhcp_client *client = userdata;
sd_dhcp_client *client = ASSERT_PTR(userdata);
_cleanup_free_ DHCPMessage *message = NULL;
const uint8_t *expected_chaddr = NULL;
uint8_t expected_hlen = 0;
ssize_t len, buflen;
assert(s);
assert(client);
buflen = next_datagram_size_fd(fd);
if (buflen < 0) {
@ -1925,7 +1921,7 @@ static int client_receive_message_raw(
uint32_t revents,
void *userdata) {
sd_dhcp_client *client = userdata;
sd_dhcp_client *client = ASSERT_PTR(userdata);
_cleanup_free_ DHCPPacket *packet = NULL;
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct tpacket_auxdata))) control;
struct iovec iov = {};
@ -1941,7 +1937,6 @@ static int client_receive_message_raw(
int r;
assert(s);
assert(client);
buflen = next_datagram_size_fd(fd);
if (buflen < 0) {

View File

@ -624,11 +624,9 @@ static int lease_parse_6rd(sd_dhcp_lease *lease, const uint8_t *option, size_t l
}
int dhcp_lease_parse_options(uint8_t code, uint8_t len, const void *option, void *userdata) {
sd_dhcp_lease *lease = userdata;
sd_dhcp_lease *lease = ASSERT_PTR(userdata);
int r;
assert(lease);
switch (code) {
case SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME:

View File

@ -733,9 +733,7 @@ static int server_send_forcerenew(
}
static int parse_request(uint8_t code, uint8_t len, const void *option, void *userdata) {
DHCPRequest *req = userdata;
assert(req);
DHCPRequest *req = ASSERT_PTR(userdata);
switch (code) {
case SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME:
@ -1264,7 +1262,7 @@ static int server_receive_message(sd_event_source *s, int fd,
uint32_t revents, void *userdata) {
_cleanup_free_ DHCPMessage *message = NULL;
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct in_pktinfo))) control;
sd_dhcp_server *server = userdata;
sd_dhcp_server *server = ASSERT_PTR(userdata);
struct iovec iov = {};
struct msghdr msg = {
.msg_iov = &iov,
@ -1276,8 +1274,6 @@ static int server_receive_message(sd_event_source *s, int fd,
ssize_t datagram_size, len;
int r;
assert(server);
datagram_size = next_datagram_size_fd(fd);
if (datagram_size < 0) {
if (ERRNO_IS_TRANSIENT(datagram_size) || ERRNO_IS_DISCONNECT(datagram_size))

View File

@ -210,11 +210,9 @@ static int ipv4acd_set_next_wakeup(sd_ipv4acd *acd, usec_t usec, usec_t random_u
}
static int ipv4acd_on_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
sd_ipv4acd *acd = userdata;
sd_ipv4acd *acd = ASSERT_PTR(userdata);
int r = 0;
assert(acd);
switch (acd->state) {
case IPV4ACD_STATE_STARTED:
@ -351,13 +349,12 @@ static int ipv4acd_on_packet(
uint32_t revents,
void *userdata) {
sd_ipv4acd *acd = userdata;
sd_ipv4acd *acd = ASSERT_PTR(userdata);
struct ether_arp packet;
ssize_t n;
int r;
assert(s);
assert(acd);
assert(fd >= 0);
n = recv(fd, &packet, sizeof(struct ether_arp), 0);

View File

@ -313,12 +313,11 @@ static void ipv4ll_client_notify(sd_ipv4ll *ll, int event) {
}
void ipv4ll_on_acd(sd_ipv4acd *acd, int event, void *userdata) {
sd_ipv4ll *ll = userdata;
sd_ipv4ll *ll = ASSERT_PTR(userdata);
IPV4LL_DONT_DESTROY(ll);
int r;
assert(acd);
assert(ll);
switch (event) {
@ -358,9 +357,7 @@ error:
}
static int ipv4ll_check_mac(sd_ipv4acd *acd, const struct ether_addr *mac, void *userdata) {
sd_ipv4ll *ll = userdata;
assert(ll);
sd_ipv4ll *ll = ASSERT_PTR(userdata);
if (ll->check_mac_callback)
return ll->check_mac_callback(ll, mac, ll->check_mac_userdata);

View File

@ -192,11 +192,10 @@ static int lldp_rx_handle_datagram(sd_lldp_rx *lldp_rx, sd_lldp_neighbor *n) {
static int lldp_rx_receive_datagram(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
_cleanup_(sd_lldp_neighbor_unrefp) sd_lldp_neighbor *n = NULL;
ssize_t space, length;
sd_lldp_rx *lldp_rx = userdata;
sd_lldp_rx *lldp_rx = ASSERT_PTR(userdata);
struct timespec ts;
assert(fd >= 0);
assert(lldp_rx);
space = next_datagram_size_fd(fd);
if (space < 0) {

View File

@ -547,11 +547,9 @@ static int lldp_tx_reset_timer(sd_lldp_tx *lldp_tx) {
}
static int on_timer_event(sd_event_source *s, uint64_t usec, void *userdata) {
sd_lldp_tx *lldp_tx = userdata;
sd_lldp_tx *lldp_tx = ASSERT_PTR(userdata);
int r;
assert(lldp_tx);
r = lldp_tx_send(lldp_tx);
if (r < 0)
log_lldp_tx_errno(lldp_tx, r, "Failed to send packet, ignoring: %m");

View File

@ -200,12 +200,11 @@ static int ndisc_handle_datagram(sd_ndisc *nd, sd_ndisc_router *rt) {
static int ndisc_recv(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
_cleanup_(sd_ndisc_router_unrefp) sd_ndisc_router *rt = NULL;
sd_ndisc *nd = userdata;
sd_ndisc *nd = ASSERT_PTR(userdata);
ssize_t buflen;
int r;
assert(s);
assert(nd);
assert(nd->event);
buflen = next_datagram_size_fd(fd);
@ -260,12 +259,11 @@ static usec_t ndisc_timeout_compute_random(usec_t val) {
}
static int ndisc_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
sd_ndisc *nd = userdata;
sd_ndisc *nd = ASSERT_PTR(userdata);
usec_t time_now;
int r;
assert(s);
assert(nd);
assert(nd->event);
assert_se(sd_event_now(nd->event, CLOCK_BOOTTIME, &time_now) >= 0);
@ -304,10 +302,9 @@ fail:
}
static int ndisc_timeout_no_ra(sd_event_source *s, uint64_t usec, void *userdata) {
sd_ndisc *nd = userdata;
sd_ndisc *nd = ASSERT_PTR(userdata);
assert(s);
assert(nd);
log_ndisc(nd, "No RA received before link confirmation timeout");

View File

@ -243,13 +243,12 @@ static int radv_send(sd_radv *ra, const struct in6_addr *dst, usec_t lifetime_us
}
static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
sd_radv *ra = userdata;
sd_radv *ra = ASSERT_PTR(userdata);
struct in6_addr src;
triple_timestamp timestamp;
int r;
assert(s);
assert(ra);
assert(ra->event);
ssize_t buflen = next_datagram_size_fd(fd);
@ -310,11 +309,10 @@ static int radv_recv(sd_event_source *s, int fd, uint32_t revents, void *userdat
static int radv_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
usec_t min_timeout, max_timeout, time_now, timeout;
sd_radv *ra = userdata;
sd_radv *ra = ASSERT_PTR(userdata);
int r;
assert(s);
assert(ra);
assert(ra->event);
assert(router_lifetime_is_valid(ra->lifetime_usec));

View File

@ -192,13 +192,12 @@ int introspect_write_interface(
const char *interface_name,
const sd_bus_vtable *v) {
const sd_bus_vtable *vtable = v;
const sd_bus_vtable *vtable = ASSERT_PTR(v);
const char *names = "";
int r;
assert(i);
assert(interface_name);
assert(v);
r = set_interface_name(i, interface_name);
if (r < 0)

View File

@ -164,12 +164,11 @@ static sd_bus_track *track_free(sd_bus_track *track) {
DEFINE_PUBLIC_TRIVIAL_REF_UNREF_FUNC(sd_bus_track, sd_bus_track, track_free);
static int on_name_owner_changed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
sd_bus_track *track = userdata;
sd_bus_track *track = ASSERT_PTR(userdata);
const char *name;
int r;
assert(message);
assert(track);
r = sd_bus_message_read(message, "sss", &name, NULL, NULL);
if (r < 0)

View File

@ -3415,12 +3415,11 @@ static int add_match_callback(
void *userdata,
sd_bus_error *ret_error) {
sd_bus_slot *match_slot = userdata;
sd_bus_slot *match_slot = ASSERT_PTR(userdata);
bool failed = false;
int r;
assert(m);
assert(match_slot);
sd_bus_slot_ref(match_slot);
@ -3592,11 +3591,9 @@ bool bus_pid_changed(sd_bus *bus) {
}
static int io_callback(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
/* Note that this is called both on input_fd, output_fd as well as inotify_fd events */
r = sd_bus_process(bus, NULL);
@ -3609,11 +3606,9 @@ static int io_callback(sd_event_source *s, int fd, uint32_t revents, void *userd
}
static int time_callback(sd_event_source *s, uint64_t usec, void *userdata) {
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
r = sd_bus_process(bus, NULL);
if (r < 0) {
log_debug_errno(r, "Processing of bus failed, closing down: %m");
@ -3624,12 +3619,11 @@ static int time_callback(sd_event_source *s, uint64_t usec, void *userdata) {
}
static int prepare_callback(sd_event_source *s, void *userdata) {
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r, e;
usec_t until;
assert(s);
assert(bus);
e = sd_bus_get_events(bus);
if (e < 0) {

View File

@ -244,9 +244,7 @@ _public_ int sd_device_monitor_stop(sd_device_monitor *m) {
static int device_monitor_event_handler(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
sd_device_monitor *m = userdata;
assert(m);
sd_device_monitor *m = ASSERT_PTR(userdata);
if (device_monitor_receive_device(m, &device) <= 0)
return 0;

View File

@ -147,7 +147,7 @@ static void set_location(sd_journal *j, JournalFile *f, Object *o) {
}
static int match_is_valid(const void *data, size_t size) {
assert(data);
const char *b = ASSERT_PTR(data);
if (size < 2)
return false;
@ -155,7 +155,6 @@ static int match_is_valid(const void *data, size_t size) {
if (((char*) data)[0] == '_' && ((char*) data)[1] == '_')
return false;
const char *b = data;
for (const char *p = b; p < b + size; p++) {
if (*p == '=')
@ -3208,13 +3207,12 @@ _public_ int sd_journal_reliable_fd(sd_journal *j) {
}
static char *lookup_field(const char *field, void *userdata) {
sd_journal *j = userdata;
sd_journal *j = ASSERT_PTR(userdata);
const void *data;
size_t size, d;
int r;
assert(field);
assert(j);
r = sd_journal_get_data(j, field, &data, &size);
if (r < 0 ||

View File

@ -678,11 +678,9 @@ _public_ int sd_netlink_get_timeout(sd_netlink *nl, uint64_t *timeout_usec) {
}
static int io_callback(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
sd_netlink *nl = userdata;
sd_netlink *nl = ASSERT_PTR(userdata);
int r;
assert(nl);
r = sd_netlink_process(nl, NULL);
if (r < 0)
return r;
@ -691,11 +689,9 @@ static int io_callback(sd_event_source *s, int fd, uint32_t revents, void *userd
}
static int time_callback(sd_event_source *s, uint64_t usec, void *userdata) {
sd_netlink *nl = userdata;
sd_netlink *nl = ASSERT_PTR(userdata);
int r;
assert(nl);
r = sd_netlink_process(nl, NULL);
if (r < 0)
return r;
@ -704,12 +700,11 @@ static int time_callback(sd_event_source *s, uint64_t usec, void *userdata) {
}
static int prepare_callback(sd_event_source *s, void *userdata) {
sd_netlink *nl = userdata;
sd_netlink *nl = ASSERT_PTR(userdata);
int r, enabled;
usec_t until;
assert(s);
assert(nl);
r = sd_netlink_get_events(nl);
if (r < 0)

View File

@ -1236,11 +1236,9 @@ _public_ int sd_resolve_query_set_floating(sd_resolve_query *q, int b) {
}
static int io_callback(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
sd_resolve *resolve = userdata;
sd_resolve *resolve = ASSERT_PTR(userdata);
int r;
assert(resolve);
r = sd_resolve_process(resolve);
if (r < 0)
return r;

View File

@ -164,11 +164,9 @@ static int show_status(int argc, char **argv, void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
r = bus_map_all_properties(bus,
"org.freedesktop.locale1",
"/org/freedesktop/locale1",
@ -186,11 +184,9 @@ static int show_status(int argc, char **argv, void *userdata) {
static int set_locale(int argc, char **argv, void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_message_new_method_call(bus, &m, bus_locale, "SetLocale");
@ -230,11 +226,9 @@ static int list_locales(int argc, char **argv, void *userdata) {
static int set_vconsole_keymap(int argc, char **argv, void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const char *map, *toggle_map;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
map = argv[1];

View File

@ -295,12 +295,11 @@ static int locale_gen_process_locale(char *new_locale[static _VARIABLE_LC_MAX],
static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *error) {
_cleanup_(locale_variables_freep) char *new_locale[_VARIABLE_LC_MAX] = {};
_cleanup_strv_free_ char **l = NULL, **l_set = NULL, **l_unset = NULL;
Context *c = userdata;
Context *c = ASSERT_PTR(userdata);
int interactive, r;
bool use_localegen;
assert(m);
assert(c);
r = sd_bus_message_read_strv(m, &l);
if (r < 0)
@ -414,12 +413,11 @@ static int method_set_locale(sd_bus_message *m, void *userdata, sd_bus_error *er
}
static int method_set_vc_keyboard(sd_bus_message *m, void *userdata, sd_bus_error *error) {
Context *c = userdata;
Context *c = ASSERT_PTR(userdata);
const char *keymap, *keymap_toggle;
int convert, interactive, r;
assert(m);
assert(c);
r = sd_bus_message_read(m, "ssbb", &keymap, &keymap_toggle, &convert, &interactive);
if (r < 0)
@ -594,12 +592,11 @@ static int verify_xkb_rmlvo(const char *model, const char *layout, const char *v
#endif
static int method_set_x11_keyboard(sd_bus_message *m, void *userdata, sd_bus_error *error) {
Context *c = userdata;
Context *c = ASSERT_PTR(userdata);
const char *layout, *model, *variant, *options;
int convert, interactive, r;
assert(m);
assert(c);
r = sd_bus_message_read(m, "ssssbb", &layout, &model, &variant, &options, &convert, &interactive);
if (r < 0)

View File

@ -117,10 +117,9 @@ static int list_sessions(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(table_unrefp) Table *table = NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(argv);
pager_open(arg_pager_flags);
@ -191,10 +190,9 @@ static int list_users(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(table_unrefp) Table *table = NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(argv);
pager_open(arg_pager_flags);
@ -254,10 +252,9 @@ static int list_seats(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(table_unrefp) Table *table = NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(argv);
pager_open(arg_pager_flags);
@ -811,12 +808,11 @@ static int show_properties(sd_bus *bus, const char *path, bool *new_line) {
static int show_session(int argc, char *argv[], void *userdata) {
bool properties, new_line = false;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_free_ char *path = NULL;
assert(bus);
assert(argv);
properties = !strstr(argv[0], "status");
@ -850,10 +846,9 @@ static int show_session(int argc, char *argv[], void *userdata) {
static int show_user(int argc, char *argv[], void *userdata) {
bool properties, new_line = false;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(argv);
properties = !strstr(argv[0], "status");
@ -907,10 +902,9 @@ static int show_user(int argc, char *argv[], void *userdata) {
static int show_seat(int argc, char *argv[], void *userdata) {
bool properties, new_line = false;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(argv);
properties = !strstr(argv[0], "status");
@ -952,10 +946,9 @@ static int show_seat(int argc, char *argv[], void *userdata) {
static int activate(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(argv);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
@ -997,10 +990,9 @@ static int activate(int argc, char *argv[], void *userdata) {
static int kill_session(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(argv);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
@ -1025,12 +1017,11 @@ static int kill_session(int argc, char *argv[], void *userdata) {
static int enable_linger(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
char* short_argv[3];
bool b;
int r;
assert(bus);
assert(argv);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
@ -1074,10 +1065,9 @@ static int enable_linger(int argc, char *argv[], void *userdata) {
static int terminate_user(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(argv);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
@ -1105,10 +1095,9 @@ static int terminate_user(int argc, char *argv[], void *userdata) {
static int kill_user(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(argv);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
@ -1144,10 +1133,9 @@ static int kill_user(int argc, char *argv[], void *userdata) {
static int attach(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(argv);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
@ -1169,10 +1157,9 @@ static int attach(int argc, char *argv[], void *userdata) {
static int flush_devices(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(argv);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
@ -1186,10 +1173,9 @@ static int flush_devices(int argc, char *argv[], void *userdata) {
static int lock_sessions(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(argv);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
@ -1208,10 +1194,9 @@ static int lock_sessions(int argc, char *argv[], void *userdata) {
static int terminate_seat(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(argv);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);

View File

@ -96,12 +96,11 @@ static void brightness_writer_reply(BrightnessWriter *w, int error) {
static int brightness_writer_fork(BrightnessWriter *w);
static int on_brightness_writer_exit(sd_event_source *s, const siginfo_t *si, void *userdata) {
BrightnessWriter *w = userdata;
BrightnessWriter *w = ASSERT_PTR(userdata);
int r;
assert(s);
assert(si);
assert(w);
assert(si->si_pid == w->child);
w->child = 0;

View File

@ -93,9 +93,8 @@ static void button_lid_switch_handle_action(Manager *manager, bool is_edge) {
}
static int button_recheck(sd_event_source *e, void *userdata) {
Button *b = userdata;
Button *b = ASSERT_PTR(userdata);
assert(b);
assert(b->lid_closed);
button_lid_switch_handle_action(b->manager, false);
@ -119,10 +118,9 @@ static int button_install_check_event_source(Button *b) {
}
static int long_press_of_power_key_handler(sd_event_source *e, uint64_t usec, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(e);
assert(m);
m->power_key_long_press_event_source = sd_event_source_unref(m->power_key_long_press_event_source);
@ -135,10 +133,9 @@ static int long_press_of_power_key_handler(sd_event_source *e, uint64_t usec, vo
}
static int long_press_of_reboot_key_handler(sd_event_source *e, uint64_t usec, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(e);
assert(m);
m->reboot_key_long_press_event_source = sd_event_source_unref(m->reboot_key_long_press_event_source);
@ -151,10 +148,9 @@ static int long_press_of_reboot_key_handler(sd_event_source *e, uint64_t usec, v
}
static int long_press_of_suspend_key_handler(sd_event_source *e, uint64_t usec, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(e);
assert(m);
m->suspend_key_long_press_event_source = sd_event_source_unref(m->suspend_key_long_press_event_source);
@ -167,10 +163,9 @@ static int long_press_of_suspend_key_handler(sd_event_source *e, uint64_t usec,
}
static int long_press_of_hibernate_key_handler(sd_event_source *e, uint64_t usec, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(e);
assert(m);
m->hibernate_key_long_press_event_source = sd_event_source_unref(m->hibernate_key_long_press_event_source);
@ -202,13 +197,12 @@ static void start_long_press(Manager *m, sd_event_source **e, sd_event_time_hand
}
static int button_dispatch(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
Button *b = userdata;
Button *b = ASSERT_PTR(userdata);
struct input_event ev;
ssize_t l;
assert(s);
assert(fd == b->fd);
assert(b);
l = read(b->fd, &ev, sizeof(ev));
if (l < 0)

View File

@ -464,14 +464,13 @@ int config_parse_n_autovts(
void *data,
void *userdata) {
unsigned *n = data;
unsigned *n = ASSERT_PTR(data);
unsigned o;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
r = safe_atou(rvalue, &o);
if (r < 0) {
@ -781,9 +780,7 @@ int manager_read_utmp(Manager *m) {
#if ENABLE_UTMP
static int manager_dispatch_utmp(sd_event_source *s, const struct inotify_event *event, void *userdata) {
Manager *m = userdata;
assert(m);
Manager *m = ASSERT_PTR(userdata);
/* If there's indication the file itself might have been removed or became otherwise unavailable, then let's
* reestablish the watch on whatever there's now. */

View File

@ -268,11 +268,10 @@ static int property_get_idle_hint(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(m);
return sd_bus_message_append(reply, "b", manager_get_idle_hint(m, NULL) > 0);
}
@ -286,12 +285,11 @@ static int property_get_idle_since_hint(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
dual_timestamp t = DUAL_TIMESTAMP_NULL;
assert(bus);
assert(reply);
assert(m);
manager_get_idle_hint(m, &t);
@ -307,12 +305,11 @@ static int property_get_inhibited(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
InhibitWhat w;
assert(bus);
assert(reply);
assert(m);
w = manager_inhibit_what(m, streq(property, "BlockInhibited") ? INHIBIT_BLOCK : INHIBIT_DELAY);
@ -328,12 +325,11 @@ static int property_get_preparing(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
bool b = false;
assert(bus);
assert(reply);
assert(m);
if (m->delayed_action) {
if (streq(property, "PreparingForShutdown"))
@ -354,12 +350,11 @@ static int property_get_scheduled_shutdown(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(m);
r = sd_bus_message_open_container(reply, 'r', "st");
if (r < 0)
@ -383,13 +378,12 @@ static BUS_DEFINE_PROPERTY_GET_REF(property_get_hashmap_size, "t", Hashmap *, (u
static int method_get_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *name;
Session *session;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &name);
if (r < 0)
@ -412,12 +406,11 @@ static int method_get_session(sd_bus_message *message, void *userdata, sd_bus_er
static int method_get_session_by_pid(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Session *session = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
pid_t pid;
int r;
assert(message);
assert(m);
assert_cc(sizeof(pid_t) == sizeof(uint32_t));
@ -450,13 +443,12 @@ static int method_get_session_by_pid(sd_bus_message *message, void *userdata, sd
static int method_get_user(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
uint32_t uid;
User *user;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "u", &uid);
if (r < 0)
@ -475,13 +467,12 @@ static int method_get_user(sd_bus_message *message, void *userdata, sd_bus_error
static int method_get_user_by_pid(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
User *user = NULL;
pid_t pid;
int r;
assert(message);
assert(m);
assert_cc(sizeof(pid_t) == sizeof(uint32_t));
@ -514,13 +505,12 @@ static int method_get_user_by_pid(sd_bus_message *message, void *userdata, sd_bu
static int method_get_seat(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *name;
Seat *seat;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &name);
if (r < 0)
@ -539,12 +529,11 @@ static int method_get_seat(sd_bus_message *message, void *userdata, sd_bus_error
static int method_list_sessions(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Session *session;
int r;
assert(message);
assert(m);
r = sd_bus_message_new_method_return(message, &reply);
if (r < 0)
@ -580,12 +569,11 @@ static int method_list_sessions(sd_bus_message *message, void *userdata, sd_bus_
static int method_list_users(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
User *user;
int r;
assert(message);
assert(m);
r = sd_bus_message_new_method_return(message, &reply);
if (r < 0)
@ -619,12 +607,11 @@ static int method_list_users(sd_bus_message *message, void *userdata, sd_bus_err
static int method_list_seats(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Seat *seat;
int r;
assert(message);
assert(m);
r = sd_bus_message_new_method_return(message, &reply);
if (r < 0)
@ -655,12 +642,11 @@ static int method_list_seats(sd_bus_message *message, void *userdata, sd_bus_err
static int method_list_inhibitors(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Inhibitor *inhibitor;
int r;
assert(message);
assert(m);
r = sd_bus_message_new_method_return(message, &reply);
if (r < 0)
@ -695,7 +681,7 @@ static int method_create_session(sd_bus_message *message, void *userdata, sd_bus
_cleanup_free_ char *id = NULL;
Session *session = NULL;
uint32_t audit_id = 0;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
User *user = NULL;
Seat *seat = NULL;
pid_t leader;
@ -707,7 +693,6 @@ static int method_create_session(sd_bus_message *message, void *userdata, sd_bus
int r;
assert(message);
assert(m);
assert_cc(sizeof(pid_t) == sizeof(uint32_t));
assert_cc(sizeof(uid_t) == sizeof(uint32_t));
@ -999,13 +984,12 @@ fail:
}
static int method_release_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Session *session;
const char *name;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &name);
if (r < 0)
@ -1023,13 +1007,12 @@ static int method_release_session(sd_bus_message *message, void *userdata, sd_bu
}
static int method_activate_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Session *session;
const char *name;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &name);
if (r < 0)
@ -1046,13 +1029,12 @@ static int method_activate_session(sd_bus_message *message, void *userdata, sd_b
static int method_activate_session_on_seat(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *session_name, *seat_name;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Session *session;
Seat *seat;
int r;
assert(message);
assert(m);
/* Same as ActivateSession() but refuses to work if the seat doesn't match */
@ -1086,13 +1068,12 @@ static int method_activate_session_on_seat(sd_bus_message *message, void *userda
}
static int method_lock_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Session *session;
const char *name;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &name);
if (r < 0)
@ -1106,11 +1087,10 @@ static int method_lock_session(sd_bus_message *message, void *userdata, sd_bus_e
}
static int method_lock_sessions(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = bus_verify_polkit_async(
message,
@ -1135,12 +1115,11 @@ static int method_lock_sessions(sd_bus_message *message, void *userdata, sd_bus_
static int method_kill_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *name;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Session *session;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &name);
if (r < 0)
@ -1154,13 +1133,12 @@ static int method_kill_session(sd_bus_message *message, void *userdata, sd_bus_e
}
static int method_kill_user(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
uint32_t uid;
User *user;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "u", &uid);
if (r < 0)
@ -1174,13 +1152,12 @@ static int method_kill_user(sd_bus_message *message, void *userdata, sd_bus_erro
}
static int method_terminate_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *name;
Session *session;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &name);
if (r < 0)
@ -1194,13 +1171,12 @@ static int method_terminate_session(sd_bus_message *message, void *userdata, sd_
}
static int method_terminate_user(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
uint32_t uid;
User *user;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "u", &uid);
if (r < 0)
@ -1214,13 +1190,12 @@ static int method_terminate_user(sd_bus_message *message, void *userdata, sd_bus
}
static int method_terminate_seat(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *name;
Seat *seat;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &name);
if (r < 0)
@ -1236,14 +1211,13 @@ static int method_terminate_seat(sd_bus_message *message, void *userdata, sd_bus
static int method_set_user_linger(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
_cleanup_free_ char *cc = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r, b, interactive;
struct passwd *pw;
const char *path;
uint32_t uid, auth_uid;
assert(message);
assert(m);
r = sd_bus_message_read(message, "ubb", &uid, &b, &interactive);
if (r < 0)
@ -1414,11 +1388,10 @@ static int flush_devices(Manager *m) {
static int method_attach_device(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *sysfs, *seat;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int interactive, r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "ssb", &seat, &sysfs, &interactive);
if (r < 0)
@ -1463,11 +1436,10 @@ static int method_attach_device(sd_bus_message *message, void *userdata, sd_bus_
}
static int method_flush_devices(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int interactive, r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "b", &interactive);
if (r < 0)
@ -1532,10 +1504,9 @@ static int bus_manager_log_shutdown(
}
static int lid_switch_ignore_handler(sd_event_source *e, uint64_t usec, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(e);
assert(m);
m->lid_switch_ignore_event_source = sd_event_source_unref(m->lid_switch_ignore_event_source);
return 0;
@ -1678,9 +1649,8 @@ static int manager_inhibit_timeout_handler(
uint64_t usec,
void *userdata) {
Manager *manager = userdata;
Manager *manager = ASSERT_PTR(userdata);
assert(manager);
assert(manager->inhibit_timeout_source == s);
return manager_dispatch_delayed(manager, true);
@ -2191,11 +2161,9 @@ static int manager_scheduled_shutdown_handler(
const HandleActionData *a = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
int r;
assert(m);
a = m->scheduled_shutdown_action;
assert(a);
@ -2233,7 +2201,7 @@ error:
}
static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
HandleAction handle;
const HandleActionData *a;
uint64_t elapse;
@ -2241,7 +2209,6 @@ static int method_schedule_shutdown(sd_bus_message *message, void *userdata, sd_
int r;
bool dry_run = false;
assert(m);
assert(message);
r = sd_bus_message_read(message, "st", &type, &elapse);
@ -2314,12 +2281,11 @@ fail:
}
static int method_cancel_scheduled_shutdown(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const HandleActionData *a;
bool cancelled;
int r;
assert(m);
assert(message);
cancelled = m->scheduled_shutdown_action
@ -2562,12 +2528,11 @@ static int method_set_reboot_parameter(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *arg;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &arg);
if (r < 0)
@ -2605,11 +2570,10 @@ static int method_can_reboot_parameter(
void *userdata,
sd_bus_error *error) {
_unused_ Manager *m = userdata;
_unused_ Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = detect_container();
if (r < 0)
@ -2667,12 +2631,11 @@ static int method_set_reboot_to_firmware_setup(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
bool use_efi;
int b, r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "b", &b);
if (r < 0)
@ -2737,11 +2700,10 @@ static int method_can_reboot_to_firmware_setup(
void *userdata,
sd_bus_error *error) {
_unused_ Manager *m = userdata;
_unused_ Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = getenv_bool("SYSTEMD_REBOOT_TO_FIRMWARE_SETUP");
if (r == -ENXIO) {
@ -2830,13 +2792,12 @@ static int method_set_reboot_to_boot_loader_menu(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
bool use_efi;
uint64_t x;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "t", &x);
if (r < 0)
@ -2914,11 +2875,10 @@ static int method_can_reboot_to_boot_loader_menu(
void *userdata,
sd_bus_error *error) {
_unused_ Manager *m = userdata;
_unused_ Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = getenv_bool("SYSTEMD_REBOOT_TO_BOOT_LOADER_MENU");
if (r == -ENXIO) {
@ -2960,13 +2920,12 @@ static int property_get_reboot_to_boot_loader_entry(
sd_bus_error *error) {
_cleanup_free_ char *v = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *x = NULL;
int r;
assert(bus);
assert(reply);
assert(m);
r = getenv_bool("SYSTEMD_REBOOT_TO_BOOT_LOADER_ENTRY");
if (r == -ENXIO) {
@ -3021,13 +2980,12 @@ static int method_set_reboot_to_boot_loader_entry(
void *userdata,
sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
bool use_efi;
const char *v;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &v);
if (r < 0)
@ -3109,11 +3067,10 @@ static int method_can_reboot_to_boot_loader_entry(
void *userdata,
sd_bus_error *error) {
_unused_ Manager *m = userdata;
_unused_ Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = getenv_bool("SYSTEMD_REBOOT_TO_BOOT_LOADER_ENTRY");
if (r == -ENXIO) {
@ -3155,13 +3112,12 @@ static int property_get_boot_loader_entries(
sd_bus_error *error) {
_cleanup_(boot_config_free) BootConfig config = BOOT_CONFIG_NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
size_t i;
int r;
assert(bus);
assert(reply);
assert(m);
r = boot_config_load_auto(&config, NULL, NULL);
if (r < 0 && r != -ENOKEY) /* don't complain if there's no GPT found */
@ -3192,12 +3148,11 @@ static int method_set_wall_message(
sd_bus_error *error) {
int r;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
char *wall_message;
int enable_wall_messages;
assert(message);
assert(m);
r = sd_bus_message_read(message, "sb", &wall_message, &enable_wall_messages);
if (r < 0)
@ -3242,7 +3197,7 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error
const char *who, *why, *what, *mode;
_cleanup_free_ char *id = NULL;
_cleanup_close_ int fifo_fd = -1;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
InhibitMode mm;
InhibitWhat w;
pid_t pid;
@ -3250,7 +3205,6 @@ static int method_inhibit(sd_bus_message *message, void *userdata, sd_bus_error
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "ssss", &what, &who, &why, &mode);
if (r < 0)
@ -3772,14 +3726,13 @@ static int session_jobs_reply(Session *s, uint32_t jid, const char *unit, const
int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *path, *result, *unit;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Session *session;
uint32_t id;
User *user;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "uoss", &id, &path, &unit, &result);
if (r < 0) {
@ -3831,13 +3784,12 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *path, *unit;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Session *session;
User *user;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "so", &unit, &path);
if (r < 0) {
@ -3858,14 +3810,13 @@ int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *er
int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *unit = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *path;
Session *session;
User *user;
int r;
assert(message);
assert(m);
path = sd_bus_message_get_path(message);
if (!path)
@ -3891,12 +3842,11 @@ int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_err
}
int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Session *session;
int b, r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "b", &b);
if (r < 0) {

View File

@ -277,11 +277,10 @@ int inhibitor_load(Inhibitor *i) {
}
static int inhibitor_dispatch_fifo(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
Inhibitor *i = userdata;
Inhibitor *i = ASSERT_PTR(userdata);
assert(s);
assert(fd == i->fifo_fd);
assert(i);
inhibitor_stop(i);
inhibitor_free(i);

View File

@ -33,11 +33,10 @@ static int property_get_active_session(
sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Seat *s = userdata;
Seat *s = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(s);
p = s->active ? session_bus_path(s->active) : strdup("/");
if (!p)
@ -55,12 +54,11 @@ static int property_get_sessions(
void *userdata,
sd_bus_error *error) {
Seat *s = userdata;
Seat *s = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(s);
r = sd_bus_message_open_container(reply, 'a', "(so)");
if (r < 0)
@ -95,11 +93,10 @@ static int property_get_idle_hint(
void *userdata,
sd_bus_error *error) {
Seat *s = userdata;
Seat *s = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(s);
return sd_bus_message_append(reply, "b", seat_get_idle_hint(s, NULL) > 0);
}
@ -113,14 +110,13 @@ static int property_get_idle_since_hint(
void *userdata,
sd_bus_error *error) {
Seat *s = userdata;
Seat *s = ASSERT_PTR(userdata);
dual_timestamp t;
uint64_t u;
int r;
assert(bus);
assert(reply);
assert(s);
r = seat_get_idle_hint(s, &t);
if (r < 0)
@ -132,11 +128,10 @@ static int property_get_idle_since_hint(
}
int bus_seat_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Seat *s = userdata;
Seat *s = ASSERT_PTR(userdata);
int r;
assert(message);
assert(s);
r = bus_verify_polkit_async(
message,
@ -160,13 +155,12 @@ int bus_seat_method_terminate(sd_bus_message *message, void *userdata, sd_bus_er
}
static int method_activate_session(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Seat *s = userdata;
Seat *s = ASSERT_PTR(userdata);
const char *name;
Session *session;
int r;
assert(message);
assert(s);
r = sd_bus_message_read(message, "s", &name);
if (r < 0)
@ -193,12 +187,11 @@ static int method_activate_session(sd_bus_message *message, void *userdata, sd_b
}
static int method_switch_to(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Seat *s = userdata;
Seat *s = ASSERT_PTR(userdata);
unsigned to;
int r;
assert(message);
assert(s);
r = sd_bus_message_read(message, "u", &to);
if (r < 0)
@ -221,11 +214,10 @@ static int method_switch_to(sd_bus_message *message, void *userdata, sd_bus_erro
}
static int method_switch_to_next(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Seat *s = userdata;
Seat *s = ASSERT_PTR(userdata);
int r;
assert(message);
assert(s);
r = check_polkit_chvt(message, s->manager, error);
if (r < 0)
@ -241,11 +233,10 @@ static int method_switch_to_next(sd_bus_message *message, void *userdata, sd_bus
}
static int method_switch_to_previous(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Seat *s = userdata;
Seat *s = ASSERT_PTR(userdata);
int r;
assert(message);
assert(s);
r = check_polkit_chvt(message, s->manager, error);
if (r < 0)
@ -263,7 +254,7 @@ static int method_switch_to_previous(sd_bus_message *message, void *userdata, sd
static int seat_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
_cleanup_free_ char *e = NULL;
sd_bus_message *message;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *p;
Seat *seat;
int r;
@ -272,7 +263,6 @@ static int seat_object_find(sd_bus *bus, const char *path, const char *interface
assert(path);
assert(interface);
assert(found);
assert(m);
p = startswith(path, "/org/freedesktop/login1/seat/");
if (!p)

View File

@ -36,11 +36,10 @@ static int property_get_user(
sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(s);
p = user_bus_path(s->user);
if (!p)
@ -58,11 +57,10 @@ static int property_get_name(
void *userdata,
sd_bus_error *error) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(s);
return sd_bus_message_append(reply, "s", s->user->user_record->user_name);
}
@ -77,11 +75,10 @@ static int property_get_seat(
sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(s);
p = s->seat ? seat_bus_path(s->seat) : strdup("/");
if (!p)
@ -104,11 +101,10 @@ static int property_get_idle_hint(
void *userdata,
sd_bus_error *error) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(s);
return sd_bus_message_append(reply, "b", session_get_idle_hint(s, NULL) > 0);
}
@ -122,14 +118,13 @@ static int property_get_idle_since_hint(
void *userdata,
sd_bus_error *error) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
dual_timestamp t = DUAL_TIMESTAMP_NULL;
uint64_t u;
int r;
assert(bus);
assert(reply);
assert(s);
r = session_get_idle_hint(s, &t);
if (r < 0)
@ -149,21 +144,19 @@ static int property_get_locked_hint(
void *userdata,
sd_bus_error *error) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(s);
return sd_bus_message_append(reply, "b", session_get_locked_hint(s) > 0);
}
int bus_session_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
int r;
assert(message);
assert(s);
r = bus_verify_polkit_async(
message,
@ -187,11 +180,10 @@ int bus_session_method_terminate(sd_bus_message *message, void *userdata, sd_bus
}
int bus_session_method_activate(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
int r;
assert(message);
assert(s);
r = check_polkit_chvt(message, s->manager, error);
if (r < 0)
@ -207,11 +199,10 @@ int bus_session_method_activate(sd_bus_message *message, void *userdata, sd_bus_
}
int bus_session_method_lock(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
int r;
assert(message);
assert(s);
r = bus_verify_polkit_async(
message,
@ -236,12 +227,11 @@ int bus_session_method_lock(sd_bus_message *message, void *userdata, sd_bus_erro
static int method_set_idle_hint(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
uid_t uid;
int r, b;
assert(message);
assert(s);
r = sd_bus_message_read(message, "b", &b);
if (r < 0)
@ -269,12 +259,11 @@ static int method_set_idle_hint(sd_bus_message *message, void *userdata, sd_bus_
static int method_set_locked_hint(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
uid_t uid;
int r, b;
assert(message);
assert(s);
r = sd_bus_message_read(message, "b", &b);
if (r < 0)
@ -297,14 +286,13 @@ static int method_set_locked_hint(sd_bus_message *message, void *userdata, sd_bu
}
int bus_session_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
const char *swho;
int32_t signo;
KillWho who;
int r;
assert(message);
assert(s);
r = sd_bus_message_read(message, "si", &swho, &signo);
if (r < 0)
@ -344,12 +332,11 @@ int bus_session_method_kill(sd_bus_message *message, void *userdata, sd_bus_erro
static int method_take_control(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
int r, force;
uid_t uid;
assert(message);
assert(s);
r = sd_bus_message_read(message, "b", &force);
if (r < 0)
@ -374,10 +361,9 @@ static int method_take_control(sd_bus_message *message, void *userdata, sd_bus_e
}
static int method_release_control(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
assert(message);
assert(s);
if (!session_is_controller(s, sd_bus_message_get_sender(message)))
return sd_bus_error_set(error, BUS_ERROR_NOT_IN_CONTROL, "You are not in control of this session");
@ -388,13 +374,12 @@ static int method_release_control(sd_bus_message *message, void *userdata, sd_bu
}
static int method_set_type(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
const char *t;
SessionType type;
int r;
assert(message);
assert(s);
r = sd_bus_message_read(message, "s", &t);
if (r < 0)
@ -438,14 +423,13 @@ static int method_set_display(sd_bus_message *message, void *userdata, sd_bus_er
}
static int method_take_device(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
uint32_t major, minor;
SessionDevice *sd;
dev_t dev;
int r;
assert(message);
assert(s);
r = sd_bus_message_read(message, "uu", &major, &minor);
if (r < 0)
@ -488,14 +472,13 @@ error:
}
static int method_release_device(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
uint32_t major, minor;
SessionDevice *sd;
dev_t dev;
int r;
assert(message);
assert(s);
r = sd_bus_message_read(message, "uu", &major, &minor);
if (r < 0)
@ -519,14 +502,13 @@ static int method_release_device(sd_bus_message *message, void *userdata, sd_bus
}
static int method_pause_device_complete(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
uint32_t major, minor;
SessionDevice *sd;
dev_t dev;
int r;
assert(message);
assert(s);
r = sd_bus_message_read(message, "uu", &major, &minor);
if (r < 0)
@ -552,13 +534,12 @@ static int method_set_brightness(sd_bus_message *message, void *userdata, sd_bus
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
_cleanup_(sd_device_unrefp) sd_device *d = NULL;
const char *subsystem, *name, *seat;
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
uint32_t brightness;
uid_t uid;
int r;
assert(message);
assert(s);
r = sd_bus_message_read(message, "ssu", &subsystem, &name, &brightness);
if (r < 0)
@ -602,7 +583,7 @@ static int method_set_brightness(sd_bus_message *message, void *userdata, sd_bus
static int session_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
_cleanup_free_ char *e = NULL;
sd_bus_message *message;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Session *session;
const char *p;
int r;
@ -611,7 +592,6 @@ static int session_object_find(sd_bus *bus, const char *path, const char *interf
assert(path);
assert(interface);
assert(found);
assert(m);
p = startswith(path, "/org/freedesktop/login1/session/");
if (!p)

View File

@ -941,10 +941,9 @@ int session_finalize(Session *s) {
}
static int release_timeout_callback(sd_event_source *es, uint64_t usec, void *userdata) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
assert(es);
assert(s);
session_stop(s, /* force = */ false);
return 0;
@ -1133,9 +1132,8 @@ int session_set_display(Session *s, const char *display) {
}
static int session_dispatch_fifo(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
assert(s);
assert(s->fifo_fd == fd);
/* EOF on the FIFO means the session died abnormally. */
@ -1426,10 +1424,9 @@ static void session_release_controller(Session *s, bool notify) {
}
static int on_bus_track(sd_bus_track *track, void *userdata) {
Session *s = userdata;
Session *s = ASSERT_PTR(userdata);
assert(track);
assert(s);
session_drop_controller(s);

View File

@ -26,11 +26,10 @@ static int property_get_uid(
void *userdata,
sd_bus_error *error) {
User *u = userdata;
User *u = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(u);
return sd_bus_message_append(reply, "u", (uint32_t) u->user_record->uid);
}
@ -44,11 +43,10 @@ static int property_get_gid(
void *userdata,
sd_bus_error *error) {
User *u = userdata;
User *u = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(u);
return sd_bus_message_append(reply, "u", (uint32_t) u->user_record->gid);
}
@ -62,11 +60,10 @@ static int property_get_name(
void *userdata,
sd_bus_error *error) {
User *u = userdata;
User *u = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(u);
return sd_bus_message_append(reply, "s", u->user_record->user_name);
}
@ -83,11 +80,10 @@ static int property_get_display(
sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
User *u = userdata;
User *u = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(u);
p = u->display ? session_bus_path(u->display) : strdup("/");
if (!p)
@ -105,12 +101,11 @@ static int property_get_sessions(
void *userdata,
sd_bus_error *error) {
User *u = userdata;
User *u = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(u);
r = sd_bus_message_open_container(reply, 'a', "(so)");
if (r < 0)
@ -141,11 +136,10 @@ static int property_get_idle_hint(
void *userdata,
sd_bus_error *error) {
User *u = userdata;
User *u = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(u);
return sd_bus_message_append(reply, "b", user_get_idle_hint(u, NULL) > 0);
}
@ -159,13 +153,12 @@ static int property_get_idle_since_hint(
void *userdata,
sd_bus_error *error) {
User *u = userdata;
User *u = ASSERT_PTR(userdata);
dual_timestamp t = DUAL_TIMESTAMP_NULL;
uint64_t k;
assert(bus);
assert(reply);
assert(u);
(void) user_get_idle_hint(u, &t);
k = streq(property, "IdleSinceHint") ? t.realtime : t.monotonic;
@ -182,12 +175,11 @@ static int property_get_linger(
void *userdata,
sd_bus_error *error) {
User *u = userdata;
User *u = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(reply);
assert(u);
r = user_check_linger_file(u);
@ -195,11 +187,10 @@ static int property_get_linger(
}
int bus_user_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error) {
User *u = userdata;
User *u = ASSERT_PTR(userdata);
int r;
assert(message);
assert(u);
r = bus_verify_polkit_async(
message,
@ -223,12 +214,11 @@ int bus_user_method_terminate(sd_bus_message *message, void *userdata, sd_bus_er
}
int bus_user_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error) {
User *u = userdata;
User *u = ASSERT_PTR(userdata);
int32_t signo;
int r;
assert(message);
assert(u);
r = bus_verify_polkit_async(
message,
@ -259,7 +249,7 @@ int bus_user_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *
}
static int user_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
uid_t uid;
User *user;
int r;
@ -268,7 +258,6 @@ static int user_object_find(sd_bus *bus, const char *path, const char *interface
assert(path);
assert(interface);
assert(found);
assert(m);
if (streq(path, "/org/freedesktop/login1/user/self")) {
sd_bus_message *message;

View File

@ -357,12 +357,11 @@ static void user_start_service(User *u) {
}
static int update_slice_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
_cleanup_(user_record_unrefp) UserRecord *ur = userdata;
_cleanup_(user_record_unrefp) UserRecord *ur = ASSERT_PTR(userdata);
const sd_bus_error *e;
int r;
assert(m);
assert(ur);
e = sd_bus_message_get_error(m);
if (e) {
@ -819,9 +818,8 @@ void user_elect_display(User *u) {
}
static int user_stop_timeout_callback(sd_event_source *es, uint64_t usec, void *userdata) {
User *u = userdata;
User *u = ASSERT_PTR(userdata);
assert(u);
user_add_to_gc_queue(u);
return 0;
@ -893,13 +891,12 @@ int config_parse_tmpfs_size(
void *data,
void *userdata) {
uint64_t *sz = data;
uint64_t *sz = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
/* First, try to parse as percentage */
r = parse_permyriad(rvalue);

View File

@ -540,9 +540,8 @@ static int manager_enumerate_inhibitors(Manager *m) {
}
static int manager_dispatch_seat_udev(sd_device_monitor *monitor, sd_device *device, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(device);
manager_process_seat_device(m, device);
@ -550,9 +549,8 @@ static int manager_dispatch_seat_udev(sd_device_monitor *monitor, sd_device *dev
}
static int manager_dispatch_device_udev(sd_device_monitor *monitor, sd_device *device, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(device);
manager_process_seat_device(m, device);
@ -560,10 +558,9 @@ static int manager_dispatch_device_udev(sd_device_monitor *monitor, sd_device *d
}
static int manager_dispatch_vcsa_udev(sd_device_monitor *monitor, sd_device *device, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *name;
assert(m);
assert(device);
/* Whenever a VCSA device is removed try to reallocate our
@ -578,9 +575,8 @@ static int manager_dispatch_vcsa_udev(sd_device_monitor *monitor, sd_device *dev
}
static int manager_dispatch_button_udev(sd_device_monitor *monitor, sd_device *device, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(device);
manager_process_button_device(m, device);
@ -588,9 +584,8 @@ static int manager_dispatch_button_udev(sd_device_monitor *monitor, sd_device *d
}
static int manager_dispatch_console(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(m);
assert(m->seat0);
assert(m->console_active_fd == fd);
@ -943,13 +938,11 @@ static void manager_gc(Manager *m, bool drop_not_started) {
}
static int manager_dispatch_idle_action(sd_event_source *s, uint64_t t, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
struct dual_timestamp since;
usec_t n, elapse;
int r;
assert(m);
if (m->idle_action == HANDLE_IGNORE ||
m->idle_action_usec <= 0)
return 0;

View File

@ -32,13 +32,12 @@ int bus_image_method_remove(
sd_bus_error *error) {
_cleanup_close_pair_ int errno_pipe_fd[2] = { -1, -1 };
Image *image = userdata;
Image *image = ASSERT_PTR(userdata);
Manager *m = image->userdata;
pid_t child;
int r;
assert(message);
assert(image);
if (m->n_operations >= OPERATIONS_MAX)
return sd_bus_error_set(error, SD_BUS_ERROR_LIMITS_EXCEEDED, "Too many ongoing operations.");
@ -99,13 +98,12 @@ int bus_image_method_rename(
void *userdata,
sd_bus_error *error) {
Image *image = userdata;
Image *image = ASSERT_PTR(userdata);
Manager *m = image->userdata;
const char *new_name;
int r;
assert(message);
assert(image);
r = sd_bus_message_read(message, "s", &new_name);
if (r < 0)
@ -148,15 +146,13 @@ int bus_image_method_clone(
sd_bus_error *error) {
_cleanup_close_pair_ int errno_pipe_fd[2] = { -1, -1 };
Image *image = userdata;
Manager *m = image->userdata;
Image *image = ASSERT_PTR(userdata);
Manager *m = ASSERT_PTR(image->userdata);
const char *new_name;
int r, read_only;
pid_t child;
assert(message);
assert(image);
assert(m);
if (m->n_operations >= OPERATIONS_MAX)
return sd_bus_error_set(error, SD_BUS_ERROR_LIMITS_EXCEEDED, "Too many ongoing operations.");
@ -389,10 +385,9 @@ int bus_image_method_get_os_release(
}
static int image_flush_cache(sd_event_source *s, void *userdata) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
assert(s);
assert(m);
hashmap_clear(m->image_cache);
return 0;

View File

@ -49,11 +49,10 @@ static int property_get_netif(
void *userdata,
sd_bus_error *error) {
Machine *m = userdata;
Machine *m = ASSERT_PTR(userdata);
assert(bus);
assert(reply);
assert(m);
assert_cc(sizeof(int) == sizeof(int32_t));
@ -61,11 +60,10 @@ static int property_get_netif(
}
int bus_machine_method_unregister(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Machine *m = userdata;
Machine *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
const char *details[] = {
"machine", m->name,
@ -95,11 +93,10 @@ int bus_machine_method_unregister(sd_bus_message *message, void *userdata, sd_bu
}
int bus_machine_method_terminate(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Machine *m = userdata;
Machine *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
const char *details[] = {
"machine", m->name,
@ -129,14 +126,13 @@ int bus_machine_method_terminate(sd_bus_message *message, void *userdata, sd_bus
}
int bus_machine_method_kill(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Machine *m = userdata;
Machine *m = ASSERT_PTR(userdata);
const char *swho;
int32_t signo;
KillWho who;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "si", &swho, &signo);
if (r < 0)
@ -182,11 +178,10 @@ int bus_machine_method_kill(sd_bus_message *message, void *userdata, sd_bus_erro
int bus_machine_method_get_addresses(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Machine *m = userdata;
Machine *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
r = sd_bus_message_new_method_return(message, &reply);
if (r < 0)
@ -360,11 +355,10 @@ int bus_machine_method_get_addresses(sd_bus_message *message, void *userdata, sd
int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
Machine *m = userdata;
Machine *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
switch (m->class) {
@ -443,11 +437,10 @@ int bus_machine_method_open_pty(sd_bus_message *message, void *userdata, sd_bus_
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_free_ char *pty_name = NULL;
_cleanup_close_ int master = -1;
Machine *m = userdata;
Machine *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
const char *details[] = {
"machine", m->name,
@ -534,12 +527,11 @@ int bus_machine_method_open_login(sd_bus_message *message, void *userdata, sd_bu
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *allocated_bus = NULL;
_cleanup_close_ int master = -1;
sd_bus *container_bus = NULL;
Machine *m = userdata;
Machine *m = ASSERT_PTR(userdata);
const char *p, *getty;
int r;
assert(message);
assert(m);
const char *details[] = {
"machine", m->name,
@ -598,12 +590,11 @@ int bus_machine_method_open_shell(sd_bus_message *message, void *userdata, sd_bu
sd_bus *container_bus = NULL;
_cleanup_close_ int master = -1, slave = -1;
_cleanup_strv_free_ char **env = NULL, **args_wire = NULL, **args = NULL;
Machine *m = userdata;
Machine *m = ASSERT_PTR(userdata);
const char *p, *unit, *user, *path, *description, *utmp_id;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "ss", &user, &path);
if (r < 0)
@ -834,12 +825,11 @@ int bus_machine_method_open_shell(sd_bus_message *message, void *userdata, sd_bu
int bus_machine_method_bind_mount(sd_bus_message *message, void *userdata, sd_bus_error *error) {
int read_only, make_file_or_directory;
const char *dest, *src, *propagate_directory;
Machine *m = userdata;
Machine *m = ASSERT_PTR(userdata);
uid_t uid;
int r;
assert(message);
assert(m);
if (m->class != MACHINE_CONTAINER)
return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Bind mounting is only supported on container machines.");
@ -901,14 +891,13 @@ int bus_machine_method_copy(sd_bus_message *message, void *userdata, sd_bus_erro
_cleanup_close_pair_ int errno_pipe_fd[2] = { -1, -1 };
CopyFlags copy_flags = COPY_REFLINK|COPY_MERGE|COPY_HARDLINKS;
_cleanup_close_ int hostfd = -1;
Machine *m = userdata;
Machine *m = ASSERT_PTR(userdata);
bool copy_from;
pid_t child;
uid_t uid_shift;
int r;
assert(message);
assert(m);
if (m->manager->n_operations >= OPERATIONS_MAX)
return sd_bus_error_set(error, SD_BUS_ERROR_LIMITS_EXCEEDED, "Too many ongoing copies.");
@ -1060,11 +1049,10 @@ int bus_machine_method_copy(sd_bus_message *message, void *userdata, sd_bus_erro
int bus_machine_method_open_root_directory(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_close_ int fd = -1;
Machine *m = userdata;
Machine *m = ASSERT_PTR(userdata);
int r;
assert(message);
assert(m);
const char *details[] = {
"machine", m->name,
@ -1151,12 +1139,11 @@ int bus_machine_method_open_root_directory(sd_bus_message *message, void *userda
}
int bus_machine_method_get_uid_shift(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Machine *m = userdata;
Machine *m = ASSERT_PTR(userdata);
uid_t shift = 0;
int r;
assert(message);
assert(m);
/* You wonder why this is a method and not a property? Well, properties are not supposed to return errors, but
* we kinda have to for this. */
@ -1177,7 +1164,7 @@ int bus_machine_method_get_uid_shift(sd_bus_message *message, void *userdata, sd
}
static int machine_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Machine *machine;
int r;
@ -1185,7 +1172,6 @@ static int machine_object_find(sd_bus *bus, const char *path, const char *interf
assert(path);
assert(interface);
assert(found);
assert(m);
if (streq(path, "/org/freedesktop/machine1/machine/self")) {
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;

View File

@ -264,11 +264,9 @@ static int list_machines(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(table_unrefp) Table *table = NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
pager_open(arg_pager_flags);
r = bus_call_method(bus, bus_machine_mgr, "ListMachines", &error, &reply, NULL);
@ -343,11 +341,9 @@ static int list_images(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(table_unrefp) Table *table = NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
pager_open(arg_pager_flags);
r = bus_call_method(bus, bus_machine_mgr, "ListImages", &error, &reply, NULL);
@ -694,11 +690,9 @@ static int show_machine(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
bool properties, new_line = false;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r = 0;
assert(bus);
properties = !strstr(argv[0], "status");
pager_open(arg_pager_flags);
@ -993,11 +987,9 @@ static int show_image(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
bool properties, new_line = false;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r = 0;
assert(bus);
properties = !strstr(argv[0], "status");
pager_open(arg_pager_flags);
@ -1037,11 +1029,9 @@ static int show_image(int argc, char *argv[], void *userdata) {
static int kill_machine(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
if (!arg_kill_whom)
@ -1078,11 +1068,9 @@ static int poweroff_machine(int argc, char *argv[], void *userdata) {
static int terminate_machine(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
for (int i = 1; i < argc; i++) {
@ -1106,12 +1094,10 @@ static int copy_files(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *abs_host_path = NULL;
char *dest, *host_path, *container_path;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
bool copy_from;
int r;
assert(bus);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
copy_from = streq(argv[0], "copy-from");
@ -1160,11 +1146,9 @@ static int copy_files(int argc, char *argv[], void *userdata) {
static int bind_mount(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_call_method(
@ -1303,11 +1287,9 @@ static int login_machine(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_slot_unrefp) sd_bus_slot *slot = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
int master = -1, r;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
const char *match, *machine;
assert(bus);
if (!strv_isempty(arg_setenv) || arg_uid)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"--setenv= and --uid= are not supported for 'login'. Use 'shell' instead.");
@ -1357,12 +1339,10 @@ static int shell_machine(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_slot_unrefp) sd_bus_slot *slot = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
int master = -1, r;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
const char *match, *machine, *path;
_cleanup_free_ char *uid = NULL;
assert(bus);
if (!IN_SET(arg_transport, BUS_TRANSPORT_LOCAL, BUS_TRANSPORT_MACHINE))
return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP),
"Shell only supported on local machines.");
@ -1433,11 +1413,9 @@ static int shell_machine(int argc, char *argv[], void *userdata) {
}
static int remove_image(int argc, char *argv[], void *userdata) {
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
for (int i = 1; i < argc; i++) {
@ -1463,11 +1441,9 @@ static int remove_image(int argc, char *argv[], void *userdata) {
static int rename_image(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_call_method(
@ -1486,11 +1462,9 @@ static int rename_image(int argc, char *argv[], void *userdata) {
static int clone_image(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
r = bus_message_new_method_call(bus, &m, bus_machine_mgr, "CloneImage");
@ -1511,11 +1485,9 @@ static int clone_image(int argc, char *argv[], void *userdata) {
static int read_only_image(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int b = true, r;
assert(bus);
if (argc > 2) {
b = parse_boolean(argv[2]);
if (b < 0)
@ -1571,11 +1543,9 @@ static int make_service_name(const char *name, char **ret) {
static int start_machine(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(bus_wait_for_jobs_freep) BusWaitForJobs *w = NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
ask_password_agent_open_if_enabled(arg_transport, arg_ask_password);
@ -1632,11 +1602,9 @@ static int enable_machine(int argc, char *argv[], void *userdata) {
UnitFileChange *changes = NULL;
size_t n_changes = 0;
const char *method = NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
method = streq(argv[0], "enable") ? "EnableUnitFiles" : "DisableUnitFiles";
@ -1834,11 +1802,9 @@ static int import_tar(int argc, char *argv[], void *userdata) {
_cleanup_free_ char *ll = NULL, *fn = NULL;
const char *local = NULL, *path = NULL;
_cleanup_close_ int fd = -1;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
if (argc >= 2)
path = empty_or_dash_to_null(argv[1]);
@ -1897,11 +1863,9 @@ static int import_raw(int argc, char *argv[], void *userdata) {
_cleanup_free_ char *ll = NULL, *fn = NULL;
const char *local = NULL, *path = NULL;
_cleanup_close_ int fd = -1;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
if (argc >= 2)
path = empty_or_dash_to_null(argv[1]);
@ -1960,11 +1924,9 @@ static int import_fs(int argc, char *argv[], void *userdata) {
const char *local = NULL, *path = NULL;
_cleanup_free_ char *fn = NULL;
_cleanup_close_ int fd = -1;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
if (argc >= 2)
path = empty_or_dash_to_null(argv[1]);
@ -2028,11 +1990,9 @@ static int export_tar(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_close_ int fd = -1;
const char *local = NULL, *path = NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
local = argv[1];
if (!hostname_is_valid(local, 0))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
@ -2070,11 +2030,9 @@ static int export_raw(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_close_ int fd = -1;
const char *local = NULL, *path = NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
local = argv[1];
if (!hostname_is_valid(local, 0))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
@ -2112,11 +2070,9 @@ static int pull_tar(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *l = NULL, *ll = NULL;
const char *local, *remote;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
remote = argv[1];
if (!http_url_is_valid(remote) && !file_url_is_valid(remote))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
@ -2168,11 +2124,9 @@ static int pull_raw(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *l = NULL, *ll = NULL;
const char *local, *remote;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
remote = argv[1];
if (!http_url_is_valid(remote) && !file_url_is_valid(remote))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
@ -2329,11 +2283,9 @@ static int list_transfers(int argc, char *argv[], void *userdata) {
static int cancel_transfer(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus *bus = userdata;
sd_bus *bus = ASSERT_PTR(userdata);
int r;
assert(bus);
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
for (int i = 1; i < argc; i++) {

View File

@ -89,13 +89,12 @@ static int property_get_pool_limit(
static int method_get_machine(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Machine *machine;
const char *name;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &name);
if (r < 0)
@ -114,12 +113,11 @@ static int method_get_machine(sd_bus_message *message, void *userdata, sd_bus_er
static int method_get_image(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
_unused_ Manager *m = userdata;
_unused_ Manager *m = ASSERT_PTR(userdata);
const char *name;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "s", &name);
if (r < 0)
@ -140,13 +138,12 @@ static int method_get_image(sd_bus_message *message, void *userdata, sd_bus_erro
static int method_get_machine_by_pid(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Machine *machine = NULL;
pid_t pid;
int r;
assert(message);
assert(m);
assert_cc(sizeof(pid_t) == sizeof(uint32_t));
@ -184,12 +181,11 @@ static int method_get_machine_by_pid(sd_bus_message *message, void *userdata, sd
static int method_list_machines(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Machine *machine;
int r;
assert(message);
assert(m);
r = sd_bus_message_new_method_return(message, &reply);
if (r < 0)
@ -346,12 +342,11 @@ fail:
}
static int method_create_machine_internal(sd_bus_message *message, bool read_network, void *userdata, sd_bus_error *error) {
Manager *manager = userdata;
Manager *manager = ASSERT_PTR(userdata);
Machine *m = NULL;
int r;
assert(message);
assert(manager);
r = method_create_or_register_machine(manager, message, read_network, &m, error);
if (r < 0)
@ -382,13 +377,12 @@ static int method_create_machine(sd_bus_message *message, void *userdata, sd_bus
}
static int method_register_machine_internal(sd_bus_message *message, bool read_network, void *userdata, sd_bus_error *error) {
Manager *manager = userdata;
Manager *manager = ASSERT_PTR(userdata);
_cleanup_free_ char *p = NULL;
Machine *m = NULL;
int r;
assert(message);
assert(manager);
r = method_create_or_register_machine(manager, message, read_network, &m, error);
if (r < 0)
@ -470,12 +464,11 @@ static int method_get_machine_os_release(sd_bus_message *message, void *userdata
static int method_list_images(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_hashmap_free_ Hashmap *images = NULL;
_unused_ Manager *m = userdata;
_unused_ Manager *m = ASSERT_PTR(userdata);
Image *image;
int r;
assert(message);
assert(m);
images = hashmap_new(&image_hash_ops);
if (!images)
@ -1226,13 +1219,12 @@ const BusObjectImplementation manager_object = {
int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *path, *result, *unit;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Machine *machine;
uint32_t id;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "uoss", &id, &path, &unit, &result);
if (r < 0) {
@ -1269,12 +1261,11 @@ int match_job_removed(sd_bus_message *message, void *userdata, sd_bus_error *err
int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *unit = NULL;
const char *path;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Machine *machine;
int r;
assert(message);
assert(m);
path = sd_bus_message_get_path(message);
if (!path)
@ -1298,12 +1289,11 @@ int match_properties_changed(sd_bus_message *message, void *userdata, sd_bus_err
int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *error) {
const char *path, *unit;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Machine *machine;
int r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "so", &unit, &path);
if (r < 0) {
@ -1320,12 +1310,11 @@ int match_unit_removed(sd_bus_message *message, void *userdata, sd_bus_error *er
}
int match_reloading(sd_bus_message *message, void *userdata, sd_bus_error *error) {
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
Machine *machine;
int b, r;
assert(message);
assert(m);
r = sd_bus_message_read(message, "b", &b);
if (r < 0) {

View File

@ -150,12 +150,11 @@ static int vl_method_get_user_record(Varlink *link, JsonVariant *parameters, Var
};
_cleanup_free_ char *found_name = NULL, *found_real_name = NULL;
uid_t found_uid = UID_INVALID, uid;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *un;
int r;
assert(parameters);
assert(m);
r = json_dispatch(parameters, dispatch_table, NULL, 0, &p);
if (r < 0)
@ -316,12 +315,11 @@ static int vl_method_get_group_record(Varlink *link, JsonVariant *parameters, Va
};
_cleanup_free_ char *found_name = NULL, *found_description = NULL;
uid_t found_gid = GID_INVALID, gid;
Manager *m = userdata;
Manager *m = ASSERT_PTR(userdata);
const char *gn;
int r;
assert(parameters);
assert(m);
r = json_dispatch(parameters, dispatch_table, NULL, 0, &p);
if (r < 0)

View File

@ -10,10 +10,9 @@
static int operation_done(sd_event_source *s, const siginfo_t *si, void *userdata) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
Operation *o = userdata;
Operation *o = ASSERT_PTR(userdata);
int r;
assert(o);
assert(si);
log_debug("Operating " PID_FMT " is now complete with code=%s status=%i",

View File

@ -1004,10 +1004,9 @@ static int parse_cmdline_ifname_policy(Context *context, const char *key, const
}
int parse_cmdline_item(const char *key, const char *value, void *data) {
Context *context = data;
Context *context = ASSERT_PTR(data);
assert(key);
assert(data);
if (streq(key, "ip"))
return parse_cmdline_ip(context, key, value);

View File

@ -157,7 +157,7 @@ int config_parse_ip_protocol(
void *data,
void *userdata) {
uint8_t *ret = data;
uint8_t *ret = ASSERT_PTR(data);
unsigned protocol;
/* linux/fou.h defines the netlink field as one byte, so we need to reject protocols numbers that
* don't fit in one byte. */
@ -167,7 +167,6 @@ int config_parse_ip_protocol(
assert(section);
assert(lvalue);
assert(rvalue);
assert(data);
r = parse_ip_protocol(rvalue);
if (r >= 0)
@ -204,14 +203,13 @@ int config_parse_fou_tunnel_address(
void *data,
void *userdata) {
union in_addr_union *addr = data;
union in_addr_union *addr = ASSERT_PTR(data);
FouTunnel *t = userdata;
int r, *f;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
if (streq(lvalue, "Local"))
f = &t->local_family;

View File

@ -119,13 +119,12 @@ int config_parse_ipoib_pkey(
void *data,
void *userdata) {
uint16_t u, *pkey = data;
uint16_t u, *pkey = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
if (isempty(rvalue)) {
*pkey = 0; /* 0 means unset. */

View File

@ -481,15 +481,13 @@ int config_parse_l2tp_tunnel_local_address(
_cleanup_free_ char *addr_or_type = NULL, *ifname = NULL;
L2tpLocalAddressType type;
L2tpTunnel *t = userdata;
const char *p = rvalue;
L2tpTunnel *t = ASSERT_PTR(userdata);
const char *p = ASSERT_PTR(rvalue);
union in_addr_union a;
int r, f;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(t);
if (isempty(rvalue)) {
t->local_ifname = mfree(t->local_ifname);
@ -575,14 +573,13 @@ int config_parse_l2tp_tunnel_remote_address(
void *data,
void *userdata) {
L2tpTunnel *t = userdata;
L2tpTunnel *t = ASSERT_PTR(userdata);
union in_addr_union a;
int r, f;
assert(filename);
assert(lvalue);
assert(rvalue);
assert(t);
if (isempty(rvalue)) {
t->remote = IN_ADDR_NULL;

View File

@ -84,7 +84,7 @@ int config_parse_macvlan_broadcast_queue_size(
void *data,
void *userdata) {
MacVlan *m = userdata;
MacVlan *m = ASSERT_PTR(userdata);
uint32_t v;
int r;
@ -93,7 +93,6 @@ int config_parse_macvlan_broadcast_queue_size(
assert(lvalue);
assert(rvalue);
assert(data);
assert(userdata);
if (isempty(rvalue)) {
m->bc_queue_length = UINT32_MAX;

View File

@ -902,11 +902,10 @@ int config_parse_netdev_kind(
void *data,
void *userdata) {
NetDevKind k, *kind = data;
NetDevKind k, *kind = ASSERT_PTR(data);
assert(filename);
assert(rvalue);
assert(data);
k = netdev_kind_from_string(rvalue);
if (k < 0) {
@ -938,10 +937,9 @@ int config_parse_netdev_hw_addr(
void *data,
void *userdata) {
struct hw_addr_data *hw_addr = data;
struct hw_addr_data *hw_addr = ASSERT_PTR(data);
assert(rvalue);
assert(data);
if (streq(rvalue, "none")) {
*hw_addr = HW_ADDR_NONE;

Some files were not shown because too many files have changed in this diff Show More