1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

Merge pull request #14352 from yuwata/sd-netlink-tiny-fixes

sd-netlink: tiny fixes
This commit is contained in:
Yu Watanabe 2019-12-17 23:10:46 +09:00 committed by GitHub
commit 4d92039fce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -757,7 +757,7 @@ int sd_netlink_message_read_u32(sd_netlink_message *m, unsigned short type, uint
r = netlink_message_read_internal(m, type, &attr_data, &net_byteorder);
if (r < 0)
return r;
else if ((size_t)r < sizeof(uint32_t))
else if ((size_t) r < sizeof(uint32_t))
return -EIO;
if (data) {
@ -783,7 +783,7 @@ int sd_netlink_message_read_ether_addr(sd_netlink_message *m, unsigned short typ
r = netlink_message_read_internal(m, type, &attr_data, NULL);
if (r < 0)
return r;
else if ((size_t)r < sizeof(struct ether_addr))
else if ((size_t) r < sizeof(struct ether_addr))
return -EIO;
if (data)
@ -805,7 +805,7 @@ int sd_netlink_message_read_cache_info(sd_netlink_message *m, unsigned short typ
r = netlink_message_read_internal(m, type, &attr_data, NULL);
if (r < 0)
return r;
else if ((size_t)r < sizeof(struct ifa_cacheinfo))
else if ((size_t) r < sizeof(struct ifa_cacheinfo))
return -EIO;
if (info)
@ -827,7 +827,7 @@ int sd_netlink_message_read_in_addr(sd_netlink_message *m, unsigned short type,
r = netlink_message_read_internal(m, type, &attr_data, NULL);
if (r < 0)
return r;
else if ((size_t)r < sizeof(struct in_addr))
else if ((size_t) r < sizeof(struct in_addr))
return -EIO;
if (data)
@ -849,7 +849,7 @@ int sd_netlink_message_read_in6_addr(sd_netlink_message *m, unsigned short type,
r = netlink_message_read_internal(m, type, &attr_data, NULL);
if (r < 0)
return r;
else if ((size_t)r < sizeof(struct in6_addr))
else if ((size_t) r < sizeof(struct in6_addr))
return -EIO;
if (data)
@ -864,7 +864,7 @@ int sd_netlink_message_read_strv(sd_netlink_message *m, unsigned short container
const NLType *nl_type;
struct rtattr *rta;
void *container;
unsigned short rt_len;
size_t rt_len;
int r;
assert_return(m, -EINVAL);
@ -896,10 +896,14 @@ int sd_netlink_message_read_strv(sd_netlink_message *m, unsigned short container
if (r < 0)
return r;
rt_len = (unsigned short) r;
rt_len = (size_t) r;
rta = container;
for (; RTA_OK(rta, rt_len); rta = RTA_NEXT(rta, rt_len)) {
/* RTA_OK() macro compares with rta->rt_len, which is unsigned short, and
* LGTM.com analysis does not like the type difference. Hence, here we
* introduce an unsigned short variable as a workaround. */
unsigned short len = rt_len;
for (; RTA_OK(rta, len); rta = RTA_NEXT(rta, len)) {
unsigned short type;
type = RTA_TYPE(rta);
@ -918,11 +922,15 @@ int sd_netlink_message_read_strv(sd_netlink_message *m, unsigned short container
static int netlink_container_parse(sd_netlink_message *m,
struct netlink_container *container,
struct rtattr *rta,
unsigned rt_len) {
size_t rt_len) {
_cleanup_free_ struct netlink_attribute *attributes = NULL;
size_t n_allocated = 0;
for (; RTA_OK(rta, rt_len); rta = RTA_NEXT(rta, rt_len)) {
/* RTA_OK() macro compares with rta->rt_len, which is unsigned short, and
* LGTM.com analysis does not like the type difference. Hence, here we
* introduce an unsigned short variable as a workaround. */
unsigned short len = rt_len;
for (; RTA_OK(rta, len); rta = RTA_NEXT(rta, len)) {
unsigned short type;
type = RTA_TYPE(rta);
@ -1021,8 +1029,7 @@ int sd_netlink_message_enter_container(sd_netlink_message *m, unsigned short typ
if (r < 0)
return r;
size = (size_t)r;
size = (size_t) r;
m->n_containers++;
r = netlink_container_parse(m,
@ -1052,7 +1059,6 @@ int sd_netlink_message_enter_array(sd_netlink_message *m, unsigned short type_id
return r;
size = (size_t) r;
m->n_containers++;
r = netlink_container_parse(m,