diff options
author | F. Aragon <paco@voltanet.io> | 2018-10-02 11:05:40 +0200 |
---|---|---|
committer | F. Aragon <paco@voltanet.io> | 2018-10-02 15:45:44 +0200 |
commit | b5891e154b6b06296678d9c8297851e931752b49 (patch) | |
tree | e4a1412f969dc3dcdfa6d30c12fcb471a7fad880 /zebra/zebra_netns_id.c | |
parent | Merge pull request #3086 from patrasar/1836 (diff) | |
download | frr-b5891e154b6b06296678d9c8297851e931752b49.tar.xz frr-b5891e154b6b06296678d9c8297851e931752b49.zip |
zebra: dead code (Coverity 1465497)
The condition in the do/while is always false because 'return_nsid' cannot
reach the end of the loop with 'return_nsid' having a different value than
NS_UNKNOWN. Because of that, the condition can be replaced with 0 (false).
Also, the loop can be removed because the two assignments made at the end
of the loop before the condition check are not used (detected via Clang,
afterwards).
Signed-off-by: F. Aragon <paco@voltanet.io>
Diffstat (limited to 'zebra/zebra_netns_id.c')
-rw-r--r-- | zebra/zebra_netns_id.c | 60 |
1 files changed, 25 insertions, 35 deletions
diff --git a/zebra/zebra_netns_id.c b/zebra/zebra_netns_id.c index 600d1d55c..ea4b07a87 100644 --- a/zebra/zebra_netns_id.c +++ b/zebra/zebra_netns_id.c @@ -220,46 +220,36 @@ ns_id_t zebra_ns_id_get(const char *netnspath) nlh = (struct nlmsghdr *)buf; /* message to analyse : NEWNSID response */ - len = ret; ret = 0; - do { - if (nlh->nlmsg_type >= NLMSG_MIN_TYPE) { - return_nsid = extract_nsid(nlh, buf); - if (return_nsid != NS_UNKNOWN) - break; - } else { - if (nlh->nlmsg_type == NLMSG_ERROR) { - struct nlmsgerr *err = - (struct nlmsgerr - *)((char *)nlh - + NETLINK_ALIGN(sizeof( - struct - nlmsghdr))); - - ret = -1; - if (err->error < 0) - errno = -err->error; - else - errno = err->error; - if (errno == 0) { - /* request NEWNSID was successfull - * return EEXIST error to get GETNSID - */ - errno = EEXIST; - } - } else { - /* other errors ignored - * attempt to get nsid + if (nlh->nlmsg_type >= NLMSG_MIN_TYPE) { + return_nsid = extract_nsid(nlh, buf); + } else { + if (nlh->nlmsg_type == NLMSG_ERROR) { + struct nlmsgerr *err = + (struct nlmsgerr + *)((char *)nlh + + NETLINK_ALIGN( + sizeof(struct nlmsghdr))); + + ret = -1; + if (err->error < 0) + errno = -err->error; + else + errno = err->error; + if (errno == 0) { + /* request NEWNSID was successfull + * return EEXIST error to get GETNSID */ - ret = -1; errno = EEXIST; - break; } + } else { + /* other errors ignored + * attempt to get nsid + */ + ret = -1; + errno = EEXIST; } - len = len - NETLINK_ALIGN(nlh->nlmsg_len); - nlh = (struct nlmsghdr *)((char *)nlh - + NETLINK_ALIGN(nlh->nlmsg_len)); - } while (len != 0 && return_nsid != NS_UNKNOWN && ret == 0); + } if (ret <= 0) { if (errno != EEXIST && ret != 0) { |