coverity: #1440389

Logically dead code Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent e92e31d1
...@@ -373,12 +373,7 @@ static int __ifaddrs_netlink_recv(int fd, unsigned int seq, int type, int af, ...@@ -373,12 +373,7 @@ static int __ifaddrs_netlink_recv(int fd, unsigned int seq, int type, int af,
struct nlmsghdr *h), struct nlmsghdr *h),
void *ctx) void *ctx)
{ {
char getlink_buf[__NETLINK_ALIGN(sizeof(struct nlmsghdr)) + int r, property, ret;
__NETLINK_ALIGN(sizeof(struct ifinfomsg)) +
__NETLINK_ALIGN(1024)];
char getaddr_buf[__NETLINK_ALIGN(sizeof(struct nlmsghdr)) +
__NETLINK_ALIGN(sizeof(struct ifaddrmsg)) +
__NETLINK_ALIGN(1024)];
char *buf; char *buf;
struct nlmsghdr *hdr; struct nlmsghdr *hdr;
struct ifinfomsg *ifi_msg; struct ifinfomsg *ifi_msg;
...@@ -391,47 +386,43 @@ static int __ifaddrs_netlink_recv(int fd, unsigned int seq, int type, int af, ...@@ -391,47 +386,43 @@ static int __ifaddrs_netlink_recv(int fd, unsigned int seq, int type, int af,
} req; } req;
struct nlmsghdr reply; struct nlmsghdr reply;
} u; } u;
int r, property, ret; char getlink_buf[__NETLINK_ALIGN(sizeof(struct nlmsghdr)) +
__NETLINK_ALIGN(sizeof(struct ifinfomsg)) +
if (type == RTM_GETLINK) __NETLINK_ALIGN(1024)] = {0};
buf = getlink_buf; char getaddr_buf[__NETLINK_ALIGN(sizeof(struct nlmsghdr)) +
else if (type == RTM_GETADDR) __NETLINK_ALIGN(sizeof(struct ifaddrmsg)) +
buf = getaddr_buf; __NETLINK_ALIGN(1024)] = {0};
else
return -1;
memset(buf, 0, sizeof(*buf));
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wcast-align" #pragma GCC diagnostic ignored "-Wcast-align"
hdr = (struct nlmsghdr *)buf; if (type == RTM_GETLINK) {
if (type == RTM_GETLINK) buf = getlink_buf;
hdr = (struct nlmsghdr *)buf;
hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*ifi_msg));
ifi_msg = (struct ifinfomsg *)__NLMSG_DATA(hdr); ifi_msg = (struct ifinfomsg *)__NLMSG_DATA(hdr);
else ifi_msg->ifi_family = af;
ifa_msg = (struct ifaddrmsg *)__NLMSG_DATA(hdr);
if (type == RTM_GETLINK) property = IFLA_TARGET_NETNSID;
hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*ifi_msg)); } else if (type == RTM_GETADDR) {
else buf = getaddr_buf;
hdr = (struct nlmsghdr *)buf;
hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*ifa_msg)); hdr->nlmsg_len = NLMSG_LENGTH(sizeof(*ifa_msg));
ifa_msg = (struct ifaddrmsg *)__NLMSG_DATA(hdr);
ifa_msg->ifa_family = af;
property = IFA_TARGET_NETNSID;
} else {
errno = EINVAL;
return -1;
}
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
hdr->nlmsg_type = type; hdr->nlmsg_type = type;
hdr->nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST; hdr->nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST;
hdr->nlmsg_pid = 0; hdr->nlmsg_pid = 0;
hdr->nlmsg_seq = seq; hdr->nlmsg_seq = seq;
if (type == RTM_GETLINK)
ifi_msg->ifi_family = af;
else
ifa_msg->ifa_family = af;
errno = EINVAL;
if (type == RTM_GETLINK)
property = IFLA_TARGET_NETNSID;
else if (type == RTM_GETADDR)
property = IFA_TARGET_NETNSID;
else
return -1;
if (netns_id >= 0) if (netns_id >= 0)
addattr(hdr, 1024, property, &netns_id, sizeof(netns_id)); addattr(hdr, 1024, property, &netns_id, sizeof(netns_id));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment