}
sd_netlink_message *sd_netlink_message_ref(sd_netlink_message *m) {
- if (m)
- assert_se(REFCNT_INC(m->n_ref) >= 2);
+ if (!m)
+ return NULL;
+ assert_se(REFCNT_INC(m->n_ref) >= 2);
return m;
}
assert_return(m, -EINVAL);
assert_return(m->sealed, -EPERM);
assert_return(data, -EINVAL);
+
assert(m->n_containers < RTNL_CONTAINER_DEPTH);
assert(m->containers[m->n_containers].attributes);
assert(type < m->containers[m->n_containers].n_attributes);
attribute = &m->containers[m->n_containers].attributes[type];
- if (!attribute->offset)
+ if (attribute->offset == 0)
return -ENODATA;
rta = (struct rtattr*)((uint8_t *) m->hdr + attribute->offset);
if (type >= count)
continue;
- if (attributes[type].offset)
+ if (attributes[type].offset != 0)
log_debug("rtnl: message parse - overwriting repeated attribute");
attributes[type].offset = (uint8_t *) rta - (uint8_t *) m->hdr;
};
struct cmsghdr *cmsg;
uint32_t group = 0;
- int r;
+ ssize_t n;
assert(fd >= 0);
assert(iov);
- r = recvmsg(fd, &msg, MSG_TRUNC | (peek ? MSG_PEEK : 0));
- if (r < 0) {
+ n = recvmsg(fd, &msg, MSG_TRUNC | (peek ? MSG_PEEK : 0));
+ if (n < 0) {
/* no data */
if (errno == ENOBUFS)
log_debug("rtnl: kernel receive buffer overrun");
if (peek) {
/* drop the message */
- r = recvmsg(fd, &msg, 0);
- if (r < 0)
+ n = recvmsg(fd, &msg, 0);
+ if (n < 0)
return IN_SET(errno, EAGAIN, EINTR) ? 0 : -errno;
}
if (_group)
*_group = group;
- return r;
+ return (int) n;
}
/* On success, the number of bytes received is returned and *ret points to the received message
if (r <= 0)
return r;
else
- len = (size_t)r;
+ len = (size_t) r;
/* make room for the pending message */
if (!greedy_realloc((void **)&rtnl->rbuffer,
if (r <= 0)
return r;
else
- len = (size_t)r;
+ len = (size_t) r;
if (len > rtnl->rbuffer_allocated)
/* message did not fit in read buffer */
/* check that we support this message type */
r = type_system_get_type(type_system_root, &nl_type, new_msg->nlmsg_type);
-
if (r < 0) {
if (r == -EOPNOTSUPP)
log_debug("sd-netlink: ignored message with unknown type: %i",
m = NULL;
}
- if (len)
+ if (len > 0)
log_debug("sd-netlink: discarding %zu bytes of incoming message", len);
if (!first)
} else {
/* we only got a partial multi-part message, push it on the
partial read queue */
- if (i < rtnl->rqueue_partial_size) {
+ if (i < rtnl->rqueue_partial_size)
rtnl->rqueue_partial[i] = first;
- } else {
+ else {
r = rtnl_rqueue_partial_make_room(rtnl);
if (r < 0)
return r;