tree-wide: check for NULLs in more places
Fixes issues pointed out by the `cpp/inconsistent-null-check` LGTM query.
This commit is contained in:
committed by
Yu Watanabe
parent
bf71ade808
commit
c73f413d8d
@@ -69,6 +69,7 @@ static int automount_send_ready(Automount *a, Set *tokens, int status);
|
||||
static void automount_init(Unit *u) {
|
||||
Automount *a = AUTOMOUNT(u);
|
||||
|
||||
assert(a);
|
||||
assert(u);
|
||||
assert(u->load_state == UNIT_STUB);
|
||||
|
||||
|
||||
@@ -248,6 +248,7 @@ static int device_serialize(Unit *u, FILE *f, FDSet *fds) {
|
||||
_cleanup_free_ char *s = NULL;
|
||||
Device *d = DEVICE(u);
|
||||
|
||||
assert(d);
|
||||
assert(u);
|
||||
assert(f);
|
||||
assert(fds);
|
||||
@@ -264,6 +265,7 @@ static int device_deserialize_item(Unit *u, const char *key, const char *value,
|
||||
Device *d = DEVICE(u);
|
||||
int r;
|
||||
|
||||
assert(d);
|
||||
assert(u);
|
||||
assert(key);
|
||||
assert(value);
|
||||
|
||||
@@ -179,6 +179,7 @@ static bool mount_needs_quota(const MountParameters *p) {
|
||||
static void mount_init(Unit *u) {
|
||||
Mount *m = MOUNT(u);
|
||||
|
||||
assert(m);
|
||||
assert(u);
|
||||
assert(u->load_state == UNIT_STUB);
|
||||
|
||||
@@ -681,6 +682,7 @@ static int mount_load(Unit *u) {
|
||||
Mount *m = MOUNT(u);
|
||||
int r, q = 0;
|
||||
|
||||
assert(m);
|
||||
assert(u);
|
||||
assert(u->load_state == UNIT_STUB);
|
||||
|
||||
@@ -1256,6 +1258,7 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
|
||||
Mount *m = MOUNT(u);
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
assert(u);
|
||||
assert(key);
|
||||
assert(value);
|
||||
@@ -1794,6 +1797,9 @@ static int mount_get_timeout(Unit *u, usec_t *timeout) {
|
||||
usec_t t;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
assert(u);
|
||||
|
||||
if (!m->timer_event_source)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -1220,6 +1220,8 @@ static int swap_process_proc_swaps(Manager *m) {
|
||||
LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_SWAP]) {
|
||||
Swap *swap = SWAP(u);
|
||||
|
||||
assert(swap);
|
||||
|
||||
swap->is_active = swap->just_activated = false;
|
||||
}
|
||||
|
||||
@@ -1231,6 +1233,8 @@ static int swap_process_proc_swaps(Manager *m) {
|
||||
LIST_FOREACH(units_by_type, u, m->units_by_type[UNIT_SWAP]) {
|
||||
Swap *swap = SWAP(u);
|
||||
|
||||
assert(swap);
|
||||
|
||||
if (!swap->is_active) {
|
||||
|
||||
swap_unset_proc_swaps(swap);
|
||||
@@ -1495,6 +1499,9 @@ static int swap_get_timeout(Unit *u, usec_t *timeout) {
|
||||
usec_t t;
|
||||
int r;
|
||||
|
||||
assert(s);
|
||||
assert(u);
|
||||
|
||||
if (!s->timer_event_source)
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -511,6 +511,8 @@ static int netdev_macsec_fill_message_create(NetDev *netdev, Link *link, sd_netl
|
||||
|
||||
v = MACSEC(netdev);
|
||||
|
||||
assert(v);
|
||||
|
||||
if (v->port > 0) {
|
||||
r = sd_netlink_message_append_u16(m, IFLA_MACSEC_PORT, v->port);
|
||||
if (r < 0)
|
||||
|
||||
@@ -214,6 +214,8 @@ int network_verify(Network *network) {
|
||||
else
|
||||
continue;
|
||||
|
||||
assert(m);
|
||||
|
||||
if (m->mode == NETDEV_MACVLAN_MODE_PASSTHRU)
|
||||
network->link_local = ADDRESS_FAMILY_NO;
|
||||
|
||||
|
||||
@@ -1452,6 +1452,8 @@ int dns_scope_announce(DnsScope *scope, bool goodbye) {
|
||||
|
||||
rr = dns_resource_record_new_full(DNS_CLASS_IN, DNS_TYPE_PTR,
|
||||
"_services._dns-sd._udp.local");
|
||||
if (!rr)
|
||||
return log_oom();
|
||||
rr->ptr.name = strdup(service_type);
|
||||
rr->ttl = MDNS_DEFAULT_TTL;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user