summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/analyze/analyze-condition.c4
-rw-r--r--src/analyze/analyze-security.c12
-rw-r--r--src/analyze/analyze-verify-util.c3
-rw-r--r--src/basic/env-file.c4
-rw-r--r--src/basic/hashmap.c3
-rw-r--r--src/basic/io-util.c6
-rw-r--r--src/basic/path-util.c4
-rw-r--r--src/basic/siphash24.c3
-rw-r--r--src/basic/time-util.c3
-rw-r--r--src/boot/efi/efi-string.c3
-rw-r--r--src/busctl/busctl-introspect.c3
-rw-r--r--src/busctl/busctl.c7
-rw-r--r--src/core/cgroup.c9
-rw-r--r--src/core/core-varlink.c16
-rw-r--r--src/core/dbus-cgroup.c35
-rw-r--r--src/core/dbus-execute.c99
-rw-r--r--src/core/dbus-job.c21
-rw-r--r--src/core/dbus-kill.c4
-rw-r--r--src/core/dbus-manager.c169
-rw-r--r--src/core/dbus-path.c3
-rw-r--r--src/core/dbus-scope.c3
-rw-r--r--src/core/dbus-service.c6
-rw-r--r--src/core/dbus-timer.c9
-rw-r--r--src/core/dbus-unit.c87
-rw-r--r--src/core/dbus.c30
-rw-r--r--src/core/execute.c3
-rw-r--r--src/core/job.c3
-rw-r--r--src/core/load-fragment.c242
-rw-r--r--src/core/manager.c30
-rw-r--r--src/core/mount.c7
-rw-r--r--src/core/service.c10
-rw-r--r--src/core/socket.c3
-rw-r--r--src/core/swap.c3
-rw-r--r--src/core/unit.c13
-rw-r--r--src/cryptsetup/cryptsetup-tokens/luks2-pkcs11.c3
-rw-r--r--src/fundamental/sha256.c3
-rw-r--r--src/fuzz/fuzz-varlink.c3
-rw-r--r--src/home/homed-conf.c3
-rw-r--r--src/home/homed-home-bus.c58
-rw-r--r--src/home/homed-home.c12
-rw-r--r--src/home/homed-manager-bus.c43
-rw-r--r--src/home/homed-manager.c20
-rw-r--r--src/home/homed-varlink.c9
-rw-r--r--src/home/homework-luks.c4
-rw-r--r--src/home/homework-pkcs11.c3
-rw-r--r--src/hostname/hostnamed.c21
-rw-r--r--src/import/curl-util.c12
-rw-r--r--src/import/import-fs.c7
-rw-r--r--src/import/import-raw.c3
-rw-r--r--src/import/importd.c33
-rw-r--r--src/import/pull-job.c13
-rw-r--r--src/journal-remote/journal-gatewayd.c19
-rw-r--r--src/journal-remote/journal-remote-main.c4
-rw-r--r--src/journal-remote/journal-upload-journal.c7
-rw-r--r--src/journal-remote/journal-upload.c17
-rw-r--r--src/journal/journald-kmsg.c3
-rw-r--r--src/journal/journald-server.c65
-rw-r--r--src/journal/journald-stream.c8
-rw-r--r--src/libsystemd-network/sd-dhcp-client.c13
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c4
-rw-r--r--src/libsystemd-network/sd-dhcp-server.c8
-rw-r--r--src/libsystemd-network/sd-ipv4acd.c7
-rw-r--r--src/libsystemd-network/sd-ipv4ll.c7
-rw-r--r--src/libsystemd-network/sd-lldp-rx.c3
-rw-r--r--src/libsystemd-network/sd-lldp-tx.c4
-rw-r--r--src/libsystemd-network/sd-ndisc.c9
-rw-r--r--src/libsystemd-network/sd-radv.c6
-rw-r--r--src/libsystemd/sd-bus/bus-introspect.c3
-rw-r--r--src/libsystemd/sd-bus/bus-track.c3
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c14
-rw-r--r--src/libsystemd/sd-device/device-monitor.c4
-rw-r--r--src/libsystemd/sd-journal/sd-journal.c6
-rw-r--r--src/libsystemd/sd-netlink/sd-netlink.c11
-rw-r--r--src/libsystemd/sd-resolve/sd-resolve.c4
-rw-r--r--src/locale/localectl.c12
-rw-r--r--src/locale/localed.c9
-rw-r--r--src/login/loginctl.c45
-rw-r--r--src/login/logind-brightness.c3
-rw-r--r--src/login/logind-button.c18
-rw-r--r--src/login/logind-core.c7
-rw-r--r--src/login/logind-dbus.c148
-rw-r--r--src/login/logind-inhibit.c3
-rw-r--r--src/login/logind-seat-dbus.c30
-rw-r--r--src/login/logind-session-dbus.c60
-rw-r--r--src/login/logind-session.c9
-rw-r--r--src/login/logind-user-dbus.c33
-rw-r--r--src/login/logind-user.c9
-rw-r--r--src/login/logind.c19
-rw-r--r--src/machine/image-dbus.c15
-rw-r--r--src/machine/machine-dbus.c42
-rw-r--r--src/machine/machinectl.c96
-rw-r--r--src/machine/machined-dbus.c33
-rw-r--r--src/machine/machined-varlink.c6
-rw-r--r--src/machine/operation.c3
-rw-r--r--src/network/generator/network-generator.c3
-rw-r--r--src/network/netdev/fou-tunnel.c6
-rw-r--r--src/network/netdev/ipoib.c3
-rw-r--r--src/network/netdev/l2tp-tunnel.c9
-rw-r--r--src/network/netdev/macvlan.c3
-rw-r--r--src/network/netdev/netdev.c6
-rw-r--r--src/network/netdev/tunnel.c6
-rw-r--r--src/network/netdev/vlan.c3
-rw-r--r--src/network/netdev/vxlan.c3
-rw-r--r--src/network/netdev/wireguard.c21
-rw-r--r--src/network/netdev/wlan.c6
-rw-r--r--src/network/networkd-address-generation.c3
-rw-r--r--src/network/networkd-can.c12
-rw-r--r--src/network/networkd-dhcp-common.c43
-rw-r--r--src/network/networkd-dhcp-prefix-delegation.c3
-rw-r--r--src/network/networkd-dhcp-server-bus.c7
-rw-r--r--src/network/networkd-dhcp-server-static-lease.c6
-rw-r--r--src/network/networkd-dhcp-server.c3
-rw-r--r--src/network/networkd-dhcp4.c12
-rw-r--r--src/network/networkd-dhcp6.c6
-rw-r--r--src/network/networkd-ipv4acd.c6
-rw-r--r--src/network/networkd-ipv4ll.c9
-rw-r--r--src/network/networkd-ipv6-proxy-ndp.c3
-rw-r--r--src/network/networkd-link-bus.c56
-rw-r--r--src/network/networkd-link.c4
-rw-r--r--src/network/networkd-lldp-rx.c4
-rw-r--r--src/network/networkd-lldp-tx.c3
-rw-r--r--src/network/networkd-manager-bus.c3
-rw-r--r--src/network/networkd-manager.c16
-rw-r--r--src/network/networkd-ndisc.c4
-rw-r--r--src/network/networkd-neighbor.c6
-rw-r--r--src/network/networkd-network-bus.c6
-rw-r--r--src/network/networkd-network.c27
-rw-r--r--src/network/networkd-radv.c27
-rw-r--r--src/network/networkd-route-util.c3
-rw-r--r--src/network/networkd-route.c3
-rw-r--r--src/network/networkd-speed-meter.c3
-rw-r--r--src/network/networkd-sysctl.c3
-rw-r--r--src/network/networkd-util.c3
-rw-r--r--src/network/tc/cake.c24
-rw-r--r--src/network/tc/codel.c9
-rw-r--r--src/network/tc/drr.c3
-rw-r--r--src/network/tc/ets.c9
-rw-r--r--src/network/tc/fifo.c6
-rw-r--r--src/network/tc/fq-codel.c12
-rw-r--r--src/network/tc/fq-pie.c3
-rw-r--r--src/network/tc/fq.c15
-rw-r--r--src/network/tc/gred.c6
-rw-r--r--src/network/tc/hhf.c3
-rw-r--r--src/network/tc/htb.c15
-rw-r--r--src/network/tc/netem.c9
-rw-r--r--src/network/tc/pie.c3
-rw-r--r--src/network/tc/qdisc.c6
-rw-r--r--src/network/tc/qfq.c6
-rw-r--r--src/network/tc/sfb.c3
-rw-r--r--src/network/tc/sfq.c3
-rw-r--r--src/network/tc/tbf.c9
-rw-r--r--src/network/tc/tclass.c6
-rw-r--r--src/network/tc/teql.c3
-rw-r--r--src/network/wait-online/manager.c7
-rw-r--r--src/nspawn/nspawn-mount.c3
-rw-r--r--src/nspawn/nspawn-oci.c138
-rw-r--r--src/nspawn/nspawn-settings.c15
-rw-r--r--src/nspawn/nspawn.c3
-rw-r--r--src/nss-resolve/nss-resolve.c9
-rw-r--r--src/oom/oomd-manager-bus.c3
-rw-r--r--src/oom/oomd-manager.c14
-rw-r--r--src/partition/repart.c25
-rw-r--r--src/portable/portabled-bus.c9
-rw-r--r--src/portable/portabled-image-bus.c9
-rw-r--r--src/portable/portabled-image.c3
-rw-r--r--src/portable/portabled-operation.c3
-rw-r--r--src/resolve/resolvectl.c55
-rw-r--r--src/resolve/resolved-bus.c60
-rw-r--r--src/resolve/resolved-conf.c15
-rw-r--r--src/resolve/resolved-dns-query.c3
-rw-r--r--src/resolve/resolved-dns-scope.c3
-rw-r--r--src/resolve/resolved-dns-stream.c4
-rw-r--r--src/resolve/resolved-dns-stub.c7
-rw-r--r--src/resolve/resolved-dns-transaction.c6
-rw-r--r--src/resolve/resolved-dnssd-bus.c9
-rw-r--r--src/resolve/resolved-link-bus.c51
-rw-r--r--src/resolve/resolved-llmnr.c3
-rw-r--r--src/resolve/resolved-manager.c27
-rw-r--r--src/resolve/resolved-socket-graveyard.c4
-rw-r--r--src/resolve/resolved-varlink.c3
-rw-r--r--src/run/run.c3
-rw-r--r--src/shared/bus-get-properties.h3
-rw-r--r--src/shared/bus-polkit.c3
-rw-r--r--src/shared/bus-util.c3
-rw-r--r--src/shared/bus-wait-for-jobs.c3
-rw-r--r--src/shared/bus-wait-for-units.c15
-rw-r--r--src/shared/conf-parser.c56
-rw-r--r--src/shared/conf-parser.h6
-rw-r--r--src/shared/cpu-set-util.c4
-rw-r--r--src/shared/elf-util.c9
-rw-r--r--src/shared/ethtool-util.c6
-rw-r--r--src/shared/exec-util.c12
-rw-r--r--src/shared/in-addr-prefix-util.c3
-rw-r--r--src/shared/json.c27
-rw-r--r--src/shared/loopback-setup.c3
-rw-r--r--src/shared/net-condition.c18
-rw-r--r--src/shared/netif-sriov.c18
-rw-r--r--src/shared/parse-helpers.c3
-rw-r--r--src/shared/pkcs11-util.c6
-rw-r--r--src/shared/ptyfwd.c12
-rw-r--r--src/shared/tpm2-util.c4
-rw-r--r--src/shared/udev-util.c3
-rw-r--r--src/shared/user-record.c4
-rw-r--r--src/shared/userdb.c4
-rw-r--r--src/shared/varlink.c18
-rw-r--r--src/shared/vlan-util.c6
-rw-r--r--src/socket-proxy/socket-proxyd.c9
-rw-r--r--src/systemctl/systemctl-is-system-running.c4
-rw-r--r--src/sysupdate/sysupdate-transfer.c24
-rw-r--r--src/timedate/timedatectl.c28
-rw-r--r--src/timedate/timedated.c21
-rw-r--r--src/timesync/timesyncd-bus.c12
-rw-r--r--src/timesync/timesyncd-manager.c26
-rw-r--r--src/udev/net/link-config.c6
-rw-r--r--src/udev/udev-ctrl.c4
-rw-r--r--src/udev/udev-event.c18
-rw-r--r--src/udev/udevadm-trigger.c3
-rw-r--r--src/udev/udevd.c36
-rw-r--r--src/userdb/userdbd-manager.c6
-rw-r--r--src/xdg-autostart-generator/xdg-autostart-service.c9
220 files changed, 1071 insertions, 2323 deletions
diff --git a/src/analyze/analyze-condition.c b/src/analyze/analyze-condition.c
index d1643b6180..b29fc0cd71 100644
--- a/src/analyze/analyze-condition.c
+++ b/src/analyze/analyze-condition.c
@@ -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);
diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c
index d4858f77c5..69eab91bdb 100644
--- a/src/analyze/analyze-security.c
+++ b/src/analyze/analyze-security.c
@@ -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)
diff --git a/src/analyze/analyze-verify-util.c b/src/analyze/analyze-verify-util.c
index c309c07516..bbadd1a9f4 100644
--- a/src/analyze/analyze-verify-util.c
+++ b/src/analyze/analyze-verify-util.c
@@ -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)
diff --git a/src/basic/env-file.c b/src/basic/env-file.c
index 2ab5c7bc0d..e363bc80bf 100644
--- a/src/basic/env-file.c
+++ b/src/basic/env-file.c
@@ -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;
diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c
index 8013ac6b8e..f68cd36bb7 100644
--- a/src/basic/hashmap.c
+++ b/src/basic/hashmap.c
@@ -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;
diff --git a/src/basic/io-util.c b/src/basic/io-util.c
index a591a75c37..cdad939aa6 100644
--- a/src/basic/io-util.c
+++ b/src/basic/io-util.c
@@ -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;
diff --git a/src/basic/path-util.c b/src/basic/path-util.c
index 41e0d4d753..29a899b421 100644
--- a/src/basic/path-util.c
+++ b/src/basic/path-util.c
@@ -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.
*
diff --git a/src/basic/siphash24.c b/src/basic/siphash24.c
index 7c61eb145d..b614ecf11a 100644
--- a/src/basic/siphash24.c
+++ b/src/basic/siphash24.c
@@ -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 */
diff --git a/src/basic/time-util.c b/src/basic/time-util.c
index 26d59de123..71b2f67350 100644
--- a/src/basic/time-util.c
+++ b/src/basic/time-util.c
@@ -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) {
diff --git a/src/boot/efi/efi-string.c b/src/boot/efi/efi-string.c
index 6161f89a74..dfb2b06a75 100644
--- a/src/boot/efi/efi-string.c
+++ b/src/boot/efi/efi-string.c
@@ -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'; \
diff --git a/src/busctl/busctl-introspect.c b/src/busctl/busctl-introspect.c
index 9fbe9ebb5e..6002af5b2a 100644
--- a/src/busctl/busctl-introspect.c
+++ b/src/busctl/busctl-introspect.c
@@ -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.");
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c
index a6dbf0ddb5..90e42a21da 100644
--- a/src/busctl/busctl.c
+++ b/src/busctl/busctl.c
@@ -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)
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index c0bb13caf3..6d40faa48b 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -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;
diff --git a/src/core/core-varlink.c b/src/core/core-varlink.c
index 40cfd0cc7a..1fdcf885b8 100644
--- a/src/core/core-varlink.c
+++ b/src/core/core-varlink.c
@@ -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);
diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c
index 015dc238d6..cbadb5bc44 100644
--- a/src/core/dbus-cgroup.c
+++ b/src/core/dbus-cgroup.c
@@ -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)
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index 37d0afb0cb..fa3001427a 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -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);
diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c
index 7b1438266b..9792a5c44a 100644
--- a/src/core/dbus-job.c
+++ b/src/core/dbus-job.c
@@ -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 */
diff --git a/src/core/dbus-kill.c b/src/core/dbus-kill.c
index 6333f3bcfe..19e439f79e 100644
--- a/src/core/dbus-kill.c
+++ b/src/core/dbus-kill.c
@@ -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);
}
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 95defd36a3..039f941b68 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -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,
diff --git a/src/core/dbus-path.c b/src/core/dbus-path.c
index 09b353ba3f..65fb7d7eb7 100644
--- a/src/core/dbus-path.c
+++ b/src/core/dbus-path.c
@@ -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)
diff --git a/src/core/dbus-scope.c b/src/core/dbus-scope.c
index 0f59622166..7d2ceb0765 100644
--- a/src/core/dbus-scope.c
+++ b/src/core/dbus-scope.c
@@ -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)
diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c
index 2e6ca9d7d9..6e4bc0bd1a 100644
--- a/src/core/dbus-service.c
+++ b/src/core/dbus-service.c
@@ -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.");
diff --git a/src/core/dbus-timer.c b/src/core/dbus-timer.c
index 8110fb1fb7..80dd40a16a 100644
--- a/src/core/dbus-timer.c
+++ b/src/core/dbus-timer.c
@@ -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,
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 7a16471758..19a71b6cb3 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -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 */
diff --git a/src/core/dbus.c b/src/core/dbus.c
index ad2230d1b5..141c3ffe12 100644
--- a/src/core/dbus.c
+++ b/src/core/dbus.c
@@ -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) {
diff --git a/src/core/execute.c b/src/core/execute.c
index 6474c97e80..e9443500ac 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -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, " ");
diff --git a/src/core/job.c b/src/core/job.c
index c54c74b524..5a83be0679 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -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));
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 30d885e7a1..a7136c0b2b 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -344,13 +344,12 @@ int config_parse_unit_string_printf(
void *userdata) {
_cleanup_free_ char *k = NULL;
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
r = unit_full_printf(u, rvalue, &k);
if (r < 0) {
@@ -373,14 +372,13 @@ int config_parse_unit_strv_printf(
void *data,
void *userdata) {
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
_cleanup_free_ char *k = NULL;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
r = unit_full_printf(u, rvalue, &k);
if (r < 0) {
@@ -404,14 +402,13 @@ int config_parse_unit_path_printf(
void *userdata) {
_cleanup_free_ char *k = NULL;
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
int r;
bool fatal = ltype;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
r = unit_path_printf(u, rvalue, &k);
if (r < 0) {
@@ -435,14 +432,13 @@ int config_parse_colon_separated_paths(
const char *rvalue,
void *data,
void *userdata) {
- char ***sv = data;
+ char ***sv = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -495,13 +491,12 @@ int config_parse_unit_path_strv_printf(
void *userdata) {
char ***x = data;
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
if (isempty(rvalue)) {
*x = strv_free(*x);
@@ -703,13 +698,12 @@ int config_parse_exec_nice(
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int priority, r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->nice_set = false;
@@ -743,13 +737,12 @@ int config_parse_exec_oom_score_adjust(
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int oa, r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->oom_score_adjust_set = false;
@@ -783,13 +776,12 @@ int config_parse_exec_coredump_filter(
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->coredump_filter = 0;
@@ -864,7 +856,7 @@ int config_parse_exec(
void *data,
void *userdata) {
- ExecCommand **e = data;
+ ExecCommand **e = ASSERT_PTR(data);
const Unit *u = userdata;
const char *p;
bool semicolon;
@@ -873,7 +865,6 @@ int config_parse_exec(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(e);
e += ltype;
@@ -1079,12 +1070,11 @@ int config_parse_socket_bindtodevice(
void *data,
void *userdata) {
- Socket *s = data;
+ Socket *s = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue) || streq(rvalue, "*")) {
s->bind_to_device = mfree(s->bind_to_device);
@@ -1111,13 +1101,12 @@ int config_parse_exec_input(
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
const char *n;
ExecInput ei;
int r;
- assert(data);
assert(filename);
assert(line);
assert(rvalue);
@@ -1185,11 +1174,10 @@ int config_parse_exec_input_text(
void *userdata) {
_cleanup_free_ char *unescaped = NULL, *resolved = NULL;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
- assert(data);
assert(filename);
assert(line);
assert(rvalue);
@@ -1249,12 +1237,11 @@ int config_parse_exec_input_data(
void *userdata) {
_cleanup_free_ void *p = NULL;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
size_t sz;
void *q;
int r;
- assert(data);
assert(filename);
assert(line);
assert(rvalue);
@@ -1309,13 +1296,12 @@ int config_parse_exec_output(
_cleanup_free_ char *resolved = NULL;
const char *n;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
bool obsolete = false;
ExecOutput eo;
int r;
- assert(data);
assert(filename);
assert(line);
assert(lvalue);
@@ -1433,13 +1419,12 @@ int config_parse_exec_io_class(const char *unit,
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int x;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->ioprio_set = false;
@@ -1470,13 +1455,12 @@ int config_parse_exec_io_priority(const char *unit,
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int i, r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->ioprio_set = false;
@@ -1507,13 +1491,12 @@ int config_parse_exec_cpu_sched_policy(const char *unit,
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int x;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->cpu_sched_set = false;
@@ -1547,13 +1530,12 @@ int config_parse_exec_mount_apivfs(const char *unit,
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int k;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->mount_apivfs_set = false;
@@ -1585,12 +1567,11 @@ int config_parse_numa_mask(const char *unit,
void *data,
void *userdata) {
int r;
- NUMAPolicy *p = data;
+ NUMAPolicy *p = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (streq(rvalue, "all")) {
r = numa_mask_add_all(&p->nodes);
@@ -1617,13 +1598,12 @@ int config_parse_exec_cpu_sched_prio(const char *unit,
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int i, min, max, r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = safe_atoi(rvalue, &i);
if (r < 0) {
@@ -1660,14 +1640,13 @@ int config_parse_root_image_options(
_cleanup_(mount_options_free_allp) MountOptions *options = NULL;
_cleanup_strv_free_ char **l = NULL;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->root_image_options = mount_options_free_all(c->root_image_options);
@@ -1739,11 +1718,10 @@ int config_parse_exec_root_hash(
void *userdata) {
_cleanup_free_ void *roothash_decoded = NULL;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
size_t roothash_decoded_size = 0;
int r;
- assert(data);
assert(filename);
assert(line);
assert(rvalue);
@@ -1802,11 +1780,10 @@ int config_parse_exec_root_hash_sig(
_cleanup_free_ void *roothash_sig_decoded = NULL;
char *value;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
size_t roothash_sig_decoded_size = 0;
int r;
- assert(data);
assert(filename);
assert(line);
assert(rvalue);
@@ -1865,7 +1842,7 @@ int config_parse_exec_cpu_affinity(
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
_cleanup_free_ char *k = NULL;
int r;
@@ -1873,7 +1850,6 @@ int config_parse_exec_cpu_affinity(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (streq(rvalue, "numa")) {
c->cpu_affinity_from_numa = true;
@@ -1909,7 +1885,7 @@ int config_parse_capability_set(
void *data,
void *userdata) {
- uint64_t *capability_set = data;
+ uint64_t *capability_set = ASSERT_PTR(data);
uint64_t sum = 0, initial = 0;
bool invert = false;
int r;
@@ -1917,7 +1893,6 @@ int config_parse_capability_set(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (rvalue[0] == '~') {
invert = true;
@@ -1960,7 +1935,7 @@ int config_parse_exec_selinux_context(
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
bool ignore;
char *k;
@@ -1969,7 +1944,6 @@ int config_parse_exec_selinux_context(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->selinux_context = mfree(c->selinux_context);
@@ -2009,7 +1983,7 @@ int config_parse_exec_apparmor_profile(
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
bool ignore;
char *k;
@@ -2018,7 +1992,6 @@ int config_parse_exec_apparmor_profile(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->apparmor_profile = mfree(c->apparmor_profile);
@@ -2058,7 +2031,7 @@ int config_parse_exec_smack_process_label(
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
bool ignore;
char *k;
@@ -2067,7 +2040,6 @@ int config_parse_exec_smack_process_label(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
c->smack_process_label = mfree(c->smack_process_label);
@@ -2110,7 +2082,7 @@ int config_parse_timer(
_cleanup_(calendar_spec_freep) CalendarSpec *c = NULL;
_cleanup_free_ char *k = NULL;
const Unit *u = userdata;
- Timer *t = data;
+ Timer *t = ASSERT_PTR(data);
usec_t usec = 0;
TimerValue *v;
int r;
@@ -2118,7 +2090,6 @@ int config_parse_timer(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets list */
@@ -2174,14 +2145,13 @@ int config_parse_trigger_unit(
void *userdata) {
_cleanup_free_ char *p = NULL;
- Unit *u = data;
+ Unit *u = ASSERT_PTR(data);
UnitType type;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (UNIT_TRIGGER(u)) {
log_syntax(unit, LOG_WARNING, filename, line, 0, "Multiple units to trigger specified, ignoring: %s", rvalue);
@@ -2224,7 +2194,7 @@ int config_parse_path_spec(const char *unit,
void *data,
void *userdata) {
- Path *p = data;
+ Path *p = ASSERT_PTR(data);
PathSpec *s;
PathType b;
_cleanup_free_ char *k = NULL;
@@ -2233,7 +2203,6 @@ int config_parse_path_spec(const char *unit,
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment clears list */
@@ -2285,14 +2254,13 @@ int config_parse_socket_service(
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_free_ char *p = NULL;
- Socket *s = data;
+ Socket *s = ASSERT_PTR(data);
Unit *x;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = unit_name_printf(UNIT(s), rvalue, &p);
if (r < 0) {
@@ -2329,13 +2297,12 @@ int config_parse_fdname(
void *userdata) {
_cleanup_free_ char *p = NULL;
- Socket *s = data;
+ Socket *s = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
s->fdname = mfree(s->fdname);
@@ -2368,13 +2335,12 @@ int config_parse_service_sockets(
void *data,
void *userdata) {
- Service *s = data;
+ Service *s = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
for (const char *p = rvalue;;) {
_cleanup_free_ char *word = NULL, *k = NULL;
@@ -2423,13 +2389,12 @@ int config_parse_bus_name(
void *userdata) {
_cleanup_free_ char *k = NULL;
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
r = unit_full_printf_full(u, rvalue, SD_BUS_MAXIMUM_NAME_LENGTH, &k);
if (r < 0) {
@@ -2457,14 +2422,13 @@ int config_parse_service_timeout(
void *data,
void *userdata) {
- Service *s = userdata;
+ Service *s = ASSERT_PTR(userdata);
usec_t usec;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(s);
/* This is called for two cases: TimeoutSec= and TimeoutStartSec=. */
@@ -2498,13 +2462,12 @@ int config_parse_timeout_abort(
void *data,
void *userdata) {
- usec_t *ret = data;
+ usec_t *ret = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(ret);
/* Note: apart from setting the arg, this returns an extra bit of information in the return value. */
@@ -2532,11 +2495,9 @@ int config_parse_service_timeout_abort(
void *data,
void *userdata) {
- Service *s = userdata;
+ Service *s = ASSERT_PTR(userdata);
int r;
- assert(s);
-
r = config_parse_timeout_abort(unit, filename, line, section, section_line, lvalue, ltype, rvalue,
&s->timeout_abort_usec, s);
if (r >= 0)
@@ -2558,13 +2519,12 @@ int config_parse_user_group_compat(
_cleanup_free_ char *k = NULL;
char **user = data;
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
if (isempty(rvalue)) {
*user = mfree(*user);
@@ -2607,13 +2567,12 @@ int config_parse_user_group_strv_compat(
void *userdata) {
char ***users = data;
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
if (isempty(rvalue)) {
*users = strv_free(*users);
@@ -2664,16 +2623,14 @@ int config_parse_working_directory(
void *data,
void *userdata) {
- ExecContext *c = data;
- const Unit *u = userdata;
+ ExecContext *c = ASSERT_PTR(data);
+ const Unit *u = ASSERT_PTR(userdata);
bool missing_ok;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(c);
- assert(u);
if (isempty(rvalue)) {
c->working_directory_home = false;
@@ -2724,7 +2681,7 @@ int config_parse_unit_env_file(const char *unit,
void *data,
void *userdata) {
- char ***env = data;
+ char ***env = ASSERT_PTR(data);
const Unit *u = userdata;
_cleanup_free_ char *n = NULL;
int r;
@@ -2732,7 +2689,6 @@ int config_parse_unit_env_file(const char *unit,
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment frees the list */
@@ -2772,13 +2728,12 @@ int config_parse_environ(
void *userdata) {
const Unit *u = userdata;
- char ***env = data;
+ char ***env = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -2836,14 +2791,13 @@ int config_parse_pass_environ(
_cleanup_strv_free_ char **n = NULL;
const Unit *u = userdata;
- char*** passenv = data;
+ char*** passenv = ASSERT_PTR(data);
size_t nlen = 0;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -2910,7 +2864,7 @@ int config_parse_unset_environ(
void *userdata) {
_cleanup_strv_free_ char **n = NULL;
- char*** unsetenv = data;
+ char*** unsetenv = ASSERT_PTR(data);
const Unit *u = userdata;
size_t nlen = 0;
int r;
@@ -2918,7 +2872,6 @@ int config_parse_unset_environ(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -2984,14 +2937,13 @@ int config_parse_log_extra_fields(
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(c);
if (isempty(rvalue)) {
exec_context_free_log_extra_fields(c);
@@ -3054,14 +3006,13 @@ int config_parse_log_namespace(
void *userdata) {
_cleanup_free_ char *k = NULL;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(c);
if (isempty(rvalue)) {
c->log_namespace = mfree(c->log_namespace);
@@ -3096,7 +3047,7 @@ int config_parse_unit_condition_path(
void *userdata) {
_cleanup_free_ char *p = NULL;
- Condition **list = data, *c;
+ Condition **list = ASSERT_PTR(data), *c;
ConditionType t = ltype;
bool trigger, negate;
const Unit *u = userdata;
@@ -3105,7 +3056,6 @@ int config_parse_unit_condition_path(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -3152,7 +3102,7 @@ int config_parse_unit_condition_string(
void *userdata) {
_cleanup_free_ char *s = NULL;
- Condition **list = data, *c;
+ Condition **list = ASSERT_PTR(data), *c;
ConditionType t = ltype;
bool trigger, negate;
const Unit *u = userdata;
@@ -3161,7 +3111,6 @@ int config_parse_unit_condition_string(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -3256,14 +3205,13 @@ int config_parse_documentation(
void *data,
void *userdata) {
- Unit *u = userdata;
+ Unit *u = ASSERT_PTR(userdata);
int r;
char **a, **b;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -3305,14 +3253,13 @@ int config_parse_syscall_filter(
void *userdata) {
ExecContext *c = data;
- _unused_ const Unit *u = userdata;
+ _unused_ const Unit *u = ASSERT_PTR(userdata);
bool invert = false;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -3400,7 +3347,7 @@ int config_parse_syscall_log(
void *userdata) {
ExecContext *c = data;
- _unused_ const Unit *u = userdata;
+ _unused_ const Unit *u = ASSERT_PTR(userdata);
bool invert = false;
const char *p;
int r;
@@ -3408,7 +3355,6 @@ int config_parse_syscall_log(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -3695,14 +3641,13 @@ int config_parse_restrict_filesystems(
const char *rvalue,
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
bool invert = false;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -4190,13 +4135,12 @@ int config_parse_io_device_weight(
_cleanup_free_ char *path = NULL, *resolved = NULL;
CGroupIODeviceWeight *w;
CGroupContext *c = data;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
uint64_t u;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
if (isempty(rvalue)) {
while (c->io_device_weights)
@@ -4264,13 +4208,12 @@ int config_parse_io_device_latency(
_cleanup_free_ char *path = NULL, *resolved = NULL;
CGroupIODeviceLatency *l;
CGroupContext *c = data;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
usec_t usec;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
if (isempty(rvalue)) {
while (c->io_device_latencies)
@@ -4337,13 +4280,12 @@ int config_parse_io_limit(
CGroupIODeviceLimit *l = NULL;
CGroupContext *c = data;
CGroupIOLimitType type;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
uint64_t num;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
type = cgroup_io_limit_type_from_string(lvalue);
assert(type >= 0);
@@ -4429,13 +4371,12 @@ int config_parse_blockio_device_weight(
_cleanup_free_ char *path = NULL, *resolved = NULL;
CGroupBlockIODeviceWeight *w;
CGroupContext *c = data;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
uint64_t u;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Unit uses %s=; please use IO*= settings instead. Support for %s= will be removed soon.",
@@ -4507,14 +4448,13 @@ int config_parse_blockio_bandwidth(
_cleanup_free_ char *path = NULL, *resolved = NULL;
CGroupBlockIODeviceBandwidth *b = NULL;
CGroupContext *c = data;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
uint64_t bytes;
bool read;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
log_syntax(unit, LOG_WARNING, filename, line, 0,
"Unit uses %s=; please use IO*= settings instead. Support for %s= will be removed soon.",
@@ -4630,14 +4570,13 @@ int config_parse_exec_directories(
void *data,
void *userdata) {
- ExecDirectory *ed = data;
+ ExecDirectory *ed = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -4736,18 +4675,16 @@ int config_parse_set_credential(
_cleanup_free_ char *word = NULL, *k = NULL;
_cleanup_free_ void *d = NULL;
- ExecContext *context = data;
+ ExecContext *context = ASSERT_PTR(data);
ExecSetCredential *old;
Unit *u = userdata;
bool encrypted = ltype;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
size_t size;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
- assert(context);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -4845,7 +4782,7 @@ int config_parse_load_credential(
void *userdata) {
_cleanup_free_ char *word = NULL, *k = NULL, *q = NULL;
- ExecContext *context = data;
+ ExecContext *context = ASSERT_PTR(data);
ExecLoadCredential *old;
bool encrypted = ltype;
Unit *u = userdata;
@@ -4855,7 +4792,6 @@ int config_parse_load_credential(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(context);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -4944,13 +4880,12 @@ int config_parse_set_status(
void *data,
void *userdata) {
- ExitStatusSet *status_set = data;
+ ExitStatusSet *status_set = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(status_set);
/* Empty assignment resets the list */
if (isempty(rvalue)) {
@@ -5010,13 +4945,12 @@ int config_parse_namespace_path_strv(
void *userdata) {
const Unit *u = userdata;
- char*** sv = data;
+ char*** sv = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -5086,13 +5020,12 @@ int config_parse_temporary_filesystems(
void *userdata) {
const Unit *u = userdata;
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -5157,14 +5090,13 @@ int config_parse_bind_paths(
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -5285,14 +5217,13 @@ int config_parse_mount_images(
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -5445,14 +5376,13 @@ int config_parse_extension_images(
void *data,
void *userdata) {
- ExecContext *c = data;
+ ExecContext *c = ASSERT_PTR(data);
const Unit *u = userdata;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -5586,14 +5516,13 @@ int config_parse_job_timeout_sec(
void *data,
void *userdata) {
- Unit *u = data;
+ Unit *u = ASSERT_PTR(data);
usec_t usec;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
r = parse_sec_fix_0(rvalue, &usec);
if (r < 0) {
@@ -5625,14 +5554,13 @@ int config_parse_job_running_timeout_sec(
void *data,
void *userdata) {
- Unit *u = data;
+ Unit *u = ASSERT_PTR(data);
usec_t usec;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
r = parse_sec_fix_0(rvalue, &usec);
if (r < 0) {
@@ -5659,13 +5587,12 @@ int config_parse_emergency_action(
void *userdata) {
Manager *m = NULL;
- EmergencyAction *x = data;
+ EmergencyAction *x = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (unit)
m = ((Unit*) userdata)->manager;
@@ -5710,14 +5637,13 @@ int config_parse_pid_file(
void *userdata) {
_cleanup_free_ char *k = NULL, *n = NULL;
- const Unit *u = userdata;
+ const Unit *u = ASSERT_PTR(userdata);
char **s = data;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
if (isempty(rvalue)) {
/* An empty assignment removes already set value. */
@@ -5833,13 +5759,12 @@ int config_parse_ip_filter_bpf_progs(
_cleanup_free_ char *resolved = NULL;
const Unit *u = userdata;
- char ***paths = data;
+ char ***paths = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(paths);
if (isempty(rvalue)) {
*paths = strv_free(*paths);
@@ -5892,13 +5817,12 @@ int config_parse_bpf_foreign_program(
void *userdata) {
_cleanup_free_ char *resolved = NULL, *word = NULL;
CGroupContext *c = data;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
Unit *u = userdata;
int attach_type, r;
assert(filename);
assert(lvalue);
- assert(rvalue);
if (isempty(rvalue)) {
while (c->bpf_foreign_programs)
@@ -5998,14 +5922,13 @@ int config_parse_restrict_network_interfaces(
const char *rvalue,
void *data,
void *userdata) {
- CGroupContext *c = data;
+ CGroupContext *c = ASSERT_PTR(data);
bool is_allow_rule = true;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -6364,9 +6287,7 @@ int config_parse_cpu_affinity2(
void *data,
void *userdata) {
- CPUSet *affinity = data;
-
- assert(affinity);
+ CPUSet *affinity = ASSERT_PTR(data);
(void) parse_cpu_set_extend(rvalue, affinity, true, unit, filename, line, lvalue);
@@ -6386,12 +6307,11 @@ int config_parse_show_status(
void *userdata) {
int k;
- ShowStatus *b = data;
+ ShowStatus *b = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
k = parse_show_status(rvalue, b);
if (k < 0)
@@ -6412,13 +6332,12 @@ int config_parse_output_restricted(
void *data,
void *userdata) {
- ExecOutput t, *eo = data;
+ ExecOutput t, *eo = ASSERT_PTR(data);
bool obsolete = false;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (streq(rvalue, "syslog")) {
t = EXEC_OUTPUT_JOURNAL;
@@ -6486,10 +6405,9 @@ int config_parse_swap_priority(
void *data,
void *userdata) {
- Swap *s = userdata;
+ Swap *s = ASSERT_PTR(userdata);
int r, priority;
- assert(s);
assert(filename);
assert(lvalue);
assert(rvalue);
diff --git a/src/core/manager.c b/src/core/manager.c
index 510585198d..cc89ae3f9c 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -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);
diff --git a/src/core/mount.c b/src/core/mount.c
index 667b269566..fba7c4cac3 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -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);
diff --git a/src/core/service.c b/src/core/service.c
index 4933163b56..8dd147ad1e 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -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);
diff --git a/src/core/socket.c b/src/core/socket.c
index f67a797054..de8634481b 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -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)
diff --git a/src/core/swap.c b/src/core/swap.c
index 6dc6bca34b..2196793ad1 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -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);
diff --git a/src/core/unit.c b/src/core/unit.c
index 81e3764141..ce2bc9f3d8 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -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.",
diff --git a/src/cryptsetup/cryptsetup-tokens/luks2-pkcs11.c b/src/cryptsetup/cryptsetup-tokens/luks2-pkcs11.c
index 9e88c8cfc3..2e0450aa5b 100644
--- a/src/cryptsetup/cryptsetup-tokens/luks2-pkcs11.c
+++ b/src/cryptsetup/cryptsetup-tokens/luks2-pkcs11.c
@@ -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)
diff --git a/src/fundamental/sha256.c b/src/fundamental/sha256.c
index 43ee996b6f..9b717645b3 100644
--- a/src/fundamental/sha256.c
+++ b/src/fundamental/sha256.c
@@ -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];
diff --git a/src/fuzz/fuzz-varlink.c b/src/fuzz/fuzz-varlink.c
index f26050cf0e..397c20dca6 100644
--- a/src/fuzz/fuzz-varlink.c
+++ b/src/fuzz/fuzz-varlink.c
@@ -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;
diff --git a/src/home/homed-conf.c b/src/home/homed-conf.c
index 4f46b0c886..296e01449d 100644
--- a/src/home/homed-conf.c
+++ b/src/home/homed-conf.c
@@ -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);
diff --git a/src/home/homed-home-bus.c b/src/home/homed-home-bus.c
index 4663792e5c..4e3fd5f0ae 100644
--- a/src/home/homed-home-bus.c
+++ b/src/home/homed-home-bus.c
@@ -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);
diff --git a/src/home/homed-home.c b/src/home/homed-home.c
index 2b7c18d32f..47dc16d83f 100644
--- a/src/home/homed-home.c
+++ b/src/home/homed-home.c
@@ -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) {
diff --git a/src/home/homed-manager-bus.c b/src/home/homed-manager-bus.c
index ba5ca42ed3..0c0c292a70 100644
--- a/src/home/homed-manager-bus.c
+++ b/src/home/homed-manager-bus.c
@@ -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(
diff --git a/src/home/homed-manager.c b/src/home/homed-manager.c
index d114236cf7..38945d7988 100644
--- a/src/home/homed-manager.c
+++ b/src/home/homed-manager.c
@@ -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);
diff --git a/src/home/homed-varlink.c b/src/home/homed-varlink.c
index 3dd5a14802..540a612554 100644
--- a/src/home/homed-varlink.c
+++ b/src/home/homed-varlink.c
@@ -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)
diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c
index eea282fe12..f2dcabd84a 100644
--- a/src/home/homework-luks.c
+++ b/src/home/homework-luks.c
@@ -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;
diff --git a/src/home/homework-pkcs11.c b/src/home/homework-pkcs11.c
index 7868fb6064..be9d905c0e 100644
--- a/src/home/homework-pkcs11.c
+++ b/src/home/homework-pkcs11.c
@@ -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:
*
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index 8c0b63503f..d59c783dbc 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -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,
diff --git a/src/import/curl-util.c b/src/import/curl-util.c
index 5b39251aa9..c124c985b9 100644
--- a/src/import/curl-util.c
+++ b/src/import/curl-util.c
@@ -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) {
diff --git a/src/import/import-fs.c b/src/import/import-fs.c
index ff7f51a60a..1c5581fd61 100644
--- a/src/import/import-fs.c
+++ b/src/import/import-fs.c
@@ -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;
diff --git a/src/import/import-raw.c b/src/import/import-raw.c
index a0208e505c..0faa58acf5 100644
--- a/src/import/import-raw.c
+++ b/src/import/import-raw.c
@@ -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);
diff --git a/src/import/importd.c b/src/import/importd.c
index 125b2dc808..74e8ffb0cf 100644
--- a/src/import/importd.c
+++ b/src/import/importd.c
@@ -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)
diff --git a/src/import/pull-job.c b/src/import/pull-job.c
index f5eb82131e..1e105bc769 100644
--- a/src/import/pull-job.c
+++ b/src/import/pull-job.c
@@ -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;
diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c
index 8fb07bc02f..cdfeb1fc80 100644
--- a/src/journal-remote/journal-gatewayd.c
+++ b/src/journal-remote/journal-gatewayd.c
@@ -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)
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c
index 4fe5812d2f..0088652184 100644
--- a/src/journal-remote/journal-remote-main.c
+++ b/src/journal-remote/journal-remote-main.c
@@ -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
diff --git a/src/journal-remote/journal-upload-journal.c b/src/journal-remote/journal-upload-journal.c
index cf9c760202..7a8f50dd0d 100644
--- a/src/journal-remote/journal-upload-journal.c
+++ b/src/journal-remote/journal-upload-journal.c
@@ -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;
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index 2ad175c248..06448b2225 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -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;
diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c
index 1b79e9366c..8ae7a23d56 100644
--- a/src/journal/journald-kmsg.c
+++ b/src/journal/journald-kmsg.c
@@ -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.");
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index b3a2df941c..bfa9f44a83 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -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 */
diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c
index 19f0799914..8bdcd8c2ae 100644
--- a/src/journal/journald-stream.c
+++ b/src/journal/journald-stream.c
@@ -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,
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index 5b7e3640e8..a106f7f3b8 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -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) {
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index 734a4fa27d..d84a356663 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -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:
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
index 5c9ba9f618..11ab2338ce 100644
--- a/src/libsystemd-network/sd-dhcp-server.c
+++ b/src/libsystemd-network/sd-dhcp-server.c
@@ -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))
diff --git a/src/libsystemd-network/sd-ipv4acd.c b/src/libsystemd-network/sd-ipv4acd.c
index 1c5eae3cff..673783b2b3 100644
--- a/src/libsystemd-network/sd-ipv4acd.c
+++ b/src/libsystemd-network/sd-ipv4acd.c
@@ -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);
diff --git a/src/libsystemd-network/sd-ipv4ll.c b/src/libsystemd-network/sd-ipv4ll.c
index 155c1a5de6..4b0fac3cf1 100644
--- a/src/libsystemd-network/sd-ipv4ll.c
+++ b/src/libsystemd-network/sd-ipv4ll.c
@@ -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);
diff --git a/src/libsystemd-network/sd-lldp-rx.c b/src/libsystemd-network/sd-lldp-rx.c
index d4762bf097..0479cff5f5 100644
--- a/src/libsystemd-network/sd-lldp-rx.c
+++ b/src/libsystemd-network/sd-lldp-rx.c
@@ -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) {
diff --git a/src/libsystemd-network/sd-lldp-tx.c b/src/libsystemd-network/sd-lldp-tx.c
index 78f37f2467..d2d24be089 100644
--- a/src/libsystemd-network/sd-lldp-tx.c
+++ b/src/libsystemd-network/sd-lldp-tx.c
@@ -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");
diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c
index f7522aa8d6..276370ef05 100644
--- a/src/libsystemd-network/sd-ndisc.c
+++ b/src/libsystemd-network/sd-ndisc.c
@@ -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");
diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c
index a1f50afce3..6611746a58 100644
--- a/src/libsystemd-network/sd-radv.c
+++ b/src/libsystemd-network/sd-radv.c
@@ -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));
diff --git a/src/libsystemd/sd-bus/bus-introspect.c b/src/libsystemd/sd-bus/bus-introspect.c
index c509e0e8cc..49236a8e12 100644
--- a/src/libsystemd/sd-bus/bus-introspect.c
+++ b/src/libsystemd/sd-bus/bus-introspect.c
@@ -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)
diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c
index 245d082f8d..f9c59a1007 100644
--- a/src/libsystemd/sd-bus/bus-track.c
+++ b/src/libsystemd/sd-bus/bus-track.c
@@ -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)
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index bb95ef08dc..3803a2c4c4 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -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) {
diff --git a/src/libsystemd/sd-device/device-monitor.c b/src/libsystemd/sd-device/device-monitor.c
index 33723950a1..8b1b01ee0f 100644
--- a/src/libsystemd/sd-device/device-monitor.c
+++ b/src/libsystemd/sd-device/device-monitor.c
@@ -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;
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c
index 77d03ec95f..af11f33505 100644
--- a/src/libsystemd/sd-journal/sd-journal.c
+++ b/src/libsystemd/sd-journal/sd-journal.c
@@ -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 ||
diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c
index 912efcf3ad..b1a684a9af 100644
--- a/src/libsystemd/sd-netlink/sd-netlink.c
+++ b/src/libsystemd/sd-netlink/sd-netlink.c
@@ -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)
diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c
index e4d43e7558..5362ec0fa8 100644
--- a/src/libsystemd/sd-resolve/sd-resolve.c
+++ b/src/libsystemd/sd-resolve/sd-resolve.c
@@ -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;
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index 55db3c9ed8..ebbf107432 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -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];
diff --git a/src/locale/localed.c b/src/locale/localed.c
index 791b5e60dd..7aa47f18c2 100644
--- a/src/locale/localed.c
+++ b/src/locale/localed.c
@@ -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)
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index b46ef2bb9d..ed24473baa 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -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);
diff --git a/src/login/logind-brightness.c b/src/login/logind-brightness.c
index d6b9289ea6..21feaae0c3 100644
--- a/src/login/logind-brightness.c
+++ b/src/login/logind-brightness.c
@@ -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;
diff --git a/src/login/logind-button.c b/src/login/logind-button.c
index 368a08a095..0314ae1774 100644
--- a/src/login/logind-button.c
+++ b/src/login/logind-button.c
@@ -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)
diff --git a/src/login/logind-core.c b/src/login/logind-core.c
index 1fba1980d7..02adc81909 100644
--- a/src/login/logind-core.c
+++ b/src/login/logind-core.c
@@ -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. */
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 8119970209..7fc96447d5 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -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) {
diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c
index dbb58e4ac3..16612ddf18 100644
--- a/src/login/logind-inhibit.c
+++ b/src/login/logind-inhibit.c
@@ -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);
diff --git a/src/login/logind-seat-dbus.c b/src/login/logind-seat-dbus.c
index cd20693cbe..03a419229e 100644
--- a/src/login/logind-seat-dbus.c
+++ b/src/login/logind-seat-dbus.c
@@ -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)
diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c
index 539109c5e8..56f6307dcd 100644
--- a/src/login/logind-session-dbus.c
+++ b/src/login/logind-session-dbus.c
@@ -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)
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index 443adf0c24..096940ddc4 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -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);
diff --git a/src/login/logind-user-dbus.c b/src/login/logind-user-dbus.c
index 67b6556d7d..88649b2f4b 100644
--- a/src/login/logind-user-dbus.c
+++ b/src/login/logind-user-dbus.c
@@ -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;
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 3f1b8f610b..e02ad754ee 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -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);
diff --git a/src/login/logind.c b/src/login/logind.c
index ebea23f01d..95c5526711 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -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;
diff --git a/src/machine/image-dbus.c b/src/machine/image-dbus.c
index 1ff1869720..84dc95eca1 100644
--- a/src/machine/image-dbus.c
+++ b/src/machine/image-dbus.c
@@ -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;
diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c
index 87d04c3d58..0a245247ec 100644
--- a/src/machine/machine-dbus.c
+++ b/src/machine/machine-dbus.c
@@ -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;
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 921af58c94..d05b4101cc 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -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++) {
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index 794e353caa..e2d0784857 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -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) {
diff --git a/src/machine/machined-varlink.c b/src/machine/machined-varlink.c
index 6e4fcfda67..ec625ad7b4 100644
--- a/src/machine/machined-varlink.c
+++ b/src/machine/machined-varlink.c
@@ -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)
diff --git a/src/machine/operation.c b/src/machine/operation.c
index 4110fcf21e..c97b29aba8 100644
--- a/src/machine/operation.c
+++ b/src/machine/operation.c
@@ -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",
diff --git a/src/network/generator/network-generator.c b/src/network/generator/network-generator.c
index fee222f88e..1090934bfc 100644
--- a/src/network/generator/network-generator.c
+++ b/src/network/generator/network-generator.c
@@ -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);
diff --git a/src/network/netdev/fou-tunnel.c b/src/network/netdev/fou-tunnel.c
index cd8f2f8087..acd609f296 100644
--- a/src/network/netdev/fou-tunnel.c
+++ b/src/network/netdev/fou-tunnel.c
@@ -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;
diff --git a/src/network/netdev/ipoib.c b/src/network/netdev/ipoib.c
index 0e27f5f044..5dd9286d57 100644
--- a/src/network/netdev/ipoib.c
+++ b/src/network/netdev/ipoib.c
@@ -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. */
diff --git a/src/network/netdev/l2tp-tunnel.c b/src/network/netdev/l2tp-tunnel.c
index 7e7d167928..2bce0fc5b2 100644
--- a/src/network/netdev/l2tp-tunnel.c
+++ b/src/network/netdev/l2tp-tunnel.c
@@ -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;
diff --git a/src/network/netdev/macvlan.c b/src/network/netdev/macvlan.c
index aca05f0f77..1114bb0cb1 100644
--- a/src/network/netdev/macvlan.c
+++ b/src/network/netdev/macvlan.c
@@ -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;
diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c
index 212df3daa0..038a27c118 100644
--- a/src/network/netdev/netdev.c
+++ b/src/network/netdev/netdev.c
@@ -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;
diff --git a/src/network/netdev/tunnel.c b/src/network/netdev/tunnel.c
index 78a8708b21..db414a8943 100644
--- a/src/network/netdev/tunnel.c
+++ b/src/network/netdev/tunnel.c
@@ -778,13 +778,12 @@ int config_parse_tunnel_local_address(
union in_addr_union buffer = IN_ADDR_NULL;
NetDevLocalAddressType type;
- Tunnel *t = userdata;
+ Tunnel *t = ASSERT_PTR(userdata);
int r, f;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(userdata);
if (isempty(rvalue) || streq(rvalue, "any"))
return unset_local(t);
@@ -846,13 +845,12 @@ int config_parse_tunnel_remote_address(
void *userdata) {
union in_addr_union buffer;
- Tunnel *t = userdata;
+ Tunnel *t = ASSERT_PTR(userdata);
int r, f;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(userdata);
if (isempty(rvalue) || streq(rvalue, "any"))
return unset_remote(t);
diff --git a/src/network/netdev/vlan.c b/src/network/netdev/vlan.c
index 3f9f594759..a3d961dac3 100644
--- a/src/network/netdev/vlan.c
+++ b/src/network/netdev/vlan.c
@@ -129,13 +129,12 @@ int config_parse_vlan_qos_maps(
void *data,
void *userdata) {
- Set **s = data;
+ Set **s = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*s = set_free(*s);
diff --git a/src/network/netdev/vxlan.c b/src/network/netdev/vxlan.c
index d93084c2d4..589161938a 100644
--- a/src/network/netdev/vxlan.c
+++ b/src/network/netdev/vxlan.c
@@ -207,7 +207,7 @@ int config_parse_vxlan_address(
void *data,
void *userdata) {
- VxLan *v = userdata;
+ VxLan *v = ASSERT_PTR(userdata);
union in_addr_union *addr = data, buffer;
int *family, f, r;
@@ -215,7 +215,6 @@ int config_parse_vxlan_address(
assert(lvalue);
assert(rvalue);
assert(data);
- assert(userdata);
if (streq(lvalue, "Local"))
family = &v->local_family;
diff --git a/src/network/netdev/wireguard.c b/src/network/netdev/wireguard.c
index b858e20ed6..51e7e02990 100644
--- a/src/network/netdev/wireguard.c
+++ b/src/network/netdev/wireguard.c
@@ -296,10 +296,9 @@ static int wireguard_set_interface(NetDev *netdev) {
}
static int on_resolve_retry(sd_event_source *s, usec_t usec, void *userdata) {
- WireguardPeer *peer = userdata;
+ WireguardPeer *peer = ASSERT_PTR(userdata);
NetDev *netdev;
- assert(peer);
assert(peer->wireguard);
netdev = NETDEV(peer->wireguard);
@@ -332,11 +331,10 @@ static int wireguard_peer_resolve_handler(
const struct addrinfo *ai,
void *userdata) {
- WireguardPeer *peer = userdata;
+ WireguardPeer *peer = ASSERT_PTR(userdata);
NetDev *netdev;
int r;
- assert(peer);
assert(peer->wireguard);
netdev = NETDEV(peer->wireguard);
@@ -462,11 +460,10 @@ int config_parse_wireguard_listen_port(
void *data,
void *userdata) {
- uint16_t *s = data;
+ uint16_t *s = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(data);
if (isempty(rvalue) || streq(rvalue, "auto")) {
*s = 0;
@@ -887,15 +884,13 @@ int config_parse_wireguard_route_table(
void *data,
void *userdata) {
- NetDev *netdev = userdata;
- uint32_t *table = data;
+ NetDev *netdev = ASSERT_PTR(userdata);
+ uint32_t *table = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
- assert(userdata);
if (isempty(rvalue) || parse_boolean(rvalue) == 0) {
*table = 0; /* Disabled. */
@@ -926,14 +921,13 @@ int config_parse_wireguard_peer_route_table(
void *userdata) {
_cleanup_(wireguard_peer_free_or_set_invalidp) WireguardPeer *peer = NULL;
- NetDev *netdev = userdata;
+ NetDev *netdev = ASSERT_PTR(userdata);
Wireguard *w;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(netdev);
assert(netdev->manager);
w = WIREGUARD(netdev);
@@ -981,13 +975,12 @@ int config_parse_wireguard_route_priority(
void *data,
void *userdata) {
- uint32_t *priority = data;
+ uint32_t *priority = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*priority = 0;
diff --git a/src/network/netdev/wlan.c b/src/network/netdev/wlan.c
index bf23ae3d3f..816e106400 100644
--- a/src/network/netdev/wlan.c
+++ b/src/network/netdev/wlan.c
@@ -179,13 +179,12 @@ int config_parse_wiphy(
void *data,
void *userdata) {
- WLan *w = userdata;
+ WLan *w = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(userdata);
if (isempty(rvalue)) {
w->wiphy_name = mfree(w->wiphy_name);
@@ -219,12 +218,11 @@ int config_parse_wlan_iftype(
void *data,
void *userdata) {
- enum nl80211_iftype t, *iftype = data;
+ enum nl80211_iftype t, *iftype = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*iftype = NL80211_IFTYPE_UNSPECIFIED;
diff --git a/src/network/networkd-address-generation.c b/src/network/networkd-address-generation.c
index 2dedcf3723..769cccf748 100644
--- a/src/network/networkd-address-generation.c
+++ b/src/network/networkd-address-generation.c
@@ -328,14 +328,13 @@ int config_parse_address_generation_type(
sd_id128_t secret_key = SD_ID128_NULL;
union in_addr_union buffer = {};
AddressGenerationType type;
- Set **tokens = data;
+ Set **tokens = ASSERT_PTR(data);
const char *addr;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*tokens = set_free(*tokens);
diff --git a/src/network/networkd-can.c b/src/network/networkd-can.c
index a3d5b68f6f..b8a1871a35 100644
--- a/src/network/networkd-can.c
+++ b/src/network/networkd-can.c
@@ -149,14 +149,13 @@ int config_parse_can_bitrate(
void *data,
void *userdata) {
- uint32_t *br = data;
+ uint32_t *br = ASSERT_PTR(data);
uint64_t sz;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = parse_size(rvalue, 1000, &sz);
if (r < 0) {
@@ -189,13 +188,12 @@ int config_parse_can_time_quanta(
void *data,
void *userdata) {
- nsec_t val, *tq = data;
+ nsec_t val, *tq = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = parse_nsec(rvalue, &val);
if (r < 0) {
@@ -227,13 +225,12 @@ int config_parse_can_restart_usec(
void *data,
void *userdata) {
- usec_t usec, *restart_usec = data;
+ usec_t usec, *restart_usec = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = parse_sec(rvalue, &usec);
if (r < 0) {
@@ -265,14 +262,13 @@ int config_parse_can_control_mode(
void *data,
void *userdata) {
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
uint32_t mask = ltype;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(userdata);
assert(mask != 0);
if (isempty(rvalue)) {
diff --git a/src/network/networkd-dhcp-common.c b/src/network/networkd-dhcp-common.c
index 9477127885..6526d3378f 100644
--- a/src/network/networkd-dhcp-common.c
+++ b/src/network/networkd-dhcp-common.c
@@ -131,14 +131,13 @@ const DUID *link_get_duid(Link *link, int family) {
}
static int get_product_uuid_handler(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
- Manager *manager = userdata;
+ Manager *manager = ASSERT_PTR(userdata);
const sd_bus_error *e;
const void *a;
size_t sz;
int r;
assert(m);
- assert(manager);
/* To avoid calling GetProductUUID() bus method so frequently, set the flag below
* even if the method fails. */
@@ -521,7 +520,7 @@ int config_parse_dhcp_or_ra_route_table(
void *data,
void *userdata) {
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
uint32_t rt;
int r;
@@ -529,7 +528,6 @@ int config_parse_dhcp_or_ra_route_table(
assert(lvalue);
assert(IN_SET(ltype, AF_INET, AF_INET6));
assert(rvalue);
- assert(userdata);
r = safe_atou32(rvalue, &rt);
if (r < 0) {
@@ -566,14 +564,13 @@ int config_parse_iaid(
void *data,
void *userdata) {
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
uint32_t iaid;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(network);
assert(IN_SET(ltype, AF_INET, AF_INET6));
r = safe_atou32(rvalue, &iaid);
@@ -614,10 +611,9 @@ int config_parse_dhcp_user_or_vendor_class(
void *data,
void *userdata) {
- char ***l = data;
+ char ***l = ASSERT_PTR(data);
int r;
- assert(l);
assert(lvalue);
assert(rvalue);
assert(IN_SET(ltype, AF_INET, AF_INET6));
@@ -681,7 +677,7 @@ int config_parse_dhcp_send_option(
_unused_ _cleanup_(sd_dhcp6_option_unrefp) sd_dhcp6_option *old6 = NULL;
uint32_t uint32_data, enterprise_identifier = 0;
_cleanup_free_ char *word = NULL, *q = NULL;
- OrderedHashmap **options = data;
+ OrderedHashmap **options = ASSERT_PTR(data);
uint16_t u16, uint16_data;
union in_addr_union addr;
DHCPOptionDataType type;
@@ -694,7 +690,6 @@ int config_parse_dhcp_send_option(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*options = ordered_hashmap_free(*options);
@@ -1005,16 +1000,14 @@ int config_parse_duid_type(
void *userdata) {
_cleanup_free_ char *type_string = NULL;
- const char *p = rvalue;
+ const char *p = ASSERT_PTR(rvalue);
bool force = ltype;
- DUID *duid = data;
+ DUID *duid = ASSERT_PTR(data);
DUIDType type;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
- assert(duid);
if (!force && duid->set)
return 0;
@@ -1077,11 +1070,9 @@ int config_parse_manager_duid_type(
void *data,
void *userdata) {
- Manager *manager = userdata;
+ Manager *manager = ASSERT_PTR(userdata);
int r;
- assert(manager);
-
/* For backward compatibility. Setting both DHCPv4 and DHCPv6 DUID if they are not specified explicitly. */
r = config_parse_duid_type(unit, filename, line, section, section_line, lvalue, false, rvalue, &manager->dhcp_duid, manager);
@@ -1103,11 +1094,9 @@ int config_parse_network_duid_type(
void *data,
void *userdata) {
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
int r;
- assert(network);
-
r = config_parse_duid_type(unit, filename, line, section, section_line, lvalue, true, rvalue, &network->dhcp_duid, network);
if (r < 0)
return r;
@@ -1131,12 +1120,11 @@ int config_parse_duid_rawdata(
uint8_t raw_data[MAX_DUID_LEN];
unsigned count = 0;
bool force = ltype;
- DUID *duid = data;
+ DUID *duid = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(duid);
if (!force && duid->set)
return 0;
@@ -1202,11 +1190,9 @@ int config_parse_manager_duid_rawdata(
void *data,
void *userdata) {
- Manager *manager = userdata;
+ Manager *manager = ASSERT_PTR(userdata);
int r;
- assert(manager);
-
/* For backward compatibility. Setting both DHCPv4 and DHCPv6 DUID if they are not specified explicitly. */
r = config_parse_duid_rawdata(unit, filename, line, section, section_line, lvalue, false, rvalue, &manager->dhcp_duid, manager);
@@ -1228,11 +1214,9 @@ int config_parse_network_duid_rawdata(
void *data,
void *userdata) {
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
int r;
- assert(network);
-
r = config_parse_duid_rawdata(unit, filename, line, section, section_line, lvalue, true, rvalue, &network->dhcp_duid, network);
if (r < 0)
return r;
@@ -1253,7 +1237,7 @@ int config_parse_uplink(
void *data,
void *userdata) {
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
bool accept_none = true;
int *index, r;
char **name;
@@ -1262,7 +1246,6 @@ int config_parse_uplink(
assert(section);
assert(lvalue);
assert(rvalue);
- assert(userdata);
if (streq(section, "DHCPServer")) {
index = &network->dhcp_server_uplink_index;
diff --git a/src/network/networkd-dhcp-prefix-delegation.c b/src/network/networkd-dhcp-prefix-delegation.c
index ee5e521e75..a78a7e5789 100644
--- a/src/network/networkd-dhcp-prefix-delegation.c
+++ b/src/network/networkd-dhcp-prefix-delegation.c
@@ -1261,14 +1261,13 @@ int config_parse_dhcp_pd_subnet_id(
void *data,
void *userdata) {
- int64_t *p = data;
+ int64_t *p = ASSERT_PTR(data);
uint64_t t;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue) || streq(rvalue, "auto")) {
*p = -1;
diff --git a/src/network/networkd-dhcp-server-bus.c b/src/network/networkd-dhcp-server-bus.c
index cc132da8b7..e3397c3208 100644
--- a/src/network/networkd-dhcp-server-bus.c
+++ b/src/network/networkd-dhcp-server-bus.c
@@ -17,13 +17,12 @@ static int property_get_leases(
sd_bus_message *reply,
void *userdata,
sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
sd_dhcp_server *s;
DHCPLease *lease;
int r;
assert(reply);
- assert(l);
s = l->dhcp_server;
if (!s)
@@ -96,9 +95,7 @@ static int dhcp_server_emit_changed(Link *link, const char *property, ...) {
}
void dhcp_server_callback(sd_dhcp_server *s, uint64_t event, void *data) {
- Link *l = data;
-
- assert(l);
+ Link *l = ASSERT_PTR(data);
if (event & SD_DHCP_SERVER_EVENT_LEASE_CHANGED)
(void) dhcp_server_emit_changed(l, "Leases", NULL);
diff --git a/src/network/networkd-dhcp-server-static-lease.c b/src/network/networkd-dhcp-server-static-lease.c
index 38e8c7e889..8e7eec64d1 100644
--- a/src/network/networkd-dhcp-server-static-lease.c
+++ b/src/network/networkd-dhcp-server-static-lease.c
@@ -114,14 +114,13 @@ int config_parse_dhcp_static_lease_address(
void *userdata) {
_cleanup_(dhcp_static_lease_free_or_set_invalidp) DHCPStaticLease *lease = NULL;
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
union in_addr_union addr;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(network);
r = lease_new_static(network, filename, section_line, &lease);
if (r < 0)
@@ -164,7 +163,7 @@ int config_parse_dhcp_static_lease_hwaddr(
void *userdata) {
_cleanup_(dhcp_static_lease_free_or_set_invalidp) DHCPStaticLease *lease = NULL;
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
struct ether_addr hwaddr;
uint8_t *c;
int r;
@@ -172,7 +171,6 @@ int config_parse_dhcp_static_lease_hwaddr(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(network);
r = lease_new_static(network, filename, section_line, &lease);
if (r < 0)
diff --git a/src/network/networkd-dhcp-server.c b/src/network/networkd-dhcp-server.c
index e36627cd57..620fbbddc7 100644
--- a/src/network/networkd-dhcp-server.c
+++ b/src/network/networkd-dhcp-server.c
@@ -640,9 +640,8 @@ int config_parse_dhcp_server_emit(
void *data,
void *userdata) {
- NetworkDHCPServerEmitAddress *emit = data;
+ NetworkDHCPServerEmitAddress *emit = ASSERT_PTR(data);
- assert(emit);
assert(rvalue);
if (isempty(rvalue)) {
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index 02deac0033..afe80460a0 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -1063,10 +1063,9 @@ static int dhcp_server_is_filtered(Link *link, sd_dhcp_client *client) {
}
static int dhcp4_handler(sd_dhcp_client *client, int event, void *userdata) {
- Link *link = userdata;
+ Link *link = ASSERT_PTR(userdata);
int r;
- assert(link);
assert(link->network);
assert(link->manager);
@@ -1630,11 +1629,10 @@ int config_parse_dhcp_max_attempts(
void *data,
void *userdata) {
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint64_t a;
int r;
- assert(network);
assert(lvalue);
assert(rvalue);
@@ -1678,12 +1676,11 @@ int config_parse_dhcp_ip_service_type(
void *data,
void *userdata) {
- int *tos = data;
+ int *tos = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue))
*tos = -1; /* use sd_dhcp_client's default (currently, CS6). */
@@ -1749,12 +1746,11 @@ int config_parse_dhcp_label(
void *data,
void *userdata) {
- char **label = data;
+ char **label = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*label = mfree(*label);
diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c
index 501e210d5f..086a6f4b61 100644
--- a/src/network/networkd-dhcp6.c
+++ b/src/network/networkd-dhcp6.c
@@ -367,10 +367,9 @@ static int dhcp6_lease_lost(Link *link) {
}
static void dhcp6_handler(sd_dhcp6_client *client, int event, void *userdata) {
- Link *link = userdata;
+ Link *link = ASSERT_PTR(userdata);
int r;
- assert(link);
assert(link->network);
if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER))
@@ -821,7 +820,7 @@ int config_parse_dhcp6_pd_prefix_hint(
void *data,
void *userdata) {
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
union in_addr_union u;
unsigned char prefixlen;
int r;
@@ -829,7 +828,6 @@ int config_parse_dhcp6_pd_prefix_hint(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(userdata);
r = in_addr_prefix_from_string(rvalue, AF_INET6, &u, &prefixlen);
if (r < 0) {
diff --git a/src/network/networkd-ipv4acd.c b/src/network/networkd-ipv4acd.c
index a633575444..4127657ebd 100644
--- a/src/network/networkd-ipv4acd.c
+++ b/src/network/networkd-ipv4acd.c
@@ -116,12 +116,11 @@ static int dhcp4_address_on_conflict(Link *link, Address *address) {
}
static void on_acd(sd_ipv4acd *acd, int event, void *userdata) {
- Address *address = userdata;
+ Address *address = ASSERT_PTR(userdata);
Link *link;
int r;
assert(acd);
- assert(address);
assert(address->acd == acd);
assert(address->link);
assert(address->family == AF_INET);
@@ -170,10 +169,9 @@ static void on_acd(sd_ipv4acd *acd, int event, void *userdata) {
}
static int ipv4acd_check_mac(sd_ipv4acd *acd, const struct ether_addr *mac, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
struct hw_addr_data hw_addr;
- assert(m);
assert(mac);
hw_addr = (struct hw_addr_data) {
diff --git a/src/network/networkd-ipv4ll.c b/src/network/networkd-ipv4ll.c
index 8b0849d2d2..8450b346b1 100644
--- a/src/network/networkd-ipv4ll.c
+++ b/src/network/networkd-ipv4ll.c
@@ -124,10 +124,9 @@ static int ipv4ll_address_claimed(sd_ipv4ll *ll, Link *link) {
}
static void ipv4ll_handler(sd_ipv4ll *ll, int event, void *userdata) {
- Link *link = userdata;
+ Link *link = ASSERT_PTR(userdata);
int r;
- assert(link);
assert(link->network);
if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER))
@@ -169,10 +168,9 @@ static void ipv4ll_handler(sd_ipv4ll *ll, int event, void *userdata) {
}
static int ipv4ll_check_mac(sd_ipv4ll *ll, const struct ether_addr *mac, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
struct hw_addr_data hw_addr;
- assert(m);
assert(mac);
hw_addr = (struct hw_addr_data) {
@@ -250,13 +248,12 @@ int config_parse_ipv4ll(
void *data,
void *userdata) {
- AddressFamily *link_local = data;
+ AddressFamily *link_local = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
/* Note that this is mostly like
* config_parse_address_family(), except that it
diff --git a/src/network/networkd-ipv6-proxy-ndp.c b/src/network/networkd-ipv6-proxy-ndp.c
index 8166851ed3..edd369a9e7 100644
--- a/src/network/networkd-ipv6-proxy-ndp.c
+++ b/src/network/networkd-ipv6-proxy-ndp.c
@@ -141,13 +141,12 @@ int config_parse_ipv6_proxy_ndp_address(
void *userdata) {
_cleanup_free_ struct in6_addr *address = NULL;
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
union in_addr_union buffer;
int r;
assert(filename);
assert(rvalue);
- assert(network);
if (isempty(rvalue)) {
network->ipv6_proxy_ndp_addresses = set_free_free(network->ipv6_proxy_ndp_addresses);
diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c
index 4173eaa15f..193d1d3e1e 100644
--- a/src/network/networkd-link-bus.c
+++ b/src/network/networkd-link-bus.c
@@ -36,14 +36,13 @@ static int property_get_bit_rates(
void *userdata,
sd_bus_error *error) {
- Link *link = userdata;
+ Link *link = ASSERT_PTR(userdata);
Manager *manager;
double interval_sec;
uint64_t tx, rx;
assert(bus);
assert(reply);
- assert(userdata);
manager = link->manager;
@@ -79,11 +78,10 @@ static int verify_managed_link(Link *l, sd_bus_error *error) {
int bus_link_method_set_ntp_servers(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_strv_free_ char **ntp = NULL;
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
int r;
assert(message);
- assert(l);
r = verify_managed_link(l, error);
if (r < 0)
@@ -122,12 +120,11 @@ int bus_link_method_set_ntp_servers(sd_bus_message *message, void *userdata, sd_
static int bus_link_method_set_dns_servers_internal(sd_bus_message *message, void *userdata, sd_bus_error *error, bool extended) {
struct in_addr_full **dns;
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
size_t n;
int r;
assert(message);
- assert(l);
r = verify_managed_link(l, error);
if (r < 0)
@@ -180,11 +177,10 @@ int bus_link_method_set_dns_servers_ex(sd_bus_message *message, void *userdata,
int bus_link_method_set_domains(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_ordered_set_free_ OrderedSet *search_domains = NULL, *route_domains = NULL;
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
int r;
assert(message);
- assert(l);
r = verify_managed_link(l, error);
if (r < 0)
@@ -259,11 +255,10 @@ int bus_link_method_set_domains(sd_bus_message *message, void *userdata, sd_bus_
}
int bus_link_method_set_default_route(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
int r, b;
assert(message);
- assert(l);
r = verify_managed_link(l, error);
if (r < 0)
@@ -295,13 +290,12 @@ int bus_link_method_set_default_route(sd_bus_message *message, void *userdata, s
}
int bus_link_method_set_llmnr(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
ResolveSupport mode;
const char *llmnr;
int r;
assert(message);
- assert(l);
r = verify_managed_link(l, error);
if (r < 0)
@@ -341,13 +335,12 @@ int bus_link_method_set_llmnr(sd_bus_message *message, void *userdata, sd_bus_er
}
int bus_link_method_set_mdns(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
ResolveSupport mode;
const char *mdns;
int r;
assert(message);
- assert(l);
r = verify_managed_link(l, error);
if (r < 0)
@@ -387,13 +380,12 @@ int bus_link_method_set_mdns(sd_bus_message *message, void *userdata, sd_bus_err
}
int bus_link_method_set_dns_over_tls(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
const char *dns_over_tls;
DnsOverTlsMode mode;
int r;
assert(message);
- assert(l);
r = verify_managed_link(l, error);
if (r < 0)
@@ -433,13 +425,12 @@ int bus_link_method_set_dns_over_tls(sd_bus_message *message, void *userdata, sd
}
int bus_link_method_set_dnssec(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
const char *dnssec;
DnssecMode mode;
int r;
assert(message);
- assert(l);
r = verify_managed_link(l, error);
if (r < 0)
@@ -481,11 +472,10 @@ int bus_link_method_set_dnssec(sd_bus_message *message, void *userdata, sd_bus_e
int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_set_free_free_ Set *ns = NULL;
_cleanup_strv_free_ char **ntas = NULL;
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
int r;
assert(message);
- assert(l);
r = verify_managed_link(l, error);
if (r < 0)
@@ -534,11 +524,10 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v
}
int bus_link_method_revert_ntp(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
int r;
assert(message);
- assert(l);
r = verify_managed_link(l, error);
if (r < 0)
@@ -564,11 +553,10 @@ int bus_link_method_revert_ntp(sd_bus_message *message, void *userdata, sd_bus_e
}
int bus_link_method_revert_dns(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
int r;
assert(message);
- assert(l);
r = verify_managed_link(l, error);
if (r < 0)
@@ -594,11 +582,9 @@ int bus_link_method_revert_dns(sd_bus_message *message, void *userdata, sd_bus_e
}
int bus_link_method_force_renew(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
int r;
- assert(l);
-
if (!l->network)
return sd_bus_error_setf(error, BUS_ERROR_UNMANAGED_INTERFACE,
"Interface %s is not managed by systemd-networkd",
@@ -623,11 +609,9 @@ int bus_link_method_force_renew(sd_bus_message *message, void *userdata, sd_bus_
}
int bus_link_method_renew(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
int r;
- assert(l);
-
if (!l->network)
return sd_bus_error_setf(error, BUS_ERROR_UNMANAGED_INTERFACE,
"Interface %s is not managed by systemd-networkd",
@@ -652,11 +636,10 @@ int bus_link_method_renew(sd_bus_message *message, void *userdata, sd_bus_error
}
int bus_link_method_reconfigure(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
int r;
assert(message);
- assert(l);
r = bus_verify_polkit_async(message, CAP_NET_ADMIN,
"org.freedesktop.network1.reconfigure",
@@ -684,11 +667,10 @@ int bus_link_method_describe(sd_bus_message *message, void *userdata, sd_bus_err
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
_cleanup_free_ char *text = NULL;
- Link *link = userdata;
+ Link *link = ASSERT_PTR(userdata);
int r;
assert(message);
- assert(link);
r = link_build_json(link, &v);
if (r < 0)
@@ -825,13 +807,12 @@ char *link_bus_path(Link *link) {
int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
unsigned c = 0;
Link *link;
assert(bus);
assert(path);
- assert(m);
assert(nodes);
l = new0(char*, hashmap_size(m->links_by_index) + 1);
@@ -856,14 +837,13 @@ int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***
int link_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
_cleanup_free_ char *identifier = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
Link *link;
int ifindex, r;
assert(bus);
assert(path);
assert(interface);
- assert(m);
assert(found);
r = sd_bus_path_decode(path, "/org/freedesktop/network1/link", &identifier);
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 06e9822251..5733521611 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -1589,11 +1589,9 @@ static int link_carrier_lost_impl(Link *link) {
}
static int link_carrier_lost_handler(sd_event_source *s, uint64_t usec, void *userdata) {
- Link *link = userdata;
+ Link *link = ASSERT_PTR(userdata);
int r;
- assert(link);
-
r = link_carrier_lost_impl(link);
if (r < 0) {
log_link_warning_errno(link, r, "Failed to process carrier lost event: %m");
diff --git a/src/network/networkd-lldp-rx.c b/src/network/networkd-lldp-rx.c
index 3ae4cada9e..3a5988405f 100644
--- a/src/network/networkd-lldp-rx.c
+++ b/src/network/networkd-lldp-rx.c
@@ -49,11 +49,9 @@ static bool link_lldp_rx_enabled(Link *link) {
}
static void lldp_rx_handler(sd_lldp_rx *lldp_rx, sd_lldp_rx_event_t event, sd_lldp_neighbor *n, void *userdata) {
- Link *link = userdata;
+ Link *link = ASSERT_PTR(userdata);
int r;
- assert(link);
-
(void) link_lldp_save(link);
if (link->lldp_tx && event == SD_LLDP_RX_EVENT_ADDED) {
diff --git a/src/network/networkd-lldp-tx.c b/src/network/networkd-lldp-tx.c
index d547efa768..fc9196fc8b 100644
--- a/src/network/networkd-lldp-tx.c
+++ b/src/network/networkd-lldp-tx.c
@@ -106,14 +106,13 @@ int config_parse_lldp_multicast_mode(
void *data,
void *userdata) {
- sd_lldp_multicast_mode_t m, *mode = data;
+ sd_lldp_multicast_mode_t m, *mode = ASSERT_PTR(data);
int r;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
- assert(mode);
if (isempty(rvalue)) {
*mode = _SD_LLDP_MULTICAST_MODE_INVALID;
diff --git a/src/network/networkd-manager-bus.c b/src/network/networkd-manager-bus.c
index 4c517d829a..2ab3aaadc2 100644
--- a/src/network/networkd-manager-bus.c
+++ b/src/network/networkd-manager-bus.c
@@ -234,11 +234,10 @@ static int bus_method_describe(sd_bus_message *message, void *userdata, sd_bus_e
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
_cleanup_free_ char *text = NULL;
- Manager *manager = userdata;
+ Manager *manager = ASSERT_PTR(userdata);
int r;
assert(message);
- assert(manager);
r = manager_build_json(manager, &v);
if (r < 0)
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index afdce76a18..cdfd29bc0e 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -82,11 +82,10 @@ static int manager_reset_all(Manager *m) {
}
static int match_prepare_for_sleep(sd_bus_message *message, void *userdata, sd_bus_error *ret_error) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
int b, r;
assert(message);
- assert(m);
r = sd_bus_message_read(message, "b", &b);
if (r < 0) {
@@ -105,10 +104,9 @@ static int match_prepare_for_sleep(sd_bus_message *message, void *userdata, sd_b
}
static int on_connected(sd_bus_message *message, void *userdata, sd_bus_error *ret_error) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
assert(message);
- assert(m);
/* Did we get a timezone or transient hostname from DHCP while D-Bus wasn't up yet? */
if (m->dynamic_hostname)
@@ -446,12 +444,10 @@ static int manager_connect_rtnl(Manager *m, int fd) {
}
static int manager_dirty_handler(sd_event_source *s, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
Link *link;
int r;
- assert(m);
-
if (m->dirty) {
r = manager_save(m);
if (r < 0)
@@ -468,9 +464,8 @@ static int manager_dirty_handler(sd_event_source *s, void *userdata) {
}
static int signal_terminate_callback(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
- assert(m);
m->restarting = false;
log_debug("Terminate operation initiated.");
@@ -479,9 +474,8 @@ static int signal_terminate_callback(sd_event_source *s, const struct signalfd_s
}
static int signal_restart_callback(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
- assert(m);
m->restarting = true;
log_debug("Restart operation initiated.");
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c
index 8e6e787536..d0508f93c0 100644
--- a/src/network/networkd-ndisc.c
+++ b/src/network/networkd-ndisc.c
@@ -1009,11 +1009,9 @@ static int ndisc_router_handler(Link *link, sd_ndisc_router *rt) {
}
static void ndisc_handler(sd_ndisc *nd, sd_ndisc_event_t event, sd_ndisc_router *rt, void *userdata) {
- Link *link = userdata;
+ Link *link = ASSERT_PTR(userdata);
int r;
- assert(link);
-
if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER))
return;
diff --git a/src/network/networkd-neighbor.c b/src/network/networkd-neighbor.c
index f11f06001b..f0f78b9c4a 100644
--- a/src/network/networkd-neighbor.c
+++ b/src/network/networkd-neighbor.c
@@ -607,14 +607,13 @@ int config_parse_neighbor_address(
void *userdata) {
_cleanup_(neighbor_free_or_set_invalidp) Neighbor *n = NULL;
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
- assert(userdata);
r = neighbor_new_static(network, filename, section_line, &n);
if (r < 0)
@@ -651,14 +650,13 @@ int config_parse_neighbor_lladdr(
void *userdata) {
_cleanup_(neighbor_free_or_set_invalidp) Neighbor *n = NULL;
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
- assert(userdata);
r = neighbor_new_static(network, filename, section_line, &n);
if (r < 0)
diff --git a/src/network/networkd-network-bus.c b/src/network/networkd-network-bus.c
index 5b3e4eee30..e1e89e8357 100644
--- a/src/network/networkd-network-bus.c
+++ b/src/network/networkd-network-bus.c
@@ -84,13 +84,12 @@ static char *network_bus_path(Network *network) {
int network_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
Network *network;
int r;
assert(bus);
assert(path);
- assert(m);
assert(nodes);
ORDERED_HASHMAP_FOREACH(network, m->networks) {
@@ -111,7 +110,7 @@ int network_node_enumerator(sd_bus *bus, const char *path, void *userdata, char
}
int network_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);
Network *network;
_cleanup_free_ char *name = NULL;
int r;
@@ -119,7 +118,6 @@ int network_object_find(sd_bus *bus, const char *path, const char *interface, vo
assert(bus);
assert(path);
assert(interface);
- assert(m);
assert(found);
r = sd_bus_path_decode(path, "/org/freedesktop/network1/network", &name);
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index 1de99e89ab..a6c5b44238 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -850,13 +850,12 @@ int config_parse_stacked_netdev(
_cleanup_free_ char *name = NULL;
NetDevKind kind = ltype;
- Hashmap **h = data;
+ Hashmap **h = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
assert(IN_SET(kind,
NETDEV_KIND_IPOIB,
NETDEV_KIND_IPVLAN,
@@ -906,13 +905,12 @@ int config_parse_domains(
void *data,
void *userdata) {
- Network *n = userdata;
+ Network *n = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(n);
if (isempty(rvalue)) {
n->search_domains = ordered_set_free(n->search_domains);
@@ -984,13 +982,12 @@ int config_parse_timezone(
void *data,
void *userdata) {
- char **tz = data;
+ char **tz = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*tz = mfree(*tz);
@@ -1019,13 +1016,12 @@ int config_parse_dns(
void *data,
void *userdata) {
- Network *n = userdata;
+ Network *n = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(n);
if (isempty(rvalue)) {
for (unsigned i = 0; i < n->n_dns; i++)
@@ -1082,13 +1078,12 @@ int config_parse_dnssec_negative_trust_anchors(
void *data,
void *userdata) {
- Set **nta = data;
+ Set **nta = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(nta);
if (isempty(rvalue)) {
*nta = set_free_free(*nta);
@@ -1134,13 +1129,12 @@ int config_parse_ntp(
void *data,
void *userdata) {
- char ***l = data;
+ char ***l = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(l);
if (isempty(rvalue)) {
*l = strv_free(*l);
@@ -1193,7 +1187,7 @@ int config_parse_required_for_online(
void *data,
void *userdata) {
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
LinkOperationalStateRange range;
bool required = true;
int r;
@@ -1201,7 +1195,6 @@ int config_parse_required_for_online(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(network);
if (isempty(rvalue)) {
network->required_for_online = -1;
@@ -1241,14 +1234,13 @@ int config_parse_link_group(
void *data,
void *userdata) {
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
int r;
int32_t group;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(network);
if (isempty(rvalue)) {
network->group = -1;
@@ -1284,14 +1276,13 @@ int config_parse_ignore_carrier_loss(
void *data,
void *userdata) {
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
usec_t usec;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(network);
if (isempty(rvalue)) {
network->ignore_carrier_loss_set = false;
diff --git a/src/network/networkd-radv.c b/src/network/networkd-radv.c
index a0ce162532..ce4ab47ef9 100644
--- a/src/network/networkd-radv.c
+++ b/src/network/networkd-radv.c
@@ -795,7 +795,7 @@ int config_parse_prefix(
void *userdata) {
_cleanup_(prefix_free_or_set_invalidp) Prefix *p = NULL;
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
union in_addr_union a;
int r;
@@ -803,7 +803,6 @@ int config_parse_prefix(
assert(section);
assert(lvalue);
assert(rvalue);
- assert(userdata);
r = prefix_new_static(network, filename, section_line, &p);
if (r < 0)
@@ -836,14 +835,13 @@ int config_parse_prefix_boolean(
void *userdata) {
_cleanup_(prefix_free_or_set_invalidp) Prefix *p = NULL;
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
- assert(userdata);
r = prefix_new_static(network, filename, section_line, &p);
if (r < 0)
@@ -882,7 +880,7 @@ int config_parse_prefix_lifetime(
void *userdata) {
_cleanup_(prefix_free_or_set_invalidp) Prefix *p = NULL;
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
usec_t usec;
int r;
@@ -890,7 +888,6 @@ int config_parse_prefix_lifetime(
assert(section);
assert(lvalue);
assert(rvalue);
- assert(userdata);
r = prefix_new_static(network, filename, section_line, &p);
if (r < 0)
@@ -933,14 +930,13 @@ int config_parse_prefix_metric(
void *userdata) {
_cleanup_(prefix_free_or_set_invalidp) Prefix *p = NULL;
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
- assert(userdata);
r = prefix_new_static(network, filename, section_line, &p);
if (r < 0)
@@ -971,14 +967,13 @@ int config_parse_prefix_token(
void *userdata) {
_cleanup_(prefix_free_or_set_invalidp) Prefix *p = NULL;
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
- assert(userdata);
r = prefix_new_static(network, filename, section_line, &p);
if (r < 0)
@@ -1006,7 +1001,7 @@ int config_parse_route_prefix(
void *userdata) {
_cleanup_(route_prefix_free_or_set_invalidp) RoutePrefix *p = NULL;
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
union in_addr_union a;
int r;
@@ -1014,7 +1009,6 @@ int config_parse_route_prefix(
assert(section);
assert(lvalue);
assert(rvalue);
- assert(userdata);
r = route_prefix_new_static(network, filename, section_line, &p);
if (r < 0)
@@ -1047,7 +1041,7 @@ int config_parse_route_prefix_lifetime(
void *userdata) {
_cleanup_(route_prefix_free_or_set_invalidp) RoutePrefix *p = NULL;
- Network *network = userdata;
+ Network *network = ASSERT_PTR(userdata);
usec_t usec;
int r;
@@ -1055,7 +1049,6 @@ int config_parse_route_prefix_lifetime(
assert(section);
assert(lvalue);
assert(rvalue);
- assert(userdata);
r = route_prefix_new_static(network, filename, section_line, &p);
if (r < 0)
@@ -1228,13 +1221,12 @@ int config_parse_router_prefix_delegation(
void *data,
void *userdata) {
- RADVPrefixDelegation val, *ra = data;
+ RADVPrefixDelegation val, *ra = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (streq(lvalue, "IPv6SendRA")) {
r = parse_boolean(rvalue);
@@ -1274,14 +1266,13 @@ int config_parse_router_lifetime(
void *data,
void *userdata) {
- usec_t usec, *lifetime = data;
+ usec_t usec, *lifetime = ASSERT_PTR(data);
int r;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*lifetime = RADV_DEFAULT_ROUTER_LIFETIME_USEC;
diff --git a/src/network/networkd-route-util.c b/src/network/networkd-route-util.c
index 4c9920b609..312f5f298a 100644
--- a/src/network/networkd-route-util.c
+++ b/src/network/networkd-route-util.c
@@ -449,13 +449,12 @@ int config_parse_route_table_names(
void *data,
void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(userdata);
if (isempty(rvalue)) {
m->route_table_names_by_number = hashmap_free(m->route_table_names_by_number);
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 3c84d80e4d..6b3708573c 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -1016,11 +1016,10 @@ void link_foreignize_routes(Link *link) {
}
static int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata) {
- Route *route = userdata;
+ Route *route = ASSERT_PTR(userdata);
Link *link;
int r;
- assert(route);
assert(route->manager || (route->link && route->link->manager));
link = route->link; /* This may be NULL. */
diff --git a/src/network/networkd-speed-meter.c b/src/network/networkd-speed-meter.c
index 34e8614520..cf8294ef95 100644
--- a/src/network/networkd-speed-meter.c
+++ b/src/network/networkd-speed-meter.c
@@ -43,13 +43,12 @@ static int process_message(Manager *manager, sd_netlink_message *message) {
static int speed_meter_handler(sd_event_source *s, uint64_t usec, void *userdata) {
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL, *reply = NULL;
- Manager *manager = userdata;
+ Manager *manager = ASSERT_PTR(userdata);
usec_t usec_now;
Link *link;
int r;
assert(s);
- assert(userdata);
r = sd_event_now(sd_event_source_get_event(s), CLOCK_MONOTONIC, &usec_now);
if (r < 0)
diff --git a/src/network/networkd-sysctl.c b/src/network/networkd-sysctl.c
index 894e608815..51a697a667 100644
--- a/src/network/networkd-sysctl.c
+++ b/src/network/networkd-sysctl.c
@@ -327,12 +327,11 @@ int config_parse_ipv6_privacy_extensions(
void *data,
void *userdata) {
- IPv6PrivacyExtensions s, *ipv6_privacy_extensions = data;
+ IPv6PrivacyExtensions s, *ipv6_privacy_extensions = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(ipv6_privacy_extensions);
s = ipv6_privacy_extensions_from_string(rvalue);
if (s < 0) {
diff --git a/src/network/networkd-util.c b/src/network/networkd-util.c
index aa1b5ed172..69347d80ff 100644
--- a/src/network/networkd-util.c
+++ b/src/network/networkd-util.c
@@ -213,13 +213,12 @@ int config_parse_mud_url(
void *userdata) {
_cleanup_free_ char *unescaped = NULL;
- char **url = data;
+ char **url = ASSERT_PTR(data);
ssize_t l;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(url);
if (isempty(rvalue)) {
*url = mfree(*url);
diff --git a/src/network/tc/cake.c b/src/network/tc/cake.c
index d52151e75d..8d770b0896 100644
--- a/src/network/tc/cake.c
+++ b/src/network/tc/cake.c
@@ -139,14 +139,13 @@ int config_parse_cake_bandwidth(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
CommonApplicationsKeptEnhanced *c;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint64_t k;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -194,14 +193,13 @@ int config_parse_cake_overhead(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
CommonApplicationsKeptEnhanced *c;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int32_t v;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -254,14 +252,13 @@ int config_parse_cake_mpu(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
CommonApplicationsKeptEnhanced *c;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint32_t v;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -313,13 +310,12 @@ int config_parse_cake_tristate(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
CommonApplicationsKeptEnhanced *c;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int *dest, r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -386,14 +382,13 @@ int config_parse_cake_compensation_mode(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
CommonApplicationsKeptEnhanced *c;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
CakeCompensationMode mode;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -452,14 +447,13 @@ int config_parse_cake_flow_isolation_mode(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
CommonApplicationsKeptEnhanced *c;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
CakeFlowIsolationMode mode;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -516,13 +510,12 @@ int config_parse_cake_priority_queueing_preset(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
CommonApplicationsKeptEnhanced *c;
CakePriorityQueueingPreset preset;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -568,14 +561,13 @@ int config_parse_cake_fwmark(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
CommonApplicationsKeptEnhanced *c;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint32_t fwmark;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_CAKE, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/codel.c b/src/network/tc/codel.c
index 23351bf3d1..b5f95f7ed2 100644
--- a/src/network/tc/codel.c
+++ b/src/network/tc/codel.c
@@ -88,13 +88,12 @@ int config_parse_controlled_delay_u32(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
ControlledDelay *cd;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_CODEL, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -141,14 +140,13 @@ int config_parse_controlled_delay_usec(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
ControlledDelay *cd;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
usec_t *p;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_CODEL, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -207,13 +205,12 @@ int config_parse_controlled_delay_bool(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
ControlledDelay *cd;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_CODEL, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/drr.c b/src/network/tc/drr.c
index 742a56f8c9..373911bc70 100644
--- a/src/network/tc/drr.c
+++ b/src/network/tc/drr.c
@@ -56,14 +56,13 @@ int config_parse_drr_size(
_cleanup_(tclass_free_or_set_invalidp) TClass *tclass = NULL;
DeficitRoundRobinSchedulerClass *drr;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint64_t u;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = tclass_new_static(TCLASS_KIND_DRR, network, filename, section_line, &tclass);
if (r == -ENOMEM)
diff --git a/src/network/tc/ets.c b/src/network/tc/ets.c
index 00c46f24a4..730b0a10c3 100644
--- a/src/network/tc/ets.c
+++ b/src/network/tc/ets.c
@@ -90,14 +90,13 @@ int config_parse_ets_u8(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
EnhancedTransmissionSelection *ets;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint8_t v, *p;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_ETS, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -157,13 +156,12 @@ int config_parse_ets_quanta(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
EnhancedTransmissionSelection *ets;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_ETS, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -241,13 +239,12 @@ int config_parse_ets_prio(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
EnhancedTransmissionSelection *ets;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_ETS, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/fifo.c b/src/network/tc/fifo.c
index 948d071863..940fa0062f 100644
--- a/src/network/tc/fifo.c
+++ b/src/network/tc/fifo.c
@@ -53,14 +53,13 @@ int config_parse_pfifo_size(
void *userdata) {
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
FirstInFirstOut *fifo;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(ltype, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -114,7 +113,7 @@ int config_parse_bfifo_size(
void *userdata) {
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
FirstInFirstOut *fifo;
uint64_t u;
int r;
@@ -122,7 +121,6 @@ int config_parse_bfifo_size(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_BFIFO, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/fq-codel.c b/src/network/tc/fq-codel.c
index 42dfd632a2..50ec203e5b 100644
--- a/src/network/tc/fq-codel.c
+++ b/src/network/tc/fq-codel.c
@@ -108,14 +108,13 @@ int config_parse_fair_queueing_controlled_delay_u32(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
FairQueueingControlledDelay *fqcd;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint32_t *p;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_FQ_CODEL, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -169,14 +168,13 @@ int config_parse_fair_queueing_controlled_delay_usec(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
FairQueueingControlledDelay *fqcd;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
usec_t *p;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_FQ_CODEL, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -235,13 +233,12 @@ int config_parse_fair_queueing_controlled_delay_bool(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
FairQueueingControlledDelay *fqcd;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_FQ_CODEL, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -289,7 +286,7 @@ int config_parse_fair_queueing_controlled_delay_size(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
FairQueueingControlledDelay *fqcd;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint64_t sz;
uint32_t *p;
int r;
@@ -297,7 +294,6 @@ int config_parse_fair_queueing_controlled_delay_size(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_FQ_CODEL, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/fq-pie.c b/src/network/tc/fq-pie.c
index d4a9d5966a..c8b2e7b7ee 100644
--- a/src/network/tc/fq-pie.c
+++ b/src/network/tc/fq-pie.c
@@ -51,14 +51,13 @@ int config_parse_fq_pie_packet_limit(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
FlowQueuePIE *fq_pie;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint32_t val;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_FQ_PIE, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/fq.c b/src/network/tc/fq.c
index 1e69a66d7b..c588f385c7 100644
--- a/src/network/tc/fq.c
+++ b/src/network/tc/fq.c
@@ -116,14 +116,13 @@ int config_parse_fair_queueing_u32(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
FairQueueing *fq;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint32_t *p;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -181,7 +180,7 @@ int config_parse_fair_queueing_size(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
FairQueueing *fq;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint64_t sz;
uint32_t *p;
int r;
@@ -189,7 +188,6 @@ int config_parse_fair_queueing_size(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -250,13 +248,12 @@ int config_parse_fair_queueing_bool(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
FairQueueing *fq;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -304,14 +301,13 @@ int config_parse_fair_queueing_usec(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
FairQueueing *fq;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
usec_t sec;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -365,14 +361,13 @@ int config_parse_fair_queueing_max_rate(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
FairQueueing *fq;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint64_t sz;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_FQ, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/gred.c b/src/network/tc/gred.c
index 96281e6bd4..476122c844 100644
--- a/src/network/tc/gred.c
+++ b/src/network/tc/gred.c
@@ -79,7 +79,7 @@ int config_parse_generic_random_early_detection_u32(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
GenericRandomEarlyDetection *gred;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint32_t *p;
uint32_t v;
int r;
@@ -87,7 +87,6 @@ int config_parse_generic_random_early_detection_u32(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_GRED, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -146,13 +145,12 @@ int config_parse_generic_random_early_detection_bool(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
GenericRandomEarlyDetection *gred;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_GRED, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/hhf.c b/src/network/tc/hhf.c
index aac4feff45..2d71a42c53 100644
--- a/src/network/tc/hhf.c
+++ b/src/network/tc/hhf.c
@@ -52,13 +52,12 @@ int config_parse_heavy_hitter_filter_packet_limit(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
HeavyHitterFilter *hhf;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_HHF, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/htb.c b/src/network/tc/htb.c
index f50b0e5010..eb2c8cfff4 100644
--- a/src/network/tc/htb.c
+++ b/src/network/tc/htb.c
@@ -59,13 +59,12 @@ int config_parse_hierarchy_token_bucket_default_class(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
HierarchyTokenBucket *htb;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_HTB, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -112,13 +111,12 @@ int config_parse_hierarchy_token_bucket_u32(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
HierarchyTokenBucket *htb;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_HTB, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -255,14 +253,13 @@ int config_parse_hierarchy_token_bucket_class_u32(
_cleanup_(tclass_free_or_set_invalidp) TClass *tclass = NULL;
HierarchyTokenBucketClass *htb;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint32_t v;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = tclass_new_static(TCLASS_KIND_HTB, network, filename, section_line, &tclass);
if (r == -ENOMEM)
@@ -309,14 +306,13 @@ int config_parse_hierarchy_token_bucket_class_size(
_cleanup_(tclass_free_or_set_invalidp) TClass *tclass = NULL;
HierarchyTokenBucketClass *htb;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint64_t v;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = tclass_new_static(TCLASS_KIND_HTB, network, filename, section_line, &tclass);
if (r == -ENOMEM)
@@ -393,14 +389,13 @@ int config_parse_hierarchy_token_bucket_class_rate(
_cleanup_(tclass_free_or_set_invalidp) TClass *tclass = NULL;
HierarchyTokenBucketClass *htb;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint64_t *v;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = tclass_new_static(TCLASS_KIND_HTB, network, filename, section_line, &tclass);
if (r == -ENOMEM)
diff --git a/src/network/tc/netem.c b/src/network/tc/netem.c
index d4c452675e..6a63221c3a 100644
--- a/src/network/tc/netem.c
+++ b/src/network/tc/netem.c
@@ -61,7 +61,7 @@ int config_parse_network_emulator_delay(
void *userdata) {
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
NetworkEmulator *ne;
usec_t u;
int r;
@@ -69,7 +69,6 @@ int config_parse_network_emulator_delay(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_NETEM, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -123,7 +122,7 @@ int config_parse_network_emulator_rate(
void *userdata) {
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
NetworkEmulator *ne;
uint32_t rate;
int r;
@@ -131,7 +130,6 @@ int config_parse_network_emulator_rate(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_NETEM, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -184,14 +182,13 @@ int config_parse_network_emulator_packet_limit(
void *userdata) {
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
NetworkEmulator *ne;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_NETEM, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/pie.c b/src/network/tc/pie.c
index 1b1a457f46..c9b171baf1 100644
--- a/src/network/tc/pie.c
+++ b/src/network/tc/pie.c
@@ -51,13 +51,12 @@ int config_parse_pie_packet_limit(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
ProportionalIntegralControllerEnhanced *pie;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_PIE, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/qdisc.c b/src/network/tc/qdisc.c
index 8f8a7408a5..ca89169a86 100644
--- a/src/network/tc/qdisc.c
+++ b/src/network/tc/qdisc.c
@@ -590,13 +590,12 @@ int config_parse_qdisc_parent(
void *userdata) {
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(ltype, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -650,14 +649,13 @@ int config_parse_qdisc_handle(
void *userdata) {
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint16_t n;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(ltype, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/qfq.c b/src/network/tc/qfq.c
index 51aef03210..7702e6ff6e 100644
--- a/src/network/tc/qfq.c
+++ b/src/network/tc/qfq.c
@@ -64,14 +64,13 @@ int config_parse_quick_fair_queueing_weight(
_cleanup_(tclass_free_or_set_invalidp) TClass *tclass = NULL;
QuickFairQueueingClass *qfq;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint32_t v;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = tclass_new_static(TCLASS_KIND_QFQ, network, filename, section_line, &tclass);
if (r == -ENOMEM)
@@ -125,14 +124,13 @@ int config_parse_quick_fair_queueing_max_packet(
_cleanup_(tclass_free_or_set_invalidp) TClass *tclass = NULL;
QuickFairQueueingClass *qfq;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
uint64_t v;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = tclass_new_static(TCLASS_KIND_QFQ, network, filename, section_line, &tclass);
if (r == -ENOMEM)
diff --git a/src/network/tc/sfb.c b/src/network/tc/sfb.c
index 88b3ce55bd..861c5fe2a0 100644
--- a/src/network/tc/sfb.c
+++ b/src/network/tc/sfb.c
@@ -62,13 +62,12 @@ int config_parse_stochastic_fair_blue_u32(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
StochasticFairBlue *sfb;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_SFB, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/sfq.c b/src/network/tc/sfq.c
index 45cc54d396..92dbae1166 100644
--- a/src/network/tc/sfq.c
+++ b/src/network/tc/sfq.c
@@ -46,13 +46,12 @@ int config_parse_stochastic_fairness_queueing_perturb_period(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
StochasticFairnessQueueing *sfq;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_SFQ, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/tbf.c b/src/network/tc/tbf.c
index 2aca8c1f13..d4344908d9 100644
--- a/src/network/tc/tbf.c
+++ b/src/network/tc/tbf.c
@@ -123,7 +123,7 @@ int config_parse_token_bucket_filter_size(
void *userdata) {
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
TokenBucketFilter *tbf;
uint64_t k;
int r;
@@ -131,7 +131,6 @@ int config_parse_token_bucket_filter_size(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_TBF, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -197,7 +196,7 @@ int config_parse_token_bucket_filter_rate(
void *userdata) {
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
TokenBucketFilter *tbf;
uint64_t k, *p;
int r;
@@ -205,7 +204,6 @@ int config_parse_token_bucket_filter_rate(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_TBF, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
@@ -259,7 +257,7 @@ int config_parse_token_bucket_filter_latency(
void *userdata) {
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
TokenBucketFilter *tbf;
usec_t u;
int r;
@@ -267,7 +265,6 @@ int config_parse_token_bucket_filter_latency(
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_TBF, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/tc/tclass.c b/src/network/tc/tclass.c
index d3b3c19bdf..0452cc99a8 100644
--- a/src/network/tc/tclass.c
+++ b/src/network/tc/tclass.c
@@ -523,13 +523,12 @@ int config_parse_tclass_parent(
void *userdata) {
_cleanup_(tclass_free_or_set_invalidp) TClass *tclass = NULL;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = tclass_new_static(ltype, network, filename, section_line, &tclass);
if (r == -ENOMEM)
@@ -570,13 +569,12 @@ int config_parse_tclass_classid(
void *userdata) {
_cleanup_(tclass_free_or_set_invalidp) TClass *tclass = NULL;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = tclass_new_static(ltype, network, filename, section_line, &tclass);
if (r == -ENOMEM)
diff --git a/src/network/tc/teql.c b/src/network/tc/teql.c
index 9fd9e09006..dcb149dbe2 100644
--- a/src/network/tc/teql.c
+++ b/src/network/tc/teql.c
@@ -52,14 +52,13 @@ int config_parse_trivial_link_equalizer_id(
_cleanup_(qdisc_free_or_set_invalidp) QDisc *qdisc = NULL;
TrivialLinkEqualizer *teql;
- Network *network = data;
+ Network *network = ASSERT_PTR(data);
unsigned id;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = qdisc_new_static(QDISC_KIND_TEQL, network, filename, section_line, &qdisc);
if (r == -ENOMEM)
diff --git a/src/network/wait-online/manager.c b/src/network/wait-online/manager.c
index c98b48b06f..3a2db101ed 100644
--- a/src/network/wait-online/manager.c
+++ b/src/network/wait-online/manager.c
@@ -176,14 +176,13 @@ bool manager_configured(Manager *m) {
}
static int manager_process_link(sd_netlink *rtnl, sd_netlink_message *mm, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
uint16_t type;
Link *l;
const char *ifname;
int ifindex, r;
assert(rtnl);
- assert(m);
assert(mm);
r = sd_netlink_message_get_type(mm, &type);
@@ -302,12 +301,10 @@ static int manager_rtnl_listen(Manager *m) {
}
static int on_network_event(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
Link *l;
int r;
- assert(m);
-
sd_network_monitor_flush(m->network_monitor);
HASHMAP_FOREACH(l, m->links_by_index) {
diff --git a/src/nspawn/nspawn-mount.c b/src/nspawn/nspawn-mount.c
index 7eb5ac82ea..d919533f4a 100644
--- a/src/nspawn/nspawn-mount.c
+++ b/src/nspawn/nspawn-mount.c
@@ -281,13 +281,12 @@ int bind_mount_parse(CustomMount **l, size_t *n, const char *s, bool read_only)
int tmpfs_mount_parse(CustomMount **l, size_t *n, const char *s) {
_cleanup_free_ char *path = NULL, *opts = NULL;
- const char *p = s;
+ const char *p = ASSERT_PTR(s);
CustomMount *m;
int r;
assert(l);
assert(n);
- assert(s);
r = extract_first_word(&p, &path, ":", EXTRACT_DONT_COALESCE_SEPARATORS);
if (r < 0)
diff --git a/src/nspawn/nspawn-oci.c b/src/nspawn/nspawn-oci.c
index a8c7b4e434..02142a9352 100644
--- a/src/nspawn/nspawn-oci.c
+++ b/src/nspawn/nspawn-oci.c
@@ -99,11 +99,9 @@ static int oci_terminal(const char *name, JsonVariant *v, JsonDispatchFlags flag
}
static int oci_console_dimension(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
- unsigned *u = userdata;
+ unsigned *u = ASSERT_PTR(userdata);
uint64_t k;
- assert(u);
-
k = json_variant_unsigned(variant);
if (k == 0)
return json_log(variant, flags, SYNTHETIC_ERRNO(ERANGE),
@@ -128,11 +126,9 @@ static int oci_console_size(const char *name, JsonVariant *v, JsonDispatchFlags
}
static int oci_absolute_path(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- char **p = userdata;
+ char **p = ASSERT_PTR(userdata);
const char *n;
- assert(p);
-
n = json_variant_string(v);
if (!path_is_absolute(n))
@@ -143,12 +139,10 @@ static int oci_absolute_path(const char *name, JsonVariant *v, JsonDispatchFlags
}
static int oci_env(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- char ***l = userdata;
+ char ***l = ASSERT_PTR(userdata);
JsonVariant *e;
int r;
- assert(l);
-
JSON_VARIANT_ARRAY_FOREACH(e, v) {
const char *n;
@@ -172,11 +166,9 @@ static int oci_env(const char *name, JsonVariant *v, JsonDispatchFlags flags, vo
static int oci_args(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
_cleanup_strv_free_ char **l = NULL;
- char ***value = userdata;
+ char ***value = ASSERT_PTR(userdata);
int r;
- assert(value);
-
r = json_variant_strv(v, &l);
if (r < 0)
return json_log(v, flags, r, "Cannot parse arguments as list of strings: %m");
@@ -214,9 +206,7 @@ static int oci_rlimit_type(const char *name, JsonVariant *v, JsonDispatchFlags f
}
static int oci_rlimit_value(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- rlim_t z, *value = userdata;
-
- assert(value);
+ rlim_t z, *value = ASSERT_PTR(userdata);
if (json_variant_is_negative(v))
z = RLIM_INFINITY;
@@ -238,12 +228,10 @@ static int oci_rlimit_value(const char *name, JsonVariant *v, JsonDispatchFlags
static int oci_rlimits(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
JsonVariant *e;
int r;
- assert(s);
-
JSON_VARIANT_ARRAY_FOREACH(e, v) {
struct rlimit_data {
@@ -328,11 +316,9 @@ static int oci_capabilities(const char *name, JsonVariant *v, JsonDispatchFlags
{}
};
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
int r;
- assert(s);
-
r = json_dispatch(v, table, oci_unexpected, flags, &s->full_capabilities);
if (r < 0)
return r;
@@ -346,11 +332,9 @@ static int oci_capabilities(const char *name, JsonVariant *v, JsonDispatchFlags
}
static int oci_oom_score_adj(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
int64_t k;
- assert(s);
-
k = json_variant_integer(v);
if (k < OOM_SCORE_ADJ_MIN || k > OOM_SCORE_ADJ_MAX)
return json_log(v, flags, SYNTHETIC_ERRNO(EINVAL),
@@ -384,12 +368,10 @@ static int oci_uid_gid(const char *name, JsonVariant *v, JsonDispatchFlags flags
}
static int oci_supplementary_gids(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
JsonVariant *e;
int r;
- assert(s);
-
JSON_VARIANT_ARRAY_FOREACH(e, v) {
gid_t gid, *a;
@@ -472,11 +454,9 @@ static int oci_root(const char *name, JsonVariant *v, JsonDispatchFlags flags, v
}
static int oci_hostname(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
const char *n;
- assert(s);
-
assert_se(n = json_variant_string(v));
if (!hostname_is_valid(n, 0))
@@ -539,12 +519,10 @@ static void cleanup_oci_mount_data(oci_mount_data *data) {
}
static int oci_mounts(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
JsonVariant *e;
int r;
- assert(s);
-
JSON_VARIANT_ARRAY_FOREACH(e, v) {
static const JsonDispatch table[] = {
{ "destination", JSON_VARIANT_STRING, oci_absolute_path, offsetof(oci_mount_data, destination), JSON_MANDATORY },
@@ -604,10 +582,9 @@ static int oci_mounts(const char *name, JsonVariant *v, JsonDispatchFlags flags,
}
static int oci_namespace_type(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- unsigned long *nsflags = userdata;
+ unsigned long *nsflags = ASSERT_PTR(userdata);
const char *n;
- assert(nsflags);
assert_se(n = json_variant_string(v));
/* We don't use namespace_flags_from_string() here, as the OCI spec uses slightly different names than the
@@ -739,12 +716,10 @@ static int oci_uid_gid_mappings(const char *name, JsonVariant *v, JsonDispatchFl
{}
};
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
JsonVariant *e;
int r;
- assert(s);
-
if (json_variant_elements(v) == 0)
return 0;
@@ -783,10 +758,9 @@ static int oci_uid_gid_mappings(const char *name, JsonVariant *v, JsonDispatchFl
}
static int oci_device_type(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- mode_t *mode = userdata;
+ mode_t *mode = ASSERT_PTR(userdata);
const char *t;
- assert(mode);
assert_se(t = json_variant_string(v));
if (STR_IN_SET(t, "c", "u"))
@@ -850,12 +824,10 @@ static int oci_device_file_mode(const char *name, JsonVariant *v, JsonDispatchFl
}
static int oci_devices(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
JsonVariant *e;
int r;
- assert(s);
-
JSON_VARIANT_ARRAY_FOREACH(e, v) {
static const JsonDispatch table[] = {
@@ -936,12 +908,10 @@ static int oci_devices(const char *name, JsonVariant *v, JsonDispatchFlags flags
static int oci_cgroups_path(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
_cleanup_free_ char *slice = NULL, *backwards = NULL;
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
const char *p;
int r;
- assert(s);
-
assert_se(p = json_variant_string(v));
r = cg_path_get_slice(p, &slice);
@@ -1016,14 +986,12 @@ static int oci_cgroup_device_access(const char *name, JsonVariant *v, JsonDispat
static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
_cleanup_free_ struct device_data *list = NULL;
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
size_t n_list = 0, i;
bool noop = false;
JsonVariant *e;
int r;
- assert(s);
-
JSON_VARIANT_ARRAY_FOREACH(e, v) {
struct device_data data = {
@@ -1175,11 +1143,9 @@ static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlag
}
static int oci_cgroup_memory_limit(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- uint64_t *m = userdata;
+ uint64_t *m = ASSERT_PTR(userdata);
uint64_t k;
- assert(m);
-
if (json_variant_is_negative(v)) {
*m = UINT64_MAX;
return 0;
@@ -1275,11 +1241,9 @@ struct cpu_data {
};
static int oci_cgroup_cpu_shares(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- uint64_t *u = userdata;
+ uint64_t *u = ASSERT_PTR(userdata);
uint64_t k;
- assert(u);
-
k = json_variant_unsigned(v);
if (k < CGROUP_CPU_SHARES_MIN || k > CGROUP_CPU_SHARES_MAX)
return json_log(v, flags, SYNTHETIC_ERRNO(ERANGE),
@@ -1290,11 +1254,9 @@ static int oci_cgroup_cpu_shares(const char *name, JsonVariant *v, JsonDispatchF
}
static int oci_cgroup_cpu_quota(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- uint64_t *u = userdata;
+ uint64_t *u = ASSERT_PTR(userdata);
uint64_t k;
- assert(u);
-
k = json_variant_unsigned(v);
if (k <= 0 || k >= UINT64_MAX)
return json_log(v, flags, SYNTHETIC_ERRNO(ERANGE),
@@ -1305,13 +1267,11 @@ static int oci_cgroup_cpu_quota(const char *name, JsonVariant *v, JsonDispatchFl
}
static int oci_cgroup_cpu_cpus(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- struct cpu_data *data = userdata;
+ struct cpu_data *data = ASSERT_PTR(userdata);
CPUSet set;
const char *n;
int r;
- assert(data);
-
assert_se(n = json_variant_string(v));
r = parse_cpu_set(n, &set);
@@ -1382,12 +1342,10 @@ static int oci_cgroup_cpu(const char *name, JsonVariant *v, JsonDispatchFlags fl
}
static int oci_cgroup_block_io_weight(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
uint64_t k;
int r;
- assert(s);
-
k = json_variant_unsigned(v);
if (k < CGROUP_BLKIO_WEIGHT_MIN || k > CGROUP_BLKIO_WEIGHT_MAX)
return json_log(v, flags, SYNTHETIC_ERRNO(ERANGE),
@@ -1405,12 +1363,10 @@ static int oci_cgroup_block_io_weight(const char *name, JsonVariant *v, JsonDisp
}
static int oci_cgroup_block_io_weight_device(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
JsonVariant *e;
int r;
- assert(s);
-
JSON_VARIANT_ARRAY_FOREACH(e, v) {
struct device_data {
unsigned major;
@@ -1460,13 +1416,11 @@ static int oci_cgroup_block_io_weight_device(const char *name, JsonVariant *v, J
}
static int oci_cgroup_block_io_throttle(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
const char *pname;
JsonVariant *e;
int r;
- assert(s);
-
pname = streq(name, "throttleReadBpsDevice") ? "IOReadBandwidthMax" :
streq(name, "throttleWriteBpsDevice") ? "IOWriteBandwidthMax" :
streq(name, "throttleReadIOPSDevice") ? "IOReadIOPSMax" :
@@ -1539,12 +1493,10 @@ static int oci_cgroup_pids(const char *name, JsonVariant *v, JsonDispatchFlags f
};
_cleanup_(json_variant_unrefp) JsonVariant *k = NULL;
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
uint64_t m;
int r;
- assert(s);
-
r = json_dispatch(v, table, oci_unexpected, flags, &k);
if (r < 0)
return r;
@@ -1623,13 +1575,11 @@ static bool sysctl_key_valid(const char *s) {
}
static int oci_sysctl(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
JsonVariant *w;
const char *k;
int r;
- assert(s);
-
JSON_VARIANT_OBJECT_FOREACH(k, w, v) {
const char *m;
@@ -1759,12 +1709,10 @@ static int oci_seccomp_compare_from_string(const char *name, enum scmp_compare *
}
static int oci_seccomp_archs(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- scmp_filter_ctx *sc = userdata;
+ scmp_filter_ctx *sc = ASSERT_PTR(userdata);
JsonVariant *e;
int r;
- assert(sc);
-
JSON_VARIANT_ARRAY_FOREACH(e, v) {
uint32_t a;
@@ -1801,11 +1749,9 @@ static void syscall_rule_free(struct syscall_rule *rule) {
};
static int oci_seccomp_action(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- uint32_t *action = userdata;
+ uint32_t *action = ASSERT_PTR(userdata);
int r;
- assert(action);
-
r = oci_seccomp_action_from_string(json_variant_string(v), action);
if (r < 0)
return json_log(v, flags, r, "Unknown system call action '%s': %m", json_variant_string(v));
@@ -1814,11 +1760,9 @@ static int oci_seccomp_action(const char *name, JsonVariant *v, JsonDispatchFlag
}
static int oci_seccomp_op(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- enum scmp_compare *op = userdata;
+ enum scmp_compare *op = ASSERT_PTR(userdata);
int r;
- assert(op);
-
r = oci_seccomp_compare_from_string(json_variant_string(v), op);
if (r < 0)
return json_log(v, flags, r, "Unknown seccomp operator '%s': %m", json_variant_string(v));
@@ -1827,12 +1771,10 @@ static int oci_seccomp_op(const char *name, JsonVariant *v, JsonDispatchFlags fl
}
static int oci_seccomp_args(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- struct syscall_rule *rule = userdata;
+ struct syscall_rule *rule = ASSERT_PTR(userdata);
JsonVariant *e;
int r;
- assert(rule);
-
JSON_VARIANT_ARRAY_FOREACH(e, v) {
static const struct JsonDispatch table[] = {
{ "index", JSON_VARIANT_UNSIGNED, json_dispatch_uint32, offsetof(struct scmp_arg_cmp, arg), JSON_MANDATORY },
@@ -1878,12 +1820,10 @@ static int oci_seccomp_args(const char *name, JsonVariant *v, JsonDispatchFlags
}
static int oci_seccomp_syscalls(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- scmp_filter_ctx *sc = userdata;
+ scmp_filter_ctx *sc = ASSERT_PTR(userdata);
JsonVariant *e;
int r;
- assert(sc);
-
JSON_VARIANT_ARRAY_FOREACH(e, v) {
static const JsonDispatch table[] = {
{ "names", JSON_VARIANT_ARRAY, json_dispatch_strv, offsetof(struct syscall_rule, names), JSON_MANDATORY },
@@ -1941,13 +1881,11 @@ static int oci_seccomp(const char *name, JsonVariant *v, JsonDispatchFlags flags
};
_cleanup_(seccomp_releasep) scmp_filter_ctx sc = NULL;
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
JsonVariant *def;
uint32_t d;
int r;
- assert(s);
-
def = json_variant_by_key(v, "defaultAction");
if (!def)
return json_log(v, flags, SYNTHETIC_ERRNO(EINVAL), "defaultAction element missing.");
@@ -1988,11 +1926,9 @@ static int oci_rootfs_propagation(const char *name, JsonVariant *v, JsonDispatch
}
static int oci_masked_paths(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
JsonVariant *e;
- assert(s);
-
JSON_VARIANT_ARRAY_FOREACH(e, v) {
_cleanup_free_ char *destination = NULL;
CustomMount *m;
@@ -2030,11 +1966,9 @@ static int oci_masked_paths(const char *name, JsonVariant *v, JsonDispatchFlags
}
static int oci_readonly_paths(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
JsonVariant *e;
- assert(s);
-
JSON_VARIANT_ARRAY_FOREACH(e, v) {
_cleanup_free_ char *source = NULL, *destination = NULL;
CustomMount *m;
@@ -2109,12 +2043,10 @@ static int oci_hook_timeout(const char *name, JsonVariant *v, JsonDispatchFlags
}
static int oci_hooks_array(const char *name, JsonVariant *v, JsonDispatchFlags flags, void *userdata) {
- Settings *s = userdata;
+ Settings *s = ASSERT_PTR(userdata);
JsonVariant *e;
int r;
- assert(s);
-
JSON_VARIANT_ARRAY_FOREACH(e, v) {
static const JsonDispatch table[] = {
diff --git a/src/nspawn/nspawn-settings.c b/src/nspawn/nspawn-settings.c
index 48daaa83e1..e06de68072 100644
--- a/src/nspawn/nspawn-settings.c
+++ b/src/nspawn/nspawn-settings.c
@@ -727,11 +727,10 @@ int config_parse_oom_score_adjust(
void *data,
void *userdata) {
- Settings *settings = data;
+ Settings *settings = ASSERT_PTR(data);
int oa, r;
assert(rvalue);
- assert(settings);
if (isempty(rvalue)) {
settings->oom_score_adjust_set = false;
@@ -766,10 +765,9 @@ int config_parse_cpu_affinity(
void *data,
void *userdata) {
- Settings *settings = data;
+ Settings *settings = ASSERT_PTR(data);
assert(rvalue);
- assert(settings);
return parse_cpu_set_extend(rvalue, &settings->cpu_set, true, unit, filename, line, lvalue);
}
@@ -844,11 +842,10 @@ int config_parse_link_journal(
void *data,
void *userdata) {
- Settings *settings = data;
+ Settings *settings = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(settings);
r = parse_link_journal(rvalue, &settings->link_journal, &settings->link_journal_try);
if (r < 0)
@@ -893,11 +890,10 @@ int config_parse_userns_chown(
void *data,
void *userdata) {
- UserNamespaceOwnership *ownership = data;
+ UserNamespaceOwnership *ownership = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(ownership);
/* Compatibility support for UserNamespaceChown=, whose job has been taken over by UserNamespaceOwnership= */
@@ -923,11 +919,10 @@ int config_parse_bind_user(
void *data,
void *userdata) {
- char ***bind_user = data;
+ char ***bind_user = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(bind_user);
if (isempty(rvalue)) {
*bind_user = strv_free(*bind_user);
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 7c703acf9c..44e5c509a8 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -2544,11 +2544,10 @@ struct ExposeArgs {
};
static int on_address_change(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
- struct ExposeArgs *args = userdata;
+ struct ExposeArgs *args = ASSERT_PTR(userdata);
assert(rtnl);
assert(m);
- assert(args);
(void) expose_port_execute(rtnl, &args->fw_ctx, arg_expose_ports, AF_INET, &args->address4);
(void) expose_port_execute(rtnl, &args->fw_ctx, arg_expose_ports, AF_INET6, &args->address6);
diff --git a/src/nss-resolve/nss-resolve.c b/src/nss-resolve/nss-resolve.c
index 9ed2945a1e..0226752275 100644
--- a/src/nss-resolve/nss-resolve.c
+++ b/src/nss-resolve/nss-resolve.c
@@ -95,11 +95,10 @@ static uint32_t ifindex_to_scopeid(int family, const void *a, int ifindex) {
}
static int json_dispatch_ifindex(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
- int *ifi = userdata;
+ int *ifi = ASSERT_PTR(userdata);
int64_t t;
assert(variant);
- assert(ifi);
if (!json_variant_is_integer(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an integer.", strna(name));
@@ -113,11 +112,10 @@ static int json_dispatch_ifindex(const char *name, JsonVariant *variant, JsonDis
}
static int json_dispatch_family(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
- int *family = userdata;
+ int *family = ASSERT_PTR(userdata);
int64_t t;
assert(variant);
- assert(family);
if (!json_variant_is_integer(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an integer.", strna(name));
@@ -158,13 +156,12 @@ typedef struct AddressParameters {
} AddressParameters;
static int json_dispatch_address(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
- AddressParameters *p = userdata;
+ AddressParameters *p = ASSERT_PTR(userdata);
union in_addr_union buf = {};
JsonVariant *i;
size_t n, k = 0;
assert(variant);
- assert(p);
if (!json_variant_is_array(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an array.", strna(name));
diff --git a/src/oom/oomd-manager-bus.c b/src/oom/oomd-manager-bus.c
index f4c196ee10..3a3308f0c4 100644
--- a/src/oom/oomd-manager-bus.c
+++ b/src/oom/oomd-manager-bus.c
@@ -13,11 +13,10 @@
static int bus_method_dump_by_fd(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *dump = NULL;
_cleanup_close_ int fd = -1;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
int r;
assert(message);
- assert(m);
r = manager_get_dump_string(m, &dump);
if (r < 0)
diff --git a/src/oom/oomd-manager.c b/src/oom/oomd-manager.c
index d9574fa97b..51bec79ba8 100644
--- a/src/oom/oomd-manager.c
+++ b/src/oom/oomd-manager.c
@@ -134,12 +134,10 @@ static int process_managed_oom_request(
JsonVariant *parameters,
VarlinkMethodFlags flags,
void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
uid_t uid;
int r;
- assert(m);
-
r = varlink_get_peer_uid(link, &uid);
if (r < 0)
return log_error_errno(r, "Failed to get varlink peer uid: %m");
@@ -153,12 +151,10 @@ static int process_managed_oom_reply(
const char *error_id,
VarlinkReplyFlags flags,
void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
uid_t uid;
int r;
- assert(m);
-
if (error_id) {
r = -EIO;
log_debug("Error getting ManagedOOM cgroups: %s", error_id);
@@ -346,12 +342,11 @@ static int acquire_managed_oom_connect(Manager *m) {
}
static int monitor_swap_contexts_handler(sd_event_source *s, uint64_t usec, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
usec_t usec_now;
int r;
assert(s);
- assert(userdata);
/* Reset timer */
r = sd_event_now(sd_event_source_get_event(s), CLOCK_MONOTONIC, &usec_now);
@@ -446,12 +441,11 @@ static int monitor_memory_pressure_contexts_handler(sd_event_source *s, uint64_t
_unused_ _cleanup_(clear_candidate_hashmapp) Manager *clear_candidates = userdata;
_cleanup_set_free_ Set *targets = NULL;
bool in_post_action_delay = false;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
usec_t usec_now;
int r;
assert(s);
- assert(userdata);
/* Reset timer */
r = sd_event_now(sd_event_source_get_event(s), CLOCK_MONOTONIC, &usec_now);
diff --git a/src/partition/repart.c b/src/partition/repart.c
index 8b1092e99a..063e4447e4 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -1058,11 +1058,10 @@ static int config_parse_type(
void *data,
void *userdata) {
- sd_id128_t *type_uuid = data;
+ sd_id128_t *type_uuid = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(type_uuid);
r = gpt_partition_type_uuid_from_string(rvalue, type_uuid);
if (r < 0)
@@ -1084,11 +1083,10 @@ static int config_parse_label(
void *userdata) {
_cleanup_free_ char *resolved = NULL;
- char **label = data;
+ char **label = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(label);
/* Nota bene: the empty label is a totally valid one. Let's hence not follow our usual rule of
* assigning the empty string to reset to default here, but really accept it as label to set. */
@@ -1207,10 +1205,9 @@ static int config_parse_fstype(
void *data,
void *userdata) {
- char **fstype = data;
+ char **fstype = ASSERT_PTR(data);
assert(rvalue);
- assert(data);
if (!filename_is_valid(rvalue))
return log_syntax(unit, LOG_ERR, filename, line, 0,
@@ -1233,11 +1230,10 @@ static int config_parse_copy_files(
_cleanup_free_ char *source = NULL, *buffer = NULL, *resolved_source = NULL, *resolved_target = NULL;
const char *p = rvalue, *target;
- Partition *partition = data;
+ Partition *partition = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(partition);
r = extract_first_word(&p, &source, ":", EXTRACT_CUNESCAPE|EXTRACT_DONT_COALESCE_SEPARATORS);
if (r < 0)
@@ -1300,11 +1296,10 @@ static int config_parse_copy_blocks(
void *userdata) {
_cleanup_free_ char *d = NULL;
- Partition *partition = data;
+ Partition *partition = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(partition);
if (isempty(rvalue)) {
partition->copy_blocks_path = mfree(partition->copy_blocks_path);
@@ -1346,13 +1341,10 @@ static int config_parse_make_dirs(
void *data,
void *userdata) {
- Partition *partition = data;
- const char *p = rvalue;
+ Partition *partition = ASSERT_PTR(data);
+ const char *p = ASSERT_PTR(rvalue);
int r;
- assert(rvalue);
- assert(partition);
-
for (;;) {
_cleanup_free_ char *word = NULL, *d = NULL;
@@ -1397,11 +1389,10 @@ static int config_parse_gpt_flags(
void *data,
void *userdata) {
- uint64_t *gpt_flags = data;
+ uint64_t *gpt_flags = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(gpt_flags);
r = safe_atou64(rvalue, gpt_flags);
if (r < 0) {
diff --git a/src/portable/portabled-bus.c b/src/portable/portabled-bus.c
index 8f8a8fbdcf..be321b8f03 100644
--- a/src/portable/portabled-bus.c
+++ b/src/portable/portabled-bus.c
@@ -108,13 +108,12 @@ static int property_get_profiles(
static int method_get_image(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;
Image *image;
int r;
assert(message);
- assert(m);
r = sd_bus_message_read(message, "s", &name);
if (r < 0)
@@ -134,12 +133,11 @@ static int method_get_image(sd_bus_message *message, void *userdata, sd_bus_erro
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;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
Image *image;
int r;
assert(message);
- assert(m);
images = hashmap_new(&image_hash_ops);
if (!images)
@@ -276,13 +274,12 @@ static int method_detach_image(sd_bus_message *message, void *userdata, sd_bus_e
_cleanup_strv_free_ char **extension_images = NULL;
PortableChange *changes = NULL;
PortableFlags flags = 0;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
size_t n_changes = 0;
const char *name_or_path;
int r;
assert(message);
- assert(m);
/* Note that we do not redirect detaching to the image object here, because we want to allow that users can
* detach already deleted images too, in case the user already deleted an image before properly detaching
diff --git a/src/portable/portabled-image-bus.c b/src/portable/portabled-image-bus.c
index 55f09d6285..7d393476a0 100644
--- a/src/portable/portabled-image-bus.c
+++ b/src/portable/portabled-image-bus.c
@@ -259,12 +259,11 @@ static int bus_image_method_get_state(
sd_bus_error *error) {
_cleanup_strv_free_ char **extension_images = NULL;
- Image *image = userdata;
+ Image *image = ASSERT_PTR(userdata);
PortableState state;
int r;
assert(message);
- assert(image);
if (sd_bus_message_is_method_call(message, NULL, "GetStateWithExtensions")) {
uint64_t input_flags = 0;
@@ -408,15 +407,13 @@ static int bus_image_method_detach(
_cleanup_strv_free_ char **extension_images = NULL;
PortableChange *changes = NULL;
- Image *image = userdata;
- Manager *m = image->userdata;
+ Image *image = ASSERT_PTR(userdata);
+ Manager *m = ASSERT_PTR(image->userdata);
PortableFlags flags = 0;
size_t n_changes = 0;
int r;
assert(message);
- assert(image);
- assert(m);
if (sd_bus_message_is_method_call(message, NULL, "DetachWithExtensions")) {
r = sd_bus_message_read_strv(message, &extension_images);
diff --git a/src/portable/portabled-image.c b/src/portable/portabled-image.c
index 40548fb655..6d2839125f 100644
--- a/src/portable/portabled-image.c
+++ b/src/portable/portabled-image.c
@@ -11,10 +11,9 @@ Image *manager_image_cache_get(Manager *m, const char *name_or_path) {
}
static int image_cache_flush(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;
diff --git a/src/portable/portabled-operation.c b/src/portable/portabled-operation.c
index e4b737ae8c..26adb9091a 100644
--- a/src/portable/portabled-operation.c
+++ b/src/portable/portabled-operation.c
@@ -9,10 +9,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",
diff --git a/src/resolve/resolvectl.c b/src/resolve/resolvectl.c
index 677e77b081..a120e838bc 100644
--- a/src/resolve/resolvectl.c
+++ b/src/resolve/resolvectl.c
@@ -1045,14 +1045,12 @@ static int show_statistics(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);
uint64_t n_current_transactions, n_total_transactions,
cache_size, n_cache_hit, n_cache_miss,
n_dnssec_secure, n_dnssec_insecure, n_dnssec_bogus, n_dnssec_indeterminate;
int r, dnssec_supported;
- assert(bus);
-
r = bus_get_property_trivial(bus, bus_resolve_mgr, "DNSSECSupported", &error, 'b', &dnssec_supported);
if (r < 0)
return log_error_errno(r, "Failed to get DNSSEC supported state: %s", bus_error_message(&error, r));
@@ -1247,13 +1245,12 @@ static int read_dns_server_one(sd_bus_message *m, bool with_ifindex, bool extend
}
static int map_link_dns_servers_internal(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata, bool extended) {
- char ***l = userdata;
+ char ***l = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(member);
assert(m);
- assert(l);
r = sd_bus_message_enter_container(m, 'a', extended ? "(iayqs)" : "(iay)");
if (r < 0)
@@ -1339,13 +1336,12 @@ static int read_domain_one(sd_bus_message *m, bool with_ifindex, char **ret) {
}
static int map_link_domains(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
- char ***l = userdata;
+ char ***l = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(member);
assert(m);
- assert(l);
r = sd_bus_message_enter_container(m, 'a', "(sb)");
if (r < 0)
@@ -1714,13 +1710,12 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, StatusMode
}
static int map_global_dns_servers_internal(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata, bool extended) {
- char ***l = userdata;
+ char ***l = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(member);
assert(m);
- assert(l);
r = sd_bus_message_enter_container(m, 'a', extended ? "(iiayqs)" : "(iiay)");
if (r < 0)
@@ -1773,13 +1768,12 @@ static int map_global_current_dns_server_ex(sd_bus *bus, const char *member, sd_
}
static int map_global_domains(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
- char ***l = userdata;
+ char ***l = ASSERT_PTR(userdata);
int r;
assert(bus);
assert(member);
assert(m);
- assert(l);
r = sd_bus_message_enter_container(m, 'a', "(isb)");
if (r < 0)
@@ -2116,11 +2110,9 @@ static int call_dns(sd_bus *bus, char **dns, const BusLocator *locator, sd_bus_e
static int verb_dns(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);
-
if (argc >= 2) {
r = ifname_mangle(argv[1]);
if (r < 0)
@@ -2196,11 +2188,9 @@ static int call_domain(sd_bus *bus, char **domain, const BusLocator *locator, sd
static int verb_domain(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);
-
if (argc >= 2) {
r = ifname_mangle(argv[1]);
if (r < 0)
@@ -2232,11 +2222,9 @@ static int verb_domain(int argc, char **argv, void *userdata) {
static int verb_default_route(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, b;
- assert(bus);
-
if (argc >= 2) {
r = ifname_mangle(argv[1]);
if (r < 0)
@@ -2272,11 +2260,9 @@ static int verb_default_route(int argc, char **argv, void *userdata) {
static int verb_llmnr(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);
-
if (argc >= 2) {
r = ifname_mangle(argv[1]);
if (r < 0)
@@ -2308,11 +2294,9 @@ static int verb_llmnr(int argc, char **argv, void *userdata) {
static int verb_mdns(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);
-
if (argc >= 2) {
r = ifname_mangle(argv[1]);
if (r < 0)
@@ -2350,11 +2334,9 @@ static int verb_mdns(int argc, char **argv, void *userdata) {
static int verb_dns_over_tls(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);
-
if (argc >= 2) {
r = ifname_mangle(argv[1]);
if (r < 0)
@@ -2392,11 +2374,9 @@ static int verb_dns_over_tls(int argc, char **argv, void *userdata) {
static int verb_dnssec(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);
-
if (argc >= 2) {
r = ifname_mangle(argv[1]);
if (r < 0)
@@ -2447,12 +2427,10 @@ static int call_nta(sd_bus *bus, char **nta, const BusLocator *locator, sd_bus_
static int verb_nta(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;
bool clear;
- assert(bus);
-
if (argc >= 2) {
r = ifname_mangle(argv[1]);
if (r < 0)
@@ -2499,11 +2477,9 @@ static int verb_nta(int argc, char **argv, void *userdata) {
static int verb_revert_link(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);
-
if (argc >= 2) {
r = ifname_mangle(argv[1]);
if (r < 0)
@@ -2531,9 +2507,8 @@ static int verb_revert_link(int argc, char **argv, void *userdata) {
}
static int verb_log_level(int argc, char *argv[], void *userdata) {
- sd_bus *bus = userdata;
+ sd_bus *bus = ASSERT_PTR(userdata);
- assert(bus);
assert(IN_SET(argc, 1, 2));
return verb_log_control_common(bus, "org.freedesktop.resolve1", argv[0], argc == 2 ? argv[1] : NULL);
diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c
index 044448ad10..908d5aeb31 100644
--- a/src/resolve/resolved-bus.c
+++ b/src/resolve/resolved-bus.c
@@ -27,10 +27,9 @@
BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_resolve_support, resolve_support, ResolveSupport);
static int query_on_bus_track(sd_bus_track *t, void *userdata) {
- DnsQuery *q = userdata;
+ DnsQuery *q = ASSERT_PTR(userdata);
assert(t);
- assert(q);
if (!DNS_TRANSACTION_IS_LIVE(q->state))
return 0;
@@ -466,14 +465,13 @@ void bus_client_log(sd_bus_message *m, const char *what) {
static int bus_method_resolve_hostname(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(dns_question_unrefp) DnsQuestion *question_idna = NULL, *question_utf8 = NULL;
_cleanup_(dns_query_freep) DnsQuery *q = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
const char *hostname;
int family, ifindex;
uint64_t flags;
int r;
assert(message);
- assert(m);
assert_cc(sizeof(int) == sizeof(int32_t));
@@ -620,14 +618,13 @@ finish:
static int bus_method_resolve_address(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(dns_question_unrefp) DnsQuestion *question = NULL;
_cleanup_(dns_query_freep) DnsQuery *q = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
union in_addr_union a;
int family, ifindex;
uint64_t flags;
int r;
assert(message);
- assert(m);
assert_cc(sizeof(int) == sizeof(int32_t));
@@ -785,14 +782,13 @@ static int bus_method_resolve_record(sd_bus_message *message, void *userdata, sd
_cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL;
_cleanup_(dns_question_unrefp) DnsQuestion *question = NULL;
_cleanup_(dns_query_freep) DnsQuery *q = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
uint16_t class, type;
const char *name;
int r, ifindex;
uint64_t flags;
assert(message);
- assert(m);
assert_cc(sizeof(int) == sizeof(int32_t));
@@ -1312,13 +1308,12 @@ static int bus_method_resolve_service(sd_bus_message *message, void *userdata, s
_cleanup_(dns_question_unrefp) DnsQuestion *question_idna = NULL, *question_utf8 = NULL;
_cleanup_(dns_query_freep) DnsQuery *q = NULL;
const char *name, *type, *domain;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
int family, ifindex;
uint64_t flags;
int r;
assert(message);
- assert(m);
assert_cc(sizeof(int) == sizeof(int32_t));
@@ -1445,12 +1440,11 @@ static int bus_property_get_dns_servers_internal(
sd_bus_error *error,
bool extended) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
Link *l;
int r;
assert(reply);
- assert(m);
r = sd_bus_message_open_container(reply, 'a', extended ? "(iiayqs)" : "(iiay)");
if (r < 0)
@@ -1504,11 +1498,10 @@ static int bus_property_get_fallback_dns_servers_internal(
sd_bus_error *error,
bool extended) {
- DnsServer **f = userdata;
+ DnsServer **f = ASSERT_PTR(userdata);
int r;
assert(reply);
- assert(f);
r = sd_bus_message_open_container(reply, 'a', extended ? "(iiayqs)" : "(iiay)");
if (r < 0)
@@ -1596,12 +1589,11 @@ static int bus_property_get_domains(
void *userdata,
sd_bus_error *error) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
Link *l;
int r;
assert(reply);
- assert(m);
r = sd_bus_message_open_container(reply, 'a', "(isb)");
if (r < 0)
@@ -1633,10 +1625,9 @@ static int bus_property_get_transaction_statistics(
void *userdata,
sd_bus_error *error) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
assert(reply);
- assert(m);
return sd_bus_message_append(reply, "(tt)",
(uint64_t) hashmap_size(m->dns_transactions),
@@ -1653,10 +1644,9 @@ static int bus_property_get_cache_statistics(
sd_bus_error *error) {
uint64_t size = 0, hit = 0, miss = 0;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
assert(reply);
- assert(m);
LIST_FOREACH(scopes, s, m->dns_scopes) {
size += dns_cache_size(&s->cache);
@@ -1676,10 +1666,9 @@ static int bus_property_get_dnssec_statistics(
void *userdata,
sd_bus_error *error) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
assert(reply);
- assert(m);
return sd_bus_message_append(reply, "(tttt)",
(uint64_t) m->n_dnssec_verdict[DNSSEC_SECURE],
@@ -1697,12 +1686,11 @@ static int bus_property_get_ntas(
void *userdata,
sd_bus_error *error) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
const char *domain;
int r;
assert(reply);
- assert(m);
r = sd_bus_message_open_container(reply, 'a', "s");
if (r < 0)
@@ -1745,10 +1733,9 @@ static int bus_property_get_resolv_conf_mode(
}
static int bus_method_reset_statistics(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
assert(message);
- assert(m);
bus_client_log(message, "statistics reset");
@@ -1836,12 +1823,11 @@ static int bus_method_revert_link(sd_bus_message *message, void *userdata, sd_bu
static int bus_method_get_link(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *p = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
int r, ifindex;
Link *l;
assert(message);
- assert(m);
r = bus_message_read_ifindex(message, error, &ifindex);
if (r < 0)
@@ -1859,10 +1845,9 @@ static int bus_method_get_link(sd_bus_message *message, void *userdata, sd_bus_e
}
static int bus_method_flush_caches(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
assert(message);
- assert(m);
bus_client_log(message, "cache flush");
@@ -1872,10 +1857,9 @@ static int bus_method_flush_caches(sd_bus_message *message, void *userdata, sd_b
}
static int bus_method_reset_server_features(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
assert(message);
- assert(m);
bus_client_log(message, "server feature reset");
@@ -1885,10 +1869,9 @@ static int bus_method_reset_server_features(sd_bus_message *message, void *userd
}
static int dnssd_service_on_bus_track(sd_bus_track *t, void *userdata) {
- DnssdService *s = userdata;
+ DnssdService *s = ASSERT_PTR(userdata);
assert(t);
- assert(s);
log_debug("Client of active request vanished, destroying DNS-SD service.");
dnssd_service_free(s);
@@ -1903,12 +1886,11 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata,
const char *name, *name_template, *type;
_cleanup_free_ char *path = NULL;
DnssdService *s = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
uid_t euid;
int r;
assert(message);
- assert(m);
if (m->mdns_support != RESOLVE_SUPPORT_YES)
return sd_bus_error_set(error, SD_BUS_ERROR_NOT_SUPPORTED, "Support for MulticastDNS is disabled");
@@ -2095,10 +2077,9 @@ static int call_dnssd_method(Manager *m, sd_bus_message *message, sd_bus_message
}
static int bus_method_unregister_service(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
assert(message);
- assert(m);
return call_dnssd_method(m, message, bus_dnssd_method_unregister, error);
}
@@ -2255,11 +2236,10 @@ const BusObjectImplementation manager_object = {
};
static int match_prepare_for_sleep(sd_bus_message *message, void *userdata, sd_bus_error *ret_error) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
int b, r;
assert(message);
- assert(m);
r = sd_bus_message_read(message, "b", &b);
if (r < 0) {
diff --git a/src/resolve/resolved-conf.c b/src/resolve/resolved-conf.c
index 3176692c5f..6fd193a7cb 100644
--- a/src/resolve/resolved-conf.c
+++ b/src/resolve/resolved-conf.c
@@ -138,13 +138,12 @@ int config_parse_dns_servers(
void *data,
void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(m);
if (isempty(rvalue))
/* Empty assignment means clear the list */
@@ -181,13 +180,12 @@ int config_parse_search_domains(
void *data,
void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(m);
if (isempty(rvalue))
/* Empty assignment means clear the list */
@@ -233,14 +231,13 @@ int config_parse_dnssd_service_name(
{ 'W', specifier_os_variant_id, NULL },
{}
};
- DnssdService *s = userdata;
+ DnssdService *s = ASSERT_PTR(userdata);
_cleanup_free_ char *name = NULL;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(s);
if (isempty(rvalue)) {
s->name_template = mfree(s->name_template);
@@ -276,13 +273,12 @@ int config_parse_dnssd_service_type(
void *data,
void *userdata) {
- DnssdService *s = userdata;
+ DnssdService *s = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(s);
if (isempty(rvalue)) {
s->type = mfree(s->type);
@@ -314,13 +310,12 @@ int config_parse_dnssd_txt(
void *userdata) {
_cleanup_(dnssd_txtdata_freep) DnssdTxtData *txt_data = NULL;
- DnssdService *s = userdata;
+ DnssdService *s = ASSERT_PTR(userdata);
DnsTxtItem *last = NULL;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(s);
if (isempty(rvalue)) {
/* Flush out collected items */
diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c
index 584495c779..8daaacfc19 100644
--- a/src/resolve/resolved-dns-query.c
+++ b/src/resolve/resolved-dns-query.c
@@ -599,10 +599,9 @@ void dns_query_complete(DnsQuery *q, DnsTransactionState state) {
}
static int on_query_timeout(sd_event_source *s, usec_t usec, void *userdata) {
- DnsQuery *q = userdata;
+ DnsQuery *q = ASSERT_PTR(userdata);
assert(s);
- assert(q);
dns_query_complete(q, DNS_TRANSACTION_TIMEOUT);
return 0;
diff --git a/src/resolve/resolved-dns-scope.c b/src/resolve/resolved-dns-scope.c
index 8fd987bd82..852829569d 100644
--- a/src/resolve/resolved-dns-scope.c
+++ b/src/resolve/resolved-dns-scope.c
@@ -1176,11 +1176,10 @@ static int dns_scope_make_conflict_packet(
}
static int on_conflict_dispatch(sd_event_source *es, usec_t usec, void *userdata) {
- DnsScope *scope = userdata;
+ DnsScope *scope = ASSERT_PTR(userdata);
int r;
assert(es);
- assert(scope);
scope->conflict_event_source = sd_event_source_disable_unref(scope->conflict_event_source);
diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c
index 4018113d54..95fbb56cd7 100644
--- a/src/resolve/resolved-dns-stream.c
+++ b/src/resolve/resolved-dns-stream.c
@@ -264,9 +264,7 @@ static ssize_t dns_stream_read(DnsStream *s, void *buf, size_t count) {
}
static int on_stream_timeout(sd_event_source *es, usec_t usec, void *userdata) {
- DnsStream *s = userdata;
-
- assert(s);
+ DnsStream *s = ASSERT_PTR(userdata);
return dns_stream_complete(s, ETIMEDOUT);
}
diff --git a/src/resolve/resolved-dns-stub.c b/src/resolve/resolved-dns-stub.c
index fdd589fa92..8a8a0b19ee 100644
--- a/src/resolve/resolved-dns-stub.c
+++ b/src/resolve/resolved-dns-stub.c
@@ -1038,9 +1038,7 @@ static int on_dns_stub_packet(sd_event_source *s, int fd, uint32_t revents, void
}
static int on_dns_stub_packet_extra(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- DnsStubListenerExtra *l = userdata;
-
- assert(l);
+ DnsStubListenerExtra *l = ASSERT_PTR(userdata);
return on_dns_stub_packet_internal(s, fd, revents, l->manager, l);
}
@@ -1091,9 +1089,8 @@ static int on_dns_stub_stream(sd_event_source *s, int fd, uint32_t revents, void
}
static int on_dns_stub_stream_extra(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- DnsStubListenerExtra *l = userdata;
+ DnsStubListenerExtra *l = ASSERT_PTR(userdata);
- assert(l);
return on_dns_stub_stream_internal(s, fd, revents, l->manager, l);
}
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
index 328913e1da..0ef0782bbb 100644
--- a/src/resolve/resolved-dns-transaction.c
+++ b/src/resolve/resolved-dns-transaction.c
@@ -1404,10 +1404,9 @@ fail:
static int on_dns_packet(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
_cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
- DnsTransaction *t = userdata;
+ DnsTransaction *t = ASSERT_PTR(userdata);
int r;
- assert(t);
assert(t->scope);
r = manager_recv(t->scope->manager, fd, DNS_PROTOCOL_DNS, &p);
@@ -1516,10 +1515,9 @@ static int dns_transaction_emit_udp(DnsTransaction *t) {
}
static int on_transaction_timeout(sd_event_source *s, usec_t usec, void *userdata) {
- DnsTransaction *t = userdata;
+ DnsTransaction *t = ASSERT_PTR(userdata);
assert(s);
- assert(t);
if (t->initial_jitter_scheduled && !t->initial_jitter_elapsed) {
log_debug("Initial jitter phase for transaction %" PRIu16 " elapsed.", t->id);
diff --git a/src/resolve/resolved-dnssd-bus.c b/src/resolve/resolved-dnssd-bus.c
index 84a51ba2e6..0f0d4786ef 100644
--- a/src/resolve/resolved-dnssd-bus.c
+++ b/src/resolve/resolved-dnssd-bus.c
@@ -11,13 +11,12 @@
#include "user-util.h"
int bus_dnssd_method_unregister(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- DnssdService *s = userdata;
+ DnssdService *s = ASSERT_PTR(userdata);
Manager *m;
Link *l;
int r;
assert(message);
- assert(s);
m = s->manager;
@@ -63,7 +62,7 @@ int bus_dnssd_method_unregister(sd_bus_message *message, void *userdata, sd_bus_
static int dnssd_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
_cleanup_free_ char *name = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
DnssdService *service;
int r;
@@ -71,7 +70,6 @@ static int dnssd_object_find(sd_bus *bus, const char *path, const char *interfac
assert(path);
assert(interface);
assert(found);
- assert(m);
r = sd_bus_path_decode(path, "/org/freedesktop/resolve1/dnssd", &name);
if (r <= 0)
@@ -87,14 +85,13 @@ static int dnssd_object_find(sd_bus *bus, const char *path, const char *interfac
static int dnssd_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
DnssdService *service;
unsigned c = 0;
int r;
assert(bus);
assert(path);
- assert(m);
assert(nodes);
l = new0(char*, hashmap_size(m->dnssd_services) + 1);
diff --git a/src/resolve/resolved-link-bus.c b/src/resolve/resolved-link-bus.c
index 2361f448e8..a817b1b453 100644
--- a/src/resolve/resolved-link-bus.c
+++ b/src/resolve/resolved-link-bus.c
@@ -32,10 +32,9 @@ static int property_get_dns_over_tls_mode(
void *userdata,
sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
assert(reply);
- assert(l);
return sd_bus_message_append(reply, "s", dns_over_tls_mode_to_string(link_get_dns_over_tls_mode(l)));
}
@@ -50,11 +49,10 @@ static int property_get_dns_internal(
sd_bus_error *error,
bool extended) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
int r;
assert(reply);
- assert(l);
r = sd_bus_message_open_container(reply, 'a', extended ? "(iayqs)" : "(iay)");
if (r < 0)
@@ -142,11 +140,10 @@ static int property_get_domains(
void *userdata,
sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
int r;
assert(reply);
- assert(l);
r = sd_bus_message_open_container(reply, 'a', "(sb)");
if (r < 0)
@@ -170,10 +167,9 @@ static int property_get_default_route(
void *userdata,
sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
assert(reply);
- assert(l);
/* Return what is configured, if there's something configured */
if (l->default_route >= 0)
@@ -195,11 +191,10 @@ static int property_get_scopes_mask(
void *userdata,
sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
uint64_t mask;
assert(reply);
- assert(l);
mask = (l->unicast_scope ? SD_RESOLVED_DNS : 0) |
(l->llmnr_ipv4_scope ? SD_RESOLVED_LLMNR_IPV4 : 0) |
@@ -219,12 +214,11 @@ static int property_get_ntas(
void *userdata,
sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
const char *name;
int r;
assert(reply);
- assert(l);
r = sd_bus_message_open_container(reply, 'a', "s");
if (r < 0)
@@ -254,12 +248,11 @@ static int bus_link_method_set_dns_servers_internal(sd_bus_message *message, voi
_cleanup_free_ char *j = NULL;
struct in_addr_full **dns;
bool changed = false;
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
size_t n;
int r;
assert(message);
- assert(l);
r = verify_unmanaged_link(l, error);
if (r < 0)
@@ -352,12 +345,11 @@ int bus_link_method_set_dns_servers_ex(sd_bus_message *message, void *userdata,
int bus_link_method_set_domains(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *j = NULL;
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
bool changed = false;
int r;
assert(message);
- assert(l);
r = verify_unmanaged_link(l, error);
if (r < 0)
@@ -467,11 +459,10 @@ clear:
}
int bus_link_method_set_default_route(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
int r, b;
assert(message);
- assert(l);
r = verify_unmanaged_link(l, error);
if (r < 0)
@@ -505,13 +496,12 @@ int bus_link_method_set_default_route(sd_bus_message *message, void *userdata, s
}
int bus_link_method_set_llmnr(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
ResolveSupport mode;
const char *llmnr;
int r;
assert(message);
- assert(l);
r = verify_unmanaged_link(l, error);
if (r < 0)
@@ -554,13 +544,12 @@ int bus_link_method_set_llmnr(sd_bus_message *message, void *userdata, sd_bus_er
}
int bus_link_method_set_mdns(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
ResolveSupport mode;
const char *mdns;
int r;
assert(message);
- assert(l);
r = verify_unmanaged_link(l, error);
if (r < 0)
@@ -603,13 +592,12 @@ int bus_link_method_set_mdns(sd_bus_message *message, void *userdata, sd_bus_err
}
int bus_link_method_set_dns_over_tls(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
const char *dns_over_tls;
DnsOverTlsMode mode;
int r;
assert(message);
- assert(l);
r = verify_unmanaged_link(l, error);
if (r < 0)
@@ -652,13 +640,12 @@ int bus_link_method_set_dns_over_tls(sd_bus_message *message, void *userdata, sd
}
int bus_link_method_set_dnssec(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
const char *dnssec;
DnssecMode mode;
int r;
assert(message);
- assert(l);
r = verify_unmanaged_link(l, error);
if (r < 0)
@@ -704,11 +691,10 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v
_cleanup_set_free_free_ Set *ns = NULL;
_cleanup_strv_free_ char **ntas = NULL;
_cleanup_free_ char *j = NULL;
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
int r;
assert(message);
- assert(l);
r = verify_unmanaged_link(l, error);
if (r < 0)
@@ -765,11 +751,10 @@ int bus_link_method_set_dnssec_negative_trust_anchors(sd_bus_message *message, v
}
int bus_link_method_revert(sd_bus_message *message, void *userdata, sd_bus_error *error) {
- Link *l = userdata;
+ Link *l = ASSERT_PTR(userdata);
int r;
assert(message);
- assert(l);
r = verify_unmanaged_link(l, error);
if (r < 0)
@@ -799,7 +784,7 @@ int bus_link_method_revert(sd_bus_message *message, void *userdata, sd_bus_error
static int link_object_find(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
_cleanup_free_ char *e = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
Link *link;
int ifindex, r;
@@ -807,7 +792,6 @@ static int link_object_find(sd_bus *bus, const char *path, const char *interface
assert(path);
assert(interface);
assert(found);
- assert(m);
r = sd_bus_path_decode(path, "/org/freedesktop/resolve1/link", &e);
if (r <= 0)
@@ -842,13 +826,12 @@ char *link_bus_path(const Link *link) {
static int link_node_enumerator(sd_bus *bus, const char *path, void *userdata, char ***nodes, sd_bus_error *error) {
_cleanup_strv_free_ char **l = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
Link *link;
unsigned c = 0;
assert(bus);
assert(path);
- assert(m);
assert(nodes);
l = new0(char*, hashmap_size(m->links) + 1);
diff --git a/src/resolve/resolved-llmnr.c b/src/resolve/resolved-llmnr.c
index 76e42940f4..897674ba51 100644
--- a/src/resolve/resolved-llmnr.c
+++ b/src/resolve/resolved-llmnr.c
@@ -72,13 +72,12 @@ eaddrinuse:
static int on_llmnr_packet(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
_cleanup_(dns_packet_unrefp) DnsPacket *p = NULL;
DnsTransaction *t = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
DnsScope *scope;
int r;
assert(s);
assert(fd >= 0);
- assert(m);
r = manager_recv(m, fd, DNS_PROTOCOL_LLMNR, &p);
if (r <= 0)
diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c
index 8385543fdf..dba75bda62 100644
--- a/src/resolve/resolved-manager.c
+++ b/src/resolve/resolved-manager.c
@@ -44,13 +44,12 @@
#define SEND_TIMEOUT_USEC (200 * USEC_PER_MSEC)
static int manager_process_link(sd_netlink *rtnl, sd_netlink_message *mm, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
uint16_t type;
Link *l;
int ifindex, r;
assert(rtnl);
- assert(m);
assert(mm);
r = sd_netlink_message_get_type(mm, &type);
@@ -106,7 +105,7 @@ fail:
}
static int manager_process_address(sd_netlink *rtnl, sd_netlink_message *mm, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
union in_addr_union address;
uint16_t type;
int r, ifindex, family;
@@ -115,7 +114,6 @@ static int manager_process_address(sd_netlink *rtnl, sd_netlink_message *mm, voi
assert(rtnl);
assert(mm);
- assert(m);
r = sd_netlink_message_get_type(mm, &type);
if (r < 0)
@@ -266,12 +264,10 @@ static int manager_rtnl_listen(Manager *m) {
}
static int on_network_event(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
Link *l;
int r;
- assert(m);
-
sd_network_monitor_flush(m->network_monitor);
HASHMAP_FOREACH(l, m->links) {
@@ -319,9 +315,7 @@ static int manager_network_monitor_listen(Manager *m) {
static int manager_clock_change_listen(Manager *m);
static int on_clock_change(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
- Manager *m = userdata;
-
- assert(m);
+ Manager *m = ASSERT_PTR(userdata);
/* The clock has changed, let's flush all caches. Why that? That's because DNSSEC validation takes
* the system clock into consideration, and if the clock changes the old validations might have been
@@ -427,12 +421,10 @@ static int make_fallback_hostnames(char **full_hostname, char **llmnr_hostname,
static int on_hostname_change(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
_cleanup_free_ char *full_hostname = NULL, *llmnr_hostname = NULL, *mdns_hostname = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
bool llmnr_hostname_changed;
int r;
- assert(m);
-
r = determine_hostnames(&full_hostname, &llmnr_hostname, &mdns_hostname);
if (r < 0) {
log_warning_errno(r, "Failed to determine the local hostname and LLMNR/mDNS names, ignoring: %m");
@@ -502,13 +494,12 @@ static int manager_watch_hostname(Manager *m) {
static int manager_sigusr1(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
_cleanup_free_ char *buffer = NULL;
_cleanup_fclose_ FILE *f = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
size_t size = 0;
Link *l;
assert(s);
assert(si);
- assert(m);
f = open_memstream_unlocked(&buffer, &size);
if (!f)
@@ -533,11 +524,10 @@ static int manager_sigusr1(sd_event_source *s, const struct signalfd_siginfo *si
}
static int manager_sigusr2(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
assert(s);
assert(si);
- assert(m);
manager_flush_caches(m, LOG_INFO);
@@ -545,11 +535,10 @@ static int manager_sigusr2(sd_event_source *s, const struct signalfd_siginfo *si
}
static int manager_sigrtmin1(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
assert(s);
assert(si);
- assert(m);
manager_reset_server_features(m);
return 0;
diff --git a/src/resolve/resolved-socket-graveyard.c b/src/resolve/resolved-socket-graveyard.c
index 6d4105bc0a..9605d725ba 100644
--- a/src/resolve/resolved-socket-graveyard.c
+++ b/src/resolve/resolved-socket-graveyard.c
@@ -70,9 +70,7 @@ void manager_socket_graveyard_clear(Manager *m) {
}
static int on_io_event(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- SocketGraveyard *g = userdata;
-
- assert(g);
+ SocketGraveyard *g = ASSERT_PTR(userdata);
/* An IO event happened on the graveyard fd. We don't actually care which event that is, and we don't
* read any incoming packet off the socket. We just close the fd, that's enough to not trigger the
diff --git a/src/resolve/resolved-varlink.c b/src/resolve/resolved-varlink.c
index 96c526a214..67ae6ff441 100644
--- a/src/resolve/resolved-varlink.c
+++ b/src/resolve/resolved-varlink.c
@@ -364,13 +364,12 @@ static int vl_method_resolve_hostname(Varlink *link, JsonVariant *parameters, Va
}
static int json_dispatch_address(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
- LookupParameters *p = userdata;
+ LookupParameters *p = ASSERT_PTR(userdata);
union in_addr_union buf = {};
JsonVariant *i;
size_t n, k = 0;
assert(variant);
- assert(p);
if (!json_variant_is_array(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an array.", strna(name));
diff --git a/src/run/run.c b/src/run/run.c
index 32c001fabc..e2915fe4de 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -1077,10 +1077,9 @@ static int run_context_update(RunContext *c, const char *path) {
}
static int on_properties_changed(sd_bus_message *m, void *userdata, sd_bus_error *error) {
- RunContext *c = userdata;
+ RunContext *c = ASSERT_PTR(userdata);
assert(m);
- assert(c);
return run_context_update(c, sd_bus_message_get_path(m));
}
diff --git a/src/shared/bus-get-properties.h b/src/shared/bus-get-properties.h
index 26f3e8588c..d048913877 100644
--- a/src/shared/bus-get-properties.h
+++ b/src/shared/bus-get-properties.h
@@ -75,11 +75,10 @@ int bus_property_get_rlimit(sd_bus *bus, const char *path, const char *interface
void *userdata, \
sd_bus_error *error) { \
\
- data_type *data = userdata; \
+ data_type *data = ASSERT_PTR(userdata); \
\
assert(bus); \
assert(reply); \
- assert(data); \
\
return sd_bus_message_append(reply, bus_type, \
get2(get1(data))); \
diff --git a/src/shared/bus-polkit.c b/src/shared/bus-polkit.c
index 6ad6c08b23..85b907faa9 100644
--- a/src/shared/bus-polkit.c
+++ b/src/shared/bus-polkit.c
@@ -197,11 +197,10 @@ static int async_polkit_defer(sd_event_source *s, void *userdata) {
}
static int async_polkit_callback(sd_bus_message *reply, void *userdata, sd_bus_error *error) {
- AsyncPolkitQuery *q = userdata;
+ AsyncPolkitQuery *q = ASSERT_PTR(userdata);
int r;
assert(reply);
- assert(q);
assert(q->slot);
q->slot = sd_bus_slot_unref(q->slot);
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index e12f95d4b1..d09ec5148d 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -23,10 +23,9 @@
#include "stdio-util.h"
static int name_owner_change_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
- sd_event *e = userdata;
+ sd_event *e = ASSERT_PTR(userdata);
assert(m);
- assert(e);
sd_bus_close(sd_bus_message_get_bus(m));
sd_event_exit(e, 0);
diff --git a/src/shared/bus-wait-for-jobs.c b/src/shared/bus-wait-for-jobs.c
index 0cd47d5787..10e3a8e269 100644
--- a/src/shared/bus-wait-for-jobs.c
+++ b/src/shared/bus-wait-for-jobs.c
@@ -34,13 +34,12 @@ static int match_disconnected(sd_bus_message *m, void *userdata, sd_bus_error *e
static int match_job_removed(sd_bus_message *m, void *userdata, sd_bus_error *error) {
const char *path, *unit, *result;
- BusWaitForJobs *d = userdata;
+ BusWaitForJobs *d = ASSERT_PTR(userdata);
uint32_t id;
char *found;
int r;
assert(m);
- assert(d);
r = sd_bus_message_read(m, "uoss", &id, &path, &unit, &result);
if (r < 0) {
diff --git a/src/shared/bus-wait-for-units.c b/src/shared/bus-wait-for-units.c
index c867f1cbfd..0dd2a295dd 100644
--- a/src/shared/bus-wait-for-units.c
+++ b/src/shared/bus-wait-for-units.c
@@ -105,10 +105,9 @@ static void bus_wait_for_units_clear(BusWaitForUnits *d) {
}
static int match_disconnected(sd_bus_message *m, void *userdata, sd_bus_error *error) {
- BusWaitForUnits *d = userdata;
+ BusWaitForUnits *d = ASSERT_PTR(userdata);
assert(m);
- assert(d);
log_error("Warning! D-Bus connection terminated.");
@@ -229,13 +228,11 @@ static int property_map_job(
sd_bus_error *error,
void *userdata) {
- WaitForItem *item = userdata;
+ WaitForItem *item = ASSERT_PTR(userdata);
const char *path;
uint32_t id;
int r;
- assert(item);
-
r = sd_bus_message_read(m, "(uo)", &id, &path);
if (r < 0)
return r;
@@ -267,12 +264,10 @@ static int wait_for_item_parse_properties(WaitForItem *item, sd_bus_message *m)
}
static int on_properties_changed(sd_bus_message *m, void *userdata, sd_bus_error *error) {
- WaitForItem *item = userdata;
+ WaitForItem *item = ASSERT_PTR(userdata);
const char *interface;
int r;
- assert(item);
-
r = sd_bus_message_read(m, "s", &interface);
if (r < 0) {
log_debug_errno(r, "Failed to parse PropertiesChanged signal: %m");
@@ -290,12 +285,10 @@ static int on_properties_changed(sd_bus_message *m, void *userdata, sd_bus_error
}
static int on_get_all_properties(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
- WaitForItem *item = userdata;
+ WaitForItem *item = ASSERT_PTR(userdata);
const sd_bus_error *e;
int r;
- assert(item);
-
e = sd_bus_message_get_error(m);
if (e) {
BusWaitForUnits *d = item->parent;
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index b7ecf9d532..5cb41a39da 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -800,14 +800,13 @@ int config_parse_iec_size(
void *data,
void *userdata) {
- size_t *sz = data;
+ size_t *sz = ASSERT_PTR(data);
uint64_t v;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = parse_size(rvalue, 1024, &v);
if (r >= 0 && (uint64_t) (size_t) v != v)
@@ -833,13 +832,12 @@ int config_parse_si_uint64(
void *data,
void *userdata) {
- uint64_t *sz = data;
+ uint64_t *sz = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = parse_size(rvalue, 1000, sz);
if (r < 0)
@@ -860,13 +858,12 @@ int config_parse_iec_uint64(
void *data,
void *userdata) {
- uint64_t *bytes = data;
+ uint64_t *bytes = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = parse_size(rvalue, 1024, bytes);
if (r < 0)
@@ -887,10 +884,9 @@ int config_parse_iec_uint64_infinity(
void *data,
void *userdata) {
- uint64_t *bytes = data;
+ uint64_t *bytes = ASSERT_PTR(data);
assert(rvalue);
- assert(data);
if (streq(rvalue, "infinity")) {
*bytes = UINT64_MAX;
@@ -913,13 +909,12 @@ int config_parse_bool(
void *userdata) {
int k;
- bool *b = data;
+ bool *b = ASSERT_PTR(data);
bool fatal = ltype;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
k = parse_boolean(rvalue);
if (k < 0) {
@@ -979,12 +974,11 @@ int config_parse_tristate(
void *data,
void *userdata) {
- int k, *t = data;
+ int k, *t = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
/* A tristate is pretty much a boolean, except that it can also take an empty string,
* indicating "uninitialized", much like NULL is for a pointer type. */
@@ -1135,13 +1129,12 @@ int config_parse_path(
_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;
@@ -1170,13 +1163,12 @@ int config_parse_strv(
void *data,
void *userdata) {
- char ***sv = data;
+ char ***sv = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*sv = strv_free(*sv);
@@ -1374,13 +1366,12 @@ int config_parse_ifname(
void *data,
void *userdata) {
- char **s = data;
+ char **s = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*s = mfree(*s);
@@ -1412,13 +1403,12 @@ int config_parse_ifnames(
void *userdata) {
_cleanup_strv_free_ char **names = NULL;
- char ***s = data;
+ char ***s = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*s = strv_free(*s);
@@ -1471,14 +1461,13 @@ int config_parse_ip_port(
void *data,
void *userdata) {
- uint16_t *s = data;
+ uint16_t *s = ASSERT_PTR(data);
uint16_t port;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*s = 0;
@@ -1508,11 +1497,10 @@ int config_parse_mtu(
void *data,
void *userdata) {
- uint32_t *mtu = data;
+ uint32_t *mtu = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(mtu);
r = parse_mtu(ltype, rvalue, mtu);
if (r == -ERANGE) {
@@ -1582,13 +1570,12 @@ int config_parse_permille(
void *data,
void *userdata) {
- unsigned *permille = data;
+ unsigned *permille = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(permille);
r = parse_permille(rvalue);
if (r < 0) {
@@ -1649,13 +1636,12 @@ int config_parse_hw_addr(
void *data,
void *userdata) {
- struct hw_addr_data a, *hwaddr = data;
+ struct hw_addr_data a, *hwaddr = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*hwaddr = HW_ADDR_NULL;
@@ -1685,13 +1671,12 @@ int config_parse_hw_addrs(
void *data,
void *userdata) {
- Set **hwaddrs = data;
+ Set **hwaddrs = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -1744,13 +1729,12 @@ int config_parse_ether_addr(
void *userdata) {
_cleanup_free_ struct ether_addr *n = NULL;
- struct ether_addr **hwaddr = data;
+ struct ether_addr **hwaddr = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*hwaddr = mfree(*hwaddr);
@@ -1785,13 +1769,12 @@ int config_parse_ether_addrs(
void *data,
void *userdata) {
- Set **hwaddrs = data;
+ Set **hwaddrs = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -1844,15 +1827,14 @@ int config_parse_in_addr_non_null(
void *userdata) {
/* data must be a pointer to struct in_addr or in6_addr, and the type is determined by ltype. */
- struct in_addr *ipv4 = data;
- struct in6_addr *ipv6 = data;
+ struct in_addr *ipv4 = ASSERT_PTR(data);
+ struct in6_addr *ipv6 = ASSERT_PTR(data);
union in_addr_union a;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
assert(IN_SET(ltype, AF_INET, AF_INET6));
if (isempty(rvalue)) {
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index 6d9d243492..e1765f5874 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -246,13 +246,12 @@ typedef enum ConfigParseStringFlags {
#define DEFINE_CONFIG_PARSE_PTR(function, parser, type, msg) \
CONFIG_PARSER_PROTOTYPE(function) { \
- type *i = data; \
+ type *i = ASSERT_PTR(data); \
int r; \
\
assert(filename); \
assert(lvalue); \
assert(rvalue); \
- assert(data); \
\
r = parser(rvalue, i); \
if (r < 0) \
@@ -312,7 +311,7 @@ typedef enum ConfigParseStringFlags {
#define DEFINE_CONFIG_PARSE_ENUMV(function, name, type, invalid, msg) \
CONFIG_PARSER_PROTOTYPE(function) { \
- type **enums = data; \
+ type **enums = ASSERT_PTR(data); \
_cleanup_free_ type *xs = NULL; \
size_t i = 0; \
int r; \
@@ -320,7 +319,6 @@ typedef enum ConfigParseStringFlags {
assert(filename); \
assert(lvalue); \
assert(rvalue); \
- assert(data); \
\
xs = new0(type, 1); \
if (!xs) \
diff --git a/src/shared/cpu-set-util.c b/src/shared/cpu-set-util.c
index 7edb673d97..b1873b6409 100644
--- a/src/shared/cpu-set-util.c
+++ b/src/shared/cpu-set-util.c
@@ -144,9 +144,7 @@ int parse_cpu_set_full(
const char *lvalue) {
_cleanup_(cpu_set_reset) CPUSet c = {};
- const char *p = rvalue;
-
- assert(p);
+ const char *p = ASSERT_PTR(rvalue);
for (;;) {
_cleanup_free_ char *word = NULL;
diff --git a/src/shared/elf-util.c b/src/shared/elf-util.c
index cc0fce56d9..3ba06c5290 100644
--- a/src/shared/elf-util.c
+++ b/src/shared/elf-util.c
@@ -177,7 +177,7 @@ static StackContext* stack_context_destroy(StackContext *c) {
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(Elf *, sym_elf_end, NULL);
static int frame_callback(Dwfl_Frame *frame, void *userdata) {
- StackContext *c = userdata;
+ StackContext *c = ASSERT_PTR(userdata);
Dwarf_Addr pc, pc_adjusted;
const char *fname = NULL, *symbol = NULL;
Dwfl_Module *module;
@@ -185,7 +185,6 @@ static int frame_callback(Dwfl_Frame *frame, void *userdata) {
uint64_t module_offset = 0;
assert(frame);
- assert(c);
if (c->n_frame >= FRAMES_MAX)
return DWARF_CB_ABORT;
@@ -241,11 +240,10 @@ static int frame_callback(Dwfl_Frame *frame, void *userdata) {
}
static int thread_callback(Dwfl_Thread *thread, void *userdata) {
- StackContext *c = userdata;
+ StackContext *c = ASSERT_PTR(userdata);
pid_t tid;
assert(thread);
- assert(c);
if (c->n_thread >= THREADS_MAX)
return DWARF_CB_ABORT;
@@ -424,14 +422,13 @@ static int parse_buildid(Dwfl_Module *mod, Elf *elf, const char *name, StackCont
static int module_callback(Dwfl_Module *mod, void **userdata, const char *name, Dwarf_Addr start, void *arg) {
_cleanup_(json_variant_unrefp) JsonVariant *id_json = NULL;
- StackContext *c = arg;
+ StackContext *c = ASSERT_PTR(arg);
size_t n_program_headers;
GElf_Addr bias;
int r;
Elf *elf;
assert(mod);
- assert(c);
if (!name)
name = "(unnamed)"; /* For logging purposes */
diff --git a/src/shared/ethtool-util.c b/src/shared/ethtool-util.c
index ef605346f2..bc51e69f85 100644
--- a/src/shared/ethtool-util.c
+++ b/src/shared/ethtool-util.c
@@ -1237,14 +1237,13 @@ int config_parse_advertise(
void *data,
void *userdata) {
- uint32_t *advertise = data;
+ uint32_t *advertise = ASSERT_PTR(data);
int r;
assert(filename);
assert(section);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
/* Empty string resets the value. */
@@ -1334,7 +1333,7 @@ int config_parse_ring_buffer_or_channel(
void *data,
void *userdata) {
- u32_opt *dst = data;
+ u32_opt *dst = ASSERT_PTR(data);
uint32_t k;
int r;
@@ -1342,7 +1341,6 @@ int config_parse_ring_buffer_or_channel(
assert(section);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
dst->value = 0;
diff --git a/src/shared/exec-util.c b/src/shared/exec-util.c
index d1f50249d0..19ddf04986 100644
--- a/src/shared/exec-util.c
+++ b/src/shared/exec-util.c
@@ -253,7 +253,7 @@ int execute_directories(
}
static int gather_environment_generate(int fd, void *arg) {
- char ***env = arg;
+ char ***env = ASSERT_PTR(arg);
_cleanup_fclose_ FILE *f = NULL;
_cleanup_strv_free_ char **new = NULL;
int r;
@@ -264,8 +264,6 @@ static int gather_environment_generate(int fd, void *arg) {
* fd is always consumed, even on error.
*/
- assert(env);
-
f = fdopen(fd, "r");
if (!f) {
safe_close(fd);
@@ -295,13 +293,11 @@ static int gather_environment_generate(int fd, void *arg) {
static int gather_environment_collect(int fd, void *arg) {
_cleanup_fclose_ FILE *f = NULL;
- char ***env = arg;
+ char ***env = ASSERT_PTR(arg);
int r;
/* Write out a series of env=cescape(VAR=value) assignments to fd. */
- assert(env);
-
f = fdopen(fd, "w");
if (!f) {
safe_close(fd);
@@ -321,13 +317,11 @@ static int gather_environment_collect(int fd, void *arg) {
static int gather_environment_consume(int fd, void *arg) {
_cleanup_fclose_ FILE *f = NULL;
- char ***env = arg;
+ char ***env = ASSERT_PTR(arg);
int r = 0;
/* Read a series of env=cescape(VAR=value) assignments from fd into env. */
- assert(env);
-
f = fdopen(fd, "r");
if (!f) {
safe_close(fd);
diff --git a/src/shared/in-addr-prefix-util.c b/src/shared/in-addr-prefix-util.c
index e23b8f9d13..2dca3102e3 100644
--- a/src/shared/in-addr-prefix-util.c
+++ b/src/shared/in-addr-prefix-util.c
@@ -218,10 +218,9 @@ int config_parse_in_addr_prefixes(
void *data,
void *userdata) {
- Set **prefixes = data;
+ Set **prefixes = ASSERT_PTR(data);
int r;
- assert(prefixes);
assert(IN_SET(ltype, AF_UNSPEC, AF_INET, AF_INET6));
if (isempty(rvalue)) {
diff --git a/src/shared/json.c b/src/shared/json.c
index d541eb1036..44a1838a7d 100644
--- a/src/shared/json.c
+++ b/src/shared/json.c
@@ -4322,10 +4322,9 @@ int json_dispatch(JsonVariant *v, const JsonDispatch table[], JsonDispatchCallba
}
int json_dispatch_boolean(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
- bool *b = userdata;
+ bool *b = ASSERT_PTR(userdata);
assert(variant);
- assert(b);
if (!json_variant_is_boolean(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not a boolean.", strna(name));
@@ -4335,10 +4334,9 @@ int json_dispatch_boolean(const char *name, JsonVariant *variant, JsonDispatchFl
}
int json_dispatch_tristate(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
- int *b = userdata;
+ int *b = ASSERT_PTR(userdata);
assert(variant);
- assert(b);
if (json_variant_is_null(variant)) {
*b = -1;
@@ -4353,10 +4351,9 @@ int json_dispatch_tristate(const char *name, JsonVariant *variant, JsonDispatchF
}
int json_dispatch_int64(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
- int64_t *i = userdata;
+ int64_t *i = ASSERT_PTR(userdata);
assert(variant);
- assert(i);
if (!json_variant_is_integer(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an integer.", strna(name));
@@ -4366,10 +4363,9 @@ int json_dispatch_int64(const char *name, JsonVariant *variant, JsonDispatchFlag
}
int json_dispatch_uint64(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
- uint64_t *u = userdata;
+ uint64_t *u = ASSERT_PTR(userdata);
assert(variant);
- assert(u);
if (!json_variant_is_unsigned(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an unsigned integer.", strna(name));
@@ -4379,10 +4375,9 @@ int json_dispatch_uint64(const char *name, JsonVariant *variant, JsonDispatchFla
}
int json_dispatch_uint32(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
- uint32_t *u = userdata;
+ uint32_t *u = ASSERT_PTR(userdata);
assert(variant);
- assert(u);
if (!json_variant_is_unsigned(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an unsigned integer.", strna(name));
@@ -4395,10 +4390,9 @@ int json_dispatch_uint32(const char *name, JsonVariant *variant, JsonDispatchFla
}
int json_dispatch_int32(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
- int32_t *i = userdata;
+ int32_t *i = ASSERT_PTR(userdata);
assert(variant);
- assert(i);
if (!json_variant_is_integer(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an integer.", strna(name));
@@ -4411,11 +4405,10 @@ int json_dispatch_int32(const char *name, JsonVariant *variant, JsonDispatchFlag
}
int json_dispatch_string(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
- char **s = userdata;
+ char **s = ASSERT_PTR(userdata);
int r;
assert(variant);
- assert(s);
if (json_variant_is_null(variant)) {
*s = mfree(*s);
@@ -4436,10 +4429,9 @@ int json_dispatch_string(const char *name, JsonVariant *variant, JsonDispatchFla
}
int json_dispatch_const_string(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
- const char **s = userdata;
+ const char **s = ASSERT_PTR(userdata);
assert(variant);
- assert(s);
if (json_variant_is_null(variant)) {
*s = NULL;
@@ -4458,12 +4450,11 @@ int json_dispatch_const_string(const char *name, JsonVariant *variant, JsonDispa
int json_dispatch_strv(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
_cleanup_strv_free_ char **l = NULL;
- char ***s = userdata;
+ char ***s = ASSERT_PTR(userdata);
JsonVariant *e;
int r;
assert(variant);
- assert(s);
if (json_variant_is_null(variant)) {
*s = strv_free(*s);
diff --git a/src/shared/loopback-setup.c b/src/shared/loopback-setup.c
index dae78cde89..5dbc4b1af2 100644
--- a/src/shared/loopback-setup.c
+++ b/src/shared/loopback-setup.c
@@ -21,10 +21,9 @@ struct state {
};
static int generic_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
- struct state *s = userdata;
+ struct state *s = ASSERT_PTR(userdata);
int r;
- assert(s);
assert(s->n_messages > 0);
s->n_messages--;
diff --git a/src/shared/net-condition.c b/src/shared/net-condition.c
index 15e3d94ded..d8b0fef322 100644
--- a/src/shared/net-condition.c
+++ b/src/shared/net-condition.c
@@ -233,15 +233,13 @@ int config_parse_match_strv(
void *data,
void *userdata) {
- const char *p = rvalue;
- char ***sv = data;
+ const char *p = ASSERT_PTR(rvalue);
+ char ***sv = ASSERT_PTR(data);
bool invert;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*sv = strv_free(*sv);
@@ -290,15 +288,13 @@ int config_parse_match_ifnames(
void *data,
void *userdata) {
- const char *p = rvalue;
- char ***sv = data;
+ const char *p = ASSERT_PTR(rvalue);
+ char ***sv = ASSERT_PTR(data);
bool invert;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*sv = strv_free(*sv);
@@ -353,15 +349,13 @@ int config_parse_match_property(
void *data,
void *userdata) {
- const char *p = rvalue;
- char ***sv = data;
+ const char *p = ASSERT_PTR(rvalue);
+ char ***sv = ASSERT_PTR(data);
bool invert;
int r;
assert(filename);
assert(lvalue);
- assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*sv = strv_free(*sv);
diff --git a/src/shared/netif-sriov.c b/src/shared/netif-sriov.c
index 18e5f0eeb7..7559b0d00c 100644
--- a/src/shared/netif-sriov.c
+++ b/src/shared/netif-sriov.c
@@ -359,14 +359,13 @@ int config_parse_sr_iov_uint32(
void *userdata) {
_cleanup_(sr_iov_free_or_set_invalidp) SRIOV *sr_iov = NULL;
- OrderedHashmap **sr_iov_by_section = data;
+ OrderedHashmap **sr_iov_by_section = ASSERT_PTR(data);
uint32_t k;
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = sr_iov_new_static(sr_iov_by_section, filename, section_line, &sr_iov);
if (r < 0)
@@ -427,13 +426,12 @@ int config_parse_sr_iov_vlan_proto(
void *userdata) {
_cleanup_(sr_iov_free_or_set_invalidp) SRIOV *sr_iov = NULL;
- OrderedHashmap **sr_iov_by_section = data;
+ OrderedHashmap **sr_iov_by_section = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = sr_iov_new_static(sr_iov_by_section, filename, section_line, &sr_iov);
if (r < 0)
@@ -466,13 +464,12 @@ int config_parse_sr_iov_link_state(
void *userdata) {
_cleanup_(sr_iov_free_or_set_invalidp) SRIOV *sr_iov = NULL;
- OrderedHashmap **sr_iov_by_section = data;
+ OrderedHashmap **sr_iov_by_section = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = sr_iov_new_static(sr_iov_by_section, filename, section_line, &sr_iov);
if (r < 0)
@@ -518,13 +515,12 @@ int config_parse_sr_iov_boolean(
void *userdata) {
_cleanup_(sr_iov_free_or_set_invalidp) SRIOV *sr_iov = NULL;
- OrderedHashmap **sr_iov_by_section = data;
+ OrderedHashmap **sr_iov_by_section = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = sr_iov_new_static(sr_iov_by_section, filename, section_line, &sr_iov);
if (r < 0)
@@ -576,13 +572,12 @@ int config_parse_sr_iov_mac(
void *userdata) {
_cleanup_(sr_iov_free_or_set_invalidp) SRIOV *sr_iov = NULL;
- OrderedHashmap **sr_iov_by_section = data;
+ OrderedHashmap **sr_iov_by_section = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = sr_iov_new_static(sr_iov_by_section, filename, section_line, &sr_iov);
if (r < 0)
@@ -617,13 +612,12 @@ int config_parse_sr_iov_num_vfs(
void *data,
void *userdata) {
- uint32_t n, *num_vfs = data;
+ uint32_t n, *num_vfs = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*num_vfs = UINT32_MAX;
diff --git a/src/shared/parse-helpers.c b/src/shared/parse-helpers.c
index a9bb58715e..e09797bbf1 100644
--- a/src/shared/parse-helpers.c
+++ b/src/shared/parse-helpers.c
@@ -144,9 +144,8 @@ int parse_socket_bind_item(
parse_token_f const *parser_ptr = parsers;
int af = AF_UNSPEC, proto = 0, r;
uint16_t nr = 0, mn = 0;
- const char *p = str;
+ const char *p = ASSERT_PTR(str);
- assert(str);
assert(address_family);
assert(ip_protocol);
assert(nr_ports);
diff --git a/src/shared/pkcs11-util.c b/src/shared/pkcs11-util.c
index 80feeb1fae..f5f661705e 100644
--- a/src/shared/pkcs11-util.c
+++ b/src/shared/pkcs11-util.c
@@ -978,7 +978,7 @@ static int pkcs11_acquire_certificate_callback(
void *userdata) {
_cleanup_(erase_and_freep) char *pin_used = NULL;
- struct pkcs11_acquire_certificate_callback_data *data = userdata;
+ struct pkcs11_acquire_certificate_callback_data *data = ASSERT_PTR(userdata);
CK_OBJECT_HANDLE object;
int r;
@@ -986,7 +986,6 @@ static int pkcs11_acquire_certificate_callback(
assert(slot_info);
assert(token_info);
assert(uri);
- assert(data);
/* Called for every token matching our URI */
@@ -1200,7 +1199,7 @@ int pkcs11_crypt_device_callback(
P11KitUri *uri,
void *userdata) {
- pkcs11_crypt_device_callback_data *data = userdata;
+ pkcs11_crypt_device_callback_data *data = ASSERT_PTR(userdata);
CK_OBJECT_HANDLE object;
int r;
@@ -1208,7 +1207,6 @@ int pkcs11_crypt_device_callback(
assert(slot_info);
assert(token_info);
assert(uri);
- assert(data);
/* Called for every token matching our URI */
diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c
index 4c309f925f..6ffe86ef7f 100644
--- a/src/shared/ptyfwd.c
+++ b/src/shared/ptyfwd.c
@@ -338,9 +338,8 @@ static int shovel(PTYForward *f) {
}
static int on_master_event(sd_event_source *e, int fd, uint32_t revents, void *userdata) {
- PTYForward *f = userdata;
+ PTYForward *f = ASSERT_PTR(userdata);
- assert(f);
assert(e);
assert(e == f->master_event_source);
assert(fd >= 0);
@@ -356,9 +355,8 @@ static int on_master_event(sd_event_source *e, int fd, uint32_t revents, void *u
}
static int on_stdin_event(sd_event_source *e, int fd, uint32_t revents, void *userdata) {
- PTYForward *f = userdata;
+ PTYForward *f = ASSERT_PTR(userdata);
- assert(f);
assert(e);
assert(e == f->stdin_event_source);
assert(fd >= 0);
@@ -371,9 +369,8 @@ static int on_stdin_event(sd_event_source *e, int fd, uint32_t revents, void *us
}
static int on_stdout_event(sd_event_source *e, int fd, uint32_t revents, void *userdata) {
- PTYForward *f = userdata;
+ PTYForward *f = ASSERT_PTR(userdata);
- assert(f);
assert(e);
assert(e == f->stdout_event_source);
assert(fd >= 0);
@@ -386,10 +383,9 @@ static int on_stdout_event(sd_event_source *e, int fd, uint32_t revents, void *u
}
static int on_sigwinch_event(sd_event_source *e, const struct signalfd_siginfo *si, void *userdata) {
- PTYForward *f = userdata;
+ PTYForward *f = ASSERT_PTR(userdata);
struct winsize ws;
- assert(f);
assert(e);
assert(e == f->sigwinch_event_source);
diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c
index ba2120065a..bfc0a97c2f 100644
--- a/src/shared/tpm2-util.c
+++ b/src/shared/tpm2-util.c
@@ -1736,12 +1736,10 @@ int tpm2_find_device_auto(
}
int tpm2_parse_pcrs(const char *s, uint32_t *ret) {
- const char *p = s;
+ const char *p = ASSERT_PTR(s);
uint32_t mask = 0;
int r;
- assert(s);
-
if (isempty(s)) {
*ret = 0;
return 0;
diff --git a/src/shared/udev-util.c b/src/shared/udev-util.c
index db3161b5ce..96fd39f30c 100644
--- a/src/shared/udev-util.c
+++ b/src/shared/udev-util.c
@@ -136,11 +136,10 @@ static void device_monitor_data_free(struct DeviceMonitorData *d) {
}
static int device_monitor_handler(sd_device_monitor *monitor, sd_device *device, void *userdata) {
- struct DeviceMonitorData *data = userdata;
+ struct DeviceMonitorData *data = ASSERT_PTR(userdata);
const char *sysname;
assert(device);
- assert(data);
assert(data->sysname || data->devlink);
assert(!data->device);
diff --git a/src/shared/user-record.c b/src/shared/user-record.c
index 06f85265b9..dc8e3802c0 100644
--- a/src/shared/user-record.c
+++ b/src/shared/user-record.c
@@ -355,12 +355,10 @@ static int json_dispatch_rlimits(const char *name, JsonVariant *variant, JsonDis
}
static int json_dispatch_filename_or_path(const char *name, JsonVariant *variant, JsonDispatchFlags flags, void *userdata) {
- char **s = userdata;
+ char **s = ASSERT_PTR(userdata);
const char *n;
int r;
- assert(s);
-
if (json_variant_is_null(variant)) {
*s = mfree(*s);
return 0;
diff --git a/src/shared/userdb.c b/src/shared/userdb.c
index 0eddd382e6..de7eef687e 100644
--- a/src/shared/userdb.c
+++ b/src/shared/userdb.c
@@ -153,11 +153,9 @@ static int userdb_on_query_reply(
VarlinkReplyFlags flags,
void *userdata) {
- UserDBIterator *iterator = userdata;
+ UserDBIterator *iterator = ASSERT_PTR(userdata);
int r;
- assert(iterator);
-
if (error_id) {
log_debug("Got lookup error: %s", error_id);
diff --git a/src/shared/varlink.c b/src/shared/varlink.c
index 5178da19c8..580ebac4db 100644
--- a/src/shared/varlink.c
+++ b/src/shared/varlink.c
@@ -1861,10 +1861,9 @@ int varlink_set_description(Varlink *v, const char *description) {
}
static int io_callback(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- Varlink *v = userdata;
+ Varlink *v = ASSERT_PTR(userdata);
assert(s);
- assert(v);
handle_revents(v, revents);
(void) varlink_process(v);
@@ -1873,33 +1872,30 @@ 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) {
- Varlink *v = userdata;
+ Varlink *v = ASSERT_PTR(userdata);
assert(s);
- assert(v);
(void) varlink_process(v);
return 1;
}
static int defer_callback(sd_event_source *s, void *userdata) {
- Varlink *v = userdata;
+ Varlink *v = ASSERT_PTR(userdata);
assert(s);
- assert(v);
(void) varlink_process(v);
return 1;
}
static int prepare_callback(sd_event_source *s, void *userdata) {
- Varlink *v = userdata;
+ Varlink *v = ASSERT_PTR(userdata);
int r, e;
usec_t until;
bool have_timeout;
assert(s);
- assert(v);
e = varlink_get_events(v);
if (e < 0)
@@ -1928,10 +1924,9 @@ static int prepare_callback(sd_event_source *s, void *userdata) {
}
static int quit_callback(sd_event_source *event, void *userdata) {
- Varlink *v = userdata;
+ Varlink *v = ASSERT_PTR(userdata);
assert(event);
- assert(v);
varlink_flush(v);
varlink_close(v);
@@ -2203,13 +2198,12 @@ int varlink_server_add_connection(VarlinkServer *server, int fd, Varlink **ret)
}
static int connect_callback(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
- VarlinkServerSocket *ss = userdata;
+ VarlinkServerSocket *ss = ASSERT_PTR(userdata);
_cleanup_close_ int cfd = -1;
Varlink *v = NULL;
int r;
assert(source);
- assert(ss);
varlink_server_log(ss->server, "New incoming connection.");
diff --git a/src/shared/vlan-util.c b/src/shared/vlan-util.c
index cb43d50220..17f2d3990b 100644
--- a/src/shared/vlan-util.c
+++ b/src/shared/vlan-util.c
@@ -49,11 +49,10 @@ int config_parse_default_port_vlanid(
const char *rvalue,
void *data,
void *userdata) {
- uint16_t *id = data;
+ uint16_t *id = ASSERT_PTR(data);
assert(lvalue);
assert(rvalue);
- assert(data);
if (streq(rvalue, "none")) {
*id = 0;
@@ -76,13 +75,12 @@ int config_parse_vlanid(
void *data,
void *userdata) {
- uint16_t *id = data;
+ uint16_t *id = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
r = parse_vlanid(rvalue, id);
if (r == -ERANGE) {
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
index 7e9ab19666..7fef53f00d 100644
--- a/src/socket-proxy/socket-proxyd.c
+++ b/src/socket-proxy/socket-proxyd.c
@@ -213,12 +213,11 @@ static int connection_shovel(
static int connection_enable_event_sources(Connection *c);
static int traffic_cb(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- Connection *c = userdata;
+ Connection *c = ASSERT_PTR(userdata);
int r;
assert(s);
assert(fd >= 0);
- assert(c);
r = connection_shovel(c,
&c->server_fd, c->server_to_client_buffer, &c->client_fd,
@@ -321,13 +320,12 @@ fail:
}
static int connect_cb(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- Connection *c = userdata;
+ Connection *c = ASSERT_PTR(userdata);
socklen_t solen;
int error, r;
assert(s);
assert(fd >= 0);
- assert(c);
solen = sizeof(error);
r = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &solen);
@@ -505,13 +503,12 @@ static int add_connection_socket(Context *context, int fd) {
static int accept_cb(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
_cleanup_free_ char *peer = NULL;
- Context *context = userdata;
+ Context *context = ASSERT_PTR(userdata);
int nfd = -1, r;
assert(s);
assert(fd >= 0);
assert(revents & EPOLLIN);
- assert(context);
nfd = accept4(fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
if (nfd < 0) {
diff --git a/src/systemctl/systemctl-is-system-running.c b/src/systemctl/systemctl-is-system-running.c
index ea89eb2cc7..6b521c9347 100644
--- a/src/systemctl/systemctl-is-system-running.c
+++ b/src/systemctl/systemctl-is-system-running.c
@@ -12,11 +12,9 @@
#include "bus-error.h"
static int match_startup_finished(sd_bus_message *m, void *userdata, sd_bus_error *error) {
- char **state = userdata;
+ char **state = ASSERT_PTR(userdata);
int r;
- assert(state);
-
r = bus_get_property_string(sd_bus_message_get_bus(m), bus_systemd_mgr, "SystemState", NULL, state);
sd_event_exit(sd_bus_get_event(sd_bus_message_get_bus(m)), r);
diff --git a/src/sysupdate/sysupdate-transfer.c b/src/sysupdate/sysupdate-transfer.c
index 7baadbad80..d6705cd12e 100644
--- a/src/sysupdate/sysupdate-transfer.c
+++ b/src/sysupdate/sysupdate-transfer.c
@@ -101,11 +101,10 @@ static int config_parse_protect_version(
void *userdata) {
_cleanup_free_ char *resolved = NULL;
- char ***protected_versions = data;
+ char ***protected_versions = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(data);
r = specifier_printf(rvalue, NAME_MAX, specifier_table, arg_root, NULL, &resolved);
if (r < 0) {
@@ -140,11 +139,10 @@ static int config_parse_min_version(
void *userdata) {
_cleanup_free_ char *resolved = NULL;
- char **version = data;
+ char **version = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(data);
r = specifier_printf(rvalue, NAME_MAX, specifier_table, arg_root, NULL, &resolved);
if (r < 0) {
@@ -175,11 +173,10 @@ static int config_parse_current_symlink(
void *userdata) {
_cleanup_free_ char *resolved = NULL;
- char **current_symlink = data;
+ char **current_symlink = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(data);
r = specifier_printf(rvalue, NAME_MAX, specifier_table, arg_root, NULL, &resolved);
if (r < 0) {
@@ -247,11 +244,10 @@ static int config_parse_resource_pattern(
void *data,
void *userdata) {
- char ***patterns = data;
+ char ***patterns = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*patterns = strv_free(*patterns);
@@ -303,11 +299,10 @@ static int config_parse_resource_path(
void *userdata) {
_cleanup_free_ char *resolved = NULL;
- Resource *rr = data;
+ Resource *rr = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(data);
if (streq(rvalue, "auto")) {
rr->path_auto = true;
@@ -344,11 +339,10 @@ static int config_parse_resource_ptype(
void *data,
void *userdata) {
- Resource *rr = data;
+ Resource *rr = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(data);
r = gpt_partition_type_uuid_from_string(rvalue, &rr->partition_type);
if (r < 0) {
@@ -373,11 +367,10 @@ static int config_parse_partition_uuid(
void *data,
void *userdata) {
- Transfer *t = data;
+ Transfer *t = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(data);
r = sd_id128_from_string(rvalue, &t->partition_uuid);
if (r < 0) {
@@ -402,11 +395,10 @@ static int config_parse_partition_flags(
void *data,
void *userdata) {
- Transfer *t = data;
+ Transfer *t = ASSERT_PTR(data);
int r;
assert(rvalue);
- assert(data);
r = safe_atou64(rvalue, &t->partition_flags);
if (r < 0) {
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index 31909064cf..ac4d3dc3ed 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -179,11 +179,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.timedate1",
"/org/freedesktop/timedate1",
@@ -199,11 +197,9 @@ static int show_status(int argc, char **argv, void *userdata) {
}
static int show_properties(int argc, char **argv, void *userdata) {
- sd_bus *bus = userdata;
+ sd_bus *bus = ASSERT_PTR(userdata);
int r;
- assert(bus);
-
r = bus_print_all_properties(bus,
"org.freedesktop.timedate1",
"/org/freedesktop/timedate1",
@@ -563,14 +559,12 @@ static int map_server_address(sd_bus *bus, const char *member, sd_bus_message *m
}
static int map_ntp_message(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
- NTPStatusInfo *p = userdata;
+ NTPStatusInfo *p = ASSERT_PTR(userdata);
const void *d;
size_t sz;
int32_t b;
int r;
- assert(p);
-
r = sd_bus_message_enter_container(m, 'r', "uuuuittayttttbtt");
if (r < 0)
return r;
@@ -661,11 +655,9 @@ static int on_properties_changed(sd_bus_message *m, void *userdata, sd_bus_error
static int show_timesync_status(int argc, char **argv, void *userdata) {
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
- sd_bus *bus = userdata;
+ sd_bus *bus = ASSERT_PTR(userdata);
int r;
- assert(bus);
-
r = show_timesync_status_once(bus);
if (r < 0)
return r;
@@ -766,11 +758,9 @@ static int print_timesync_property(const char *name, const char *expected_value,
}
static int show_timesync(int argc, char **argv, void *userdata) {
- sd_bus *bus = userdata;
+ sd_bus *bus = ASSERT_PTR(userdata);
int r;
- assert(bus);
-
r = bus_print_all_properties(bus,
"org.freedesktop.timesync1",
"/org/freedesktop/timesync1",
@@ -812,11 +802,9 @@ static int parse_ifindex_bus(sd_bus *bus, const char *str) {
static int verb_ntp_servers(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 *req = NULL;
- sd_bus *bus = userdata;
+ sd_bus *bus = ASSERT_PTR(userdata);
int ifindex, r;
- assert(bus);
-
ifindex = parse_ifindex_bus(bus, argv[1]);
if (ifindex < 0)
return ifindex;
@@ -844,11 +832,9 @@ static int verb_ntp_servers(int argc, char **argv, void *userdata) {
static int verb_revert(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 ifindex, r;
- assert(bus);
-
ifindex = parse_ifindex_bus(bus, argv[1]);
if (ifindex < 0)
return ifindex;
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 9ca5d37b75..373574cc06 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -447,12 +447,11 @@ static int context_update_ntp_status(Context *c, sd_bus *bus, sd_bus_message *m)
}
static int match_job_removed(sd_bus_message *m, void *userdata, sd_bus_error *error) {
- Context *c = userdata;
+ Context *c = ASSERT_PTR(userdata);
const char *path;
unsigned n = 0;
int r;
- assert(c);
assert(m);
r = sd_bus_message_read(m, "uoss", NULL, &path, NULL, NULL);
@@ -608,10 +607,9 @@ static int property_get_can_ntp(
void *userdata,
sd_bus_error *error) {
- Context *c = userdata;
+ Context *c = ASSERT_PTR(userdata);
int r;
- assert(c);
assert(bus);
assert(property);
assert(reply);
@@ -637,10 +635,9 @@ static int property_get_ntp(
void *userdata,
sd_bus_error *error) {
- Context *c = userdata;
+ Context *c = ASSERT_PTR(userdata);
int r;
- assert(c);
assert(bus);
assert(property);
assert(reply);
@@ -658,12 +655,11 @@ static int property_get_ntp(
}
static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error *error) {
- Context *c = userdata;
+ Context *c = ASSERT_PTR(userdata);
int interactive, r;
const char *z;
assert(m);
- assert(c);
r = sd_bus_message_read(m, "sb", &z, &interactive);
if (r < 0)
@@ -737,12 +733,11 @@ static int method_set_timezone(sd_bus_message *m, void *userdata, sd_bus_error *
static int method_set_local_rtc(sd_bus_message *m, void *userdata, sd_bus_error *error) {
int lrtc, fix_system, interactive;
- Context *c = userdata;
+ Context *c = ASSERT_PTR(userdata);
struct timespec ts;
int r;
assert(m);
- assert(c);
r = sd_bus_message_read(m, "bbb", &lrtc, &fix_system, &interactive);
if (r < 0)
@@ -826,14 +821,13 @@ static int method_set_time(sd_bus_message *m, void *userdata, sd_bus_error *erro
sd_bus *bus = sd_bus_message_get_bus(m);
char buf[FORMAT_TIMESTAMP_MAX];
int relative, interactive, r;
- Context *c = userdata;
+ Context *c = ASSERT_PTR(userdata);
int64_t utc;
struct timespec ts;
usec_t start;
struct tm tm;
assert(m);
- assert(c);
if (c->slot_job_removed)
return sd_bus_error_set(error, BUS_ERROR_AUTOMATIC_TIME_SYNC_ENABLED, "Previous request is not finished, refusing.");
@@ -918,13 +912,12 @@ static int method_set_time(sd_bus_message *m, void *userdata, sd_bus_error *erro
static int method_set_ntp(sd_bus_message *m, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_slot_unrefp) sd_bus_slot *slot = NULL;
sd_bus *bus = sd_bus_message_get_bus(m);
- Context *c = userdata;
+ Context *c = ASSERT_PTR(userdata);
const UnitStatusInfo *selected = NULL;
int enable, interactive, q, r;
assert(m);
assert(bus);
- assert(c);
r = sd_bus_message_read(m, "bb", &enable, &interactive);
if (r < 0)
diff --git a/src/timesync/timesyncd-bus.c b/src/timesync/timesyncd-bus.c
index 0eb61a3808..1c33f3fbd2 100644
--- a/src/timesync/timesyncd-bus.c
+++ b/src/timesync/timesyncd-bus.c
@@ -29,10 +29,9 @@ static int property_get_servers(
void *userdata,
sd_bus_error *error) {
- ServerName **s = userdata;
+ ServerName **s = ASSERT_PTR(userdata);
int r;
- assert(s);
assert(bus);
assert(reply);
@@ -51,10 +50,9 @@ static int property_get_servers(
static int method_set_runtime_servers(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_strv_free_ char **msg_names = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
int r;
- assert(m);
assert(message);
r = sd_bus_message_read_strv(message, &msg_names);
@@ -106,9 +104,8 @@ static int property_get_current_server_name(
void *userdata,
sd_bus_error *error) {
- ServerName **s = userdata;
+ ServerName **s = ASSERT_PTR(userdata);
- assert(s);
assert(bus);
assert(reply);
@@ -172,10 +169,9 @@ static int property_get_ntp_message(
void *userdata,
sd_bus_error *error) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
int r;
- assert(m);
assert(reply);
r = sd_bus_message_open_container(reply, 'r', "uuuuittayttttbtt");
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
index 2de24cf0b7..49eb228318 100644
--- a/src/timesync/timesyncd-manager.c
+++ b/src/timesync/timesyncd-manager.c
@@ -86,9 +86,8 @@ static uint32_t graceful_add_offset_1900_1970(time_t t) {
static int manager_timeout(sd_event_source *source, usec_t usec, void *userdata) {
_cleanup_free_ char *pretty = NULL;
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
- assert(m);
assert(m->current_server_name);
assert(m->current_server_address);
@@ -173,9 +172,7 @@ static int manager_send_request(Manager *m) {
}
static int manager_timer(sd_event_source *source, usec_t usec, void *userdata) {
- Manager *m = userdata;
-
- assert(m);
+ Manager *m = ASSERT_PTR(userdata);
return manager_send_request(m);
}
@@ -207,9 +204,7 @@ static int manager_arm_timer(Manager *m, usec_t next) {
}
static int manager_clock_watch(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
- Manager *m = userdata;
-
- assert(m);
+ Manager *m = ASSERT_PTR(userdata);
/* rearm timer */
manager_clock_watch_setup(m);
@@ -395,7 +390,7 @@ static void manager_adjust_poll(Manager *m, double offset, bool spike) {
}
static int manager_receive_response(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
struct ntp_msg ntpmsg;
struct iovec iov = {
@@ -421,7 +416,6 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
int leap_sec, r;
assert(source);
- assert(m);
if (revents & (EPOLLHUP|EPOLLERR)) {
log_warning("Server connection returned error.");
@@ -783,9 +777,7 @@ static int manager_resolve_handler(sd_resolve_query *q, int ret, const struct ad
}
static int manager_retry_connect(sd_event_source *source, usec_t usec, void *userdata) {
- Manager *m = userdata;
-
- assert(m);
+ Manager *m = ASSERT_PTR(userdata);
return manager_connect(m);
}
@@ -1040,12 +1032,10 @@ bool manager_is_connected(Manager *m) {
}
static int manager_network_event_handler(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
bool changed, connected, online;
int r;
- assert(m);
-
sd_network_monitor_flush(m->network_monitor);
/* When manager_network_read_link_servers() failed, we assume that the servers are changed. */
@@ -1165,9 +1155,7 @@ int manager_new(Manager **ret) {
}
static int manager_save_time_handler(sd_event_source *s, uint64_t usec, void *userdata) {
- Manager *m = userdata;
-
- assert(m);
+ Manager *m = ASSERT_PTR(userdata);
(void) manager_save_time_and_rearm(m, USEC_INFINITY);
return 0;
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index cc6e0a1c9b..e408725b08 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -983,12 +983,11 @@ int config_parse_ifalias(
void *data,
void *userdata) {
- char **s = data;
+ char **s = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (isempty(rvalue)) {
*s = mfree(*s);
@@ -1090,13 +1089,12 @@ int config_parse_wol_password(
void *data,
void *userdata) {
- LinkConfig *config = userdata;
+ LinkConfig *config = ASSERT_PTR(userdata);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(userdata);
if (isempty(rvalue)) {
config->wol_password = erase_and_free(config->wol_password);
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index cb71dc0929..c8b773611f 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -217,13 +217,11 @@ static int udev_ctrl_connection_event_handler(sd_event_source *s, int fd, uint32
}
static int udev_ctrl_event_handler(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- UdevCtrl *uctrl = userdata;
+ UdevCtrl *uctrl = ASSERT_PTR(userdata);
_cleanup_close_ int sock = -1;
struct ucred ucred;
int r;
- assert(uctrl);
-
sock = accept4(fd, NULL, NULL, SOCK_CLOEXEC|SOCK_NONBLOCK);
if (sock < 0) {
if (ERRNO_IS_ACCEPT_AGAIN(errno))
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 41449da84d..14607a6c13 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -464,12 +464,11 @@ size_t udev_event_apply_format(
bool *ret_truncated) {
bool truncated = false;
- const char *s = src;
+ const char *s = ASSERT_PTR(src);
int r;
assert(event);
assert(event->dev);
- assert(src);
assert(dest);
assert(size > 0);
@@ -568,13 +567,12 @@ int udev_check_format(const char *value, size_t *offset, const char **hint) {
}
static int on_spawn_io(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- Spawn *spawn = userdata;
+ Spawn *spawn = ASSERT_PTR(userdata);
char buf[4096], *p;
size_t size;
ssize_t l;
int r;
- assert(spawn);
assert(fd == spawn->fd_stdout || fd == spawn->fd_stderr);
assert(!spawn->result || spawn->result_len < spawn->result_size);
@@ -637,9 +635,7 @@ reenable:
}
static int on_spawn_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
- Spawn *spawn = userdata;
-
- assert(spawn);
+ Spawn *spawn = ASSERT_PTR(userdata);
DEVICE_TRACE_POINT(spawn_timeout, spawn->device, spawn->cmd);
@@ -653,9 +649,7 @@ static int on_spawn_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
}
static int on_spawn_timeout_warning(sd_event_source *s, uint64_t usec, void *userdata) {
- Spawn *spawn = userdata;
-
- assert(spawn);
+ Spawn *spawn = ASSERT_PTR(userdata);
log_device_warning(spawn->device, "Spawned process '%s' ["PID_FMT"] is taking longer than %s to complete",
spawn->cmd, spawn->pid,
@@ -665,11 +659,9 @@ static int on_spawn_timeout_warning(sd_event_source *s, uint64_t usec, void *use
}
static int on_spawn_sigchld(sd_event_source *s, const siginfo_t *si, void *userdata) {
- Spawn *spawn = userdata;
+ Spawn *spawn = ASSERT_PTR(userdata);
int ret = -EIO;
- assert(spawn);
-
switch (si->si_code) {
case CLD_EXITED:
if (si->si_status == 0)
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c
index 56921e2cc6..1d421064d7 100644
--- a/src/udev/udevadm-trigger.c
+++ b/src/udev/udevadm-trigger.c
@@ -137,14 +137,13 @@ static int exec_list(
}
static int device_monitor_handler(sd_device_monitor *m, sd_device *dev, void *userdata) {
- Hashmap *settle_hashmap = userdata;
+ Hashmap *settle_hashmap = ASSERT_PTR(userdata);
sd_id128_t *settle_id;
const char *syspath;
char *k;
int r;
assert(dev);
- assert(settle_hashmap);
r = sd_device_get_syspath(dev, &syspath);
if (r < 0) {
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 0d99c7fd66..8451313f55 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -397,9 +397,7 @@ static void manager_reload(Manager *manager, bool force) {
}
static int on_kill_workers_event(sd_event_source *s, uint64_t usec, void *userdata) {
- Manager *manager = userdata;
-
- assert(manager);
+ Manager *manager = ASSERT_PTR(userdata);
log_debug("Cleanup idle workers");
manager_kill_workers(manager, false);
@@ -663,11 +661,10 @@ static int worker_process_device(Manager *manager, sd_device *dev) {
}
static int worker_device_monitor_handler(sd_device_monitor *monitor, sd_device *dev, void *userdata) {
- Manager *manager = userdata;
+ Manager *manager = ASSERT_PTR(userdata);
int r;
assert(dev);
- assert(manager);
r = worker_process_device(manager, dev);
if (r == EVENT_RESULT_TRY_AGAIN)
@@ -742,9 +739,8 @@ static int worker_main(Manager *_manager, sd_device_monitor *monitor, sd_device
}
static int on_event_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
- Event *event = userdata;
+ Event *event = ASSERT_PTR(userdata);
- assert(event);
assert(event->worker);
kill_and_sigcont(event->worker->pid, arg_timeout_signal);
@@ -756,9 +752,8 @@ static int on_event_timeout(sd_event_source *s, uint64_t usec, void *userdata) {
}
static int on_event_timeout_warning(sd_event_source *s, uint64_t usec, void *userdata) {
- Event *event = userdata;
+ Event *event = ASSERT_PTR(userdata);
- assert(event);
assert(event->worker);
log_device_warning(event->dev, "Worker ["PID_FMT"] processing SEQNUM=%"PRIu64" is taking a long time", event->worker->pid, event->seqnum);
@@ -1162,11 +1157,9 @@ static int event_queue_insert(Manager *manager, sd_device *dev) {
}
static int on_uevent(sd_device_monitor *monitor, sd_device *dev, void *userdata) {
- Manager *manager = userdata;
+ Manager *manager = ASSERT_PTR(userdata);
int r;
- assert(manager);
-
DEVICE_TRACE_POINT(kernel_uevent_received, dev);
device_ensure_usec_initialized(dev, NULL);
@@ -1183,9 +1176,7 @@ static int on_uevent(sd_device_monitor *monitor, sd_device *dev, void *userdata)
}
static int on_worker(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
- Manager *manager = userdata;
-
- assert(manager);
+ Manager *manager = ASSERT_PTR(userdata);
for (;;) {
EventResult result;
@@ -1250,11 +1241,10 @@ static int on_worker(sd_event_source *s, int fd, uint32_t revents, void *userdat
/* receive the udevd message from userspace */
static int on_ctrl_msg(UdevCtrl *uctrl, UdevCtrlMessageType type, const UdevCtrlMessageValue *value, void *userdata) {
- Manager *manager = userdata;
+ Manager *manager = ASSERT_PTR(userdata);
int r;
assert(value);
- assert(manager);
switch (type) {
case UDEV_CTRL_SET_LOG_LEVEL:
@@ -1483,9 +1473,7 @@ static int on_inotify(sd_event_source *s, int fd, uint32_t revents, void *userda
}
static int on_sigterm(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
- Manager *manager = userdata;
-
- assert(manager);
+ Manager *manager = ASSERT_PTR(userdata);
manager_exit(manager);
@@ -1493,9 +1481,7 @@ static int on_sigterm(sd_event_source *s, const struct signalfd_siginfo *si, voi
}
static int on_sighup(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
- Manager *manager = userdata;
-
- assert(manager);
+ Manager *manager = ASSERT_PTR(userdata);
manager_reload(manager, /* force = */ true);
@@ -1546,9 +1532,7 @@ static int on_sigchld(sd_event_source *s, const siginfo_t *si, void *userdata) {
}
static int on_post(sd_event_source *s, void *userdata) {
- Manager *manager = userdata;
-
- assert(manager);
+ Manager *manager = ASSERT_PTR(userdata);
if (manager->events) {
/* Try to process pending events if idle workers exist. Why is this necessary?
diff --git a/src/userdb/userdbd-manager.c b/src/userdb/userdbd-manager.c
index aabf8070d2..ff2607f8fe 100644
--- a/src/userdb/userdbd-manager.c
+++ b/src/userdb/userdbd-manager.c
@@ -20,10 +20,9 @@
static int start_workers(Manager *m, bool explicit_request);
static int on_sigchld(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
assert(s);
- assert(m);
for (;;) {
siginfo_t siginfo = {};
@@ -67,10 +66,9 @@ static int on_sigchld(sd_event_source *s, const struct signalfd_siginfo *si, voi
}
static int on_sigusr2(sd_event_source *s, const struct signalfd_siginfo *si, void *userdata) {
- Manager *m = userdata;
+ Manager *m = ASSERT_PTR(userdata);
assert(s);
- assert(m);
(void) start_workers(m, true); /* Workers told us there's more work, let's add one more worker as long as we are below the high watermark */
return 0;
diff --git a/src/xdg-autostart-generator/xdg-autostart-service.c b/src/xdg-autostart-generator/xdg-autostart-service.c
index 0c14b6ea65..75b6a62a97 100644
--- a/src/xdg-autostart-generator/xdg-autostart-service.c
+++ b/src/xdg-autostart-generator/xdg-autostart-service.c
@@ -73,12 +73,11 @@ static int xdg_config_parse_bool(
void *data,
void *userdata) {
- bool *b = data;
+ bool *b = ASSERT_PTR(data);
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
if (streq(rvalue, "true"))
*b = true;
@@ -157,13 +156,12 @@ static int xdg_config_parse_string(
void *userdata) {
_cleanup_free_ char *res = NULL;
- char **out = data;
+ char **out = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
/* XDG does not allow duplicate definitions. */
if (*out) {
@@ -228,13 +226,12 @@ static int xdg_config_parse_strv(
void *data,
void *userdata) {
- char ***ret_sv = data;
+ char ***ret_sv = ASSERT_PTR(data);
int r;
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(data);
/* XDG does not allow duplicate definitions. */
if (*ret_sv) {