Merge pull request #11423 from donaldsharp/lgtm_fixes

Lgtm fixes
This commit is contained in:
Donatas Abraitis 2022-06-19 22:33:01 +03:00 committed by GitHub
commit 4ed0abcb55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 58 additions and 70 deletions

View File

@ -240,14 +240,14 @@ DEFPY (show_ip_eigrp_interfaces,
struct eigrp *eigrp; struct eigrp *eigrp;
if (vrf && strncmp(vrf, "all", sizeof("all")) == 0) { if (vrf && strncmp(vrf, "all", sizeof("all")) == 0) {
struct vrf *vrf; struct vrf *v;
RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { RB_FOREACH (v, vrf_name_head, &vrfs_by_name) {
eigrp = eigrp_lookup(vrf->vrf_id); eigrp = eigrp_lookup(v->vrf_id);
if (!eigrp) if (!eigrp)
continue; continue;
vty_out(vty, "VRF %s:\n", vrf->name); vty_out(vty, "VRF %s:\n", v->name);
eigrp_interface_helper(vty, eigrp, ifname, detail); eigrp_interface_helper(vty, eigrp, ifname, detail);
} }

View File

@ -429,7 +429,6 @@ static char *zencrypt(const char *passwd)
{ {
char salt[6]; char salt[6];
struct timeval tv; struct timeval tv;
char *crypt(const char *, const char *);
gettimeofday(&tv, 0); gettimeofday(&tv, 0);

View File

@ -382,7 +382,6 @@ static void vty_auth(struct vty *vty, char *buf)
char *passwd = NULL; char *passwd = NULL;
enum node_type next_node = 0; enum node_type next_node = 0;
int fail; int fail;
char *crypt(const char *, const char *);
switch (vty->node) { switch (vty->node) {
case AUTH_NODE: case AUTH_NODE:

View File

@ -89,7 +89,7 @@ ssize_t zbuf_read(struct zbuf *zb, int fd, size_t maxlen)
zb->tail += r; zb->tail += r;
else if (r == 0) else if (r == 0)
r = -2; r = -2;
else if (r < 0 && ERRNO_IO_RETRY(errno)) else if (ERRNO_IO_RETRY(errno))
r = 0; r = 0;
return r; return r;
@ -109,7 +109,7 @@ ssize_t zbuf_write(struct zbuf *zb, int fd)
zbuf_reset(zb); zbuf_reset(zb);
} else if (r == 0) } else if (r == 0)
r = -2; r = -2;
else if (r < 0 && ERRNO_IO_RETRY(errno)) else if (ERRNO_IO_RETRY(errno))
r = 0; r = 0;
return r; return r;
@ -128,7 +128,7 @@ ssize_t zbuf_recv(struct zbuf *zb, int fd)
zb->tail += r; zb->tail += r;
else if (r == 0) else if (r == 0)
r = -2; r = -2;
else if (r < 0 && ERRNO_IO_RETRY(errno)) else if (ERRNO_IO_RETRY(errno))
r = 0; r = 0;
return r; return r;
} }

View File

@ -165,8 +165,6 @@ static uint32_t ospf6_interface_get_cost(struct ospf6_interface *oi)
cost = (uint32_t)((double)refbw / (double)bw + (double)0.5); cost = (uint32_t)((double)refbw / (double)bw + (double)0.5);
if (cost < 1) if (cost < 1)
cost = 1; cost = 1;
else if (cost > UINT32_MAX)
cost = UINT32_MAX;
} }
return cost; return cost;

View File

@ -21,7 +21,6 @@ import os
import subprocess import subprocess
import re import re
import argparse import argparse
import subprocess
import json import json
structs = ['xref', 'xref_logmsg', 'xref_threadsched', 'xref_install_element', 'xrefdata', 'xrefdata_logmsg', 'cmd_element'] structs = ['xref', 'xref_logmsg', 'xref_threadsched', 'xref_install_element', 'xrefdata', 'xrefdata_logmsg', 'cmd_element']

View File

@ -255,12 +255,10 @@ ns_id_t zebra_ns_id_get(const char *netnspath, int fd_param)
} }
} }
if (ret <= 0) {
if (errno != EEXIST && ret != 0) { if (errno != EEXIST && ret != 0) {
flog_err( flog_err(EC_LIB_SOCKET,
EC_LIB_SOCKET, "netlink( %u) recvfrom() error 2 when reading: %s", fd,
"netlink( %u) recvfrom() error 2 when reading: %s", safe_strerror(errno));
fd, safe_strerror(errno));
close(sock); close(sock);
if (netnspath) if (netnspath)
close(fd); close(fd);
@ -278,8 +276,7 @@ ns_id_t zebra_ns_id_get(const char *netnspath, int fd_param)
rt->rtgen_family = AF_UNSPEC; rt->rtgen_family = AF_UNSPEC;
nl_attr_put32(nlh, NETLINK_SOCKET_BUFFER_SIZE, NETNSA_FD, fd); nl_attr_put32(nlh, NETLINK_SOCKET_BUFFER_SIZE, NETNSA_FD, fd);
nl_attr_put32(nlh, NETLINK_SOCKET_BUFFER_SIZE, NETNSA_NSID, nl_attr_put32(nlh, NETLINK_SOCKET_BUFFER_SIZE, NETNSA_NSID, ns_id);
ns_id);
ret = send_receive(sock, nlh, seq, buf); ret = send_receive(sock, nlh, seq, buf);
if (ret < 0) { if (ret < 0) {
@ -298,11 +295,9 @@ ns_id_t zebra_ns_id_get(const char *netnspath, int fd_param)
break; break;
} else if (nlh->nlmsg_type == NLMSG_ERROR) { } else if (nlh->nlmsg_type == NLMSG_ERROR) {
struct nlmsgerr *err = struct nlmsgerr *err =
(struct nlmsgerr (struct nlmsgerr *)((char *)nlh +
*)((char *)nlh NETLINK_ALIGN(sizeof(
+ NETLINK_ALIGN(sizeof( struct nlmsghdr)));
struct
nlmsghdr)));
if (err->error < 0) if (err->error < 0)
errno = -err->error; errno = -err->error;
else else
@ -310,11 +305,9 @@ ns_id_t zebra_ns_id_get(const char *netnspath, int fd_param)
break; break;
} }
len = len - NETLINK_ALIGN(nlh->nlmsg_len); len = len - NETLINK_ALIGN(nlh->nlmsg_len);
nlh = (struct nlmsghdr *)((char *)nlh nlh = (struct nlmsghdr *)((char *)nlh +
+ NETLINK_ALIGN( NETLINK_ALIGN(nlh->nlmsg_len));
nlh->nlmsg_len));
} while (len != 0 && ret == 0); } while (len != 0 && ret == 0);
}
if (netnspath) if (netnspath)
close(fd); close(fd);