sd-netlink: minor coding style updates

nothing really relevant
This commit is contained in:
Lennart Poettering 2018-01-23 15:47:18 +01:00
parent e69b29a8b9
commit f1dd72c29b
2 changed files with 17 additions and 16 deletions

View file

@ -116,9 +116,10 @@ int sd_netlink_message_request_dump(sd_netlink_message *m, int dump) {
}
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;
}
@ -567,13 +568,14 @@ static int netlink_message_read_internal(sd_netlink_message *m, unsigned short t
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);
@ -793,7 +795,7 @@ static int netlink_container_parse(sd_netlink_message *m,
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;

View file

@ -269,13 +269,13 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *_group, bool
};
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");
@ -291,8 +291,8 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *_group, bool
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;
}
@ -313,7 +313,7 @@ static int socket_recv_message(int fd, struct iovec *iov, uint32_t *_group, bool
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
@ -343,7 +343,7 @@ int socket_read_message(sd_netlink *rtnl) {
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,
@ -359,7 +359,7 @@ int socket_read_message(sd_netlink *rtnl) {
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 */
@ -400,7 +400,6 @@ int socket_read_message(sd_netlink *rtnl) {
/* 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",
@ -437,7 +436,7 @@ int socket_read_message(sd_netlink *rtnl) {
m = NULL;
}
if (len)
if (len > 0)
log_debug("sd-netlink: discarding %zu bytes of incoming message", len);
if (!first)
@ -463,9 +462,9 @@ int socket_read_message(sd_netlink *rtnl) {
} 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;