diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-09-13 14:38:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-13 14:38:32 +0200 |
commit | 6efca3442f9e74c789803cbcfba330cd12de7863 (patch) | |
tree | c9f2e7511ba0ee99ec763c86f5c0a21fa14b293d | |
parent | Merge pull request #3006 from pacovn/static_analysis__shadow_variables1 (diff) | |
parent | lib vtysh zebra: variable shadowing fixes (diff) | |
download | frr-6efca3442f9e74c789803cbcfba330cd12de7863.tar.xz frr-6efca3442f9e74c789803cbcfba330cd12de7863.zip |
Merge pull request #3007 from pacovn/static_analysis__shadow_variables2
lib vtysh zebra: variable shadowing fixes
-rw-r--r-- | lib/buffer.c | 1 | ||||
-rw-r--r-- | lib/command_match.c | 6 | ||||
-rw-r--r-- | lib/grammar_sandbox.c | 4 | ||||
-rw-r--r-- | lib/linklist.c | 4 | ||||
-rw-r--r-- | lib/termtable.c | 8 | ||||
-rw-r--r-- | vtysh/vtysh_main.c | 3 | ||||
-rw-r--r-- | zebra/rt_netlink.c | 6 |
7 files changed, 15 insertions, 17 deletions
diff --git a/lib/buffer.c b/lib/buffer.c index 0bf75e4c3..11bacf83b 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -446,7 +446,6 @@ in one shot. */ /* Free printed buffer data. */ while (written > 0) { - struct buffer_data *d; if (!(d = b->head)) { flog_err( LIB_ERR_DEVELOPMENT, diff --git a/lib/command_match.c b/lib/command_match.c index c165305d7..a1ae3ac6b 100644 --- a/lib/command_match.c +++ b/lib/command_match.c @@ -195,7 +195,7 @@ static enum matcher_rv command_match_r(struct graph_node *start, vector vline, enum matcher_rv status = MATCHER_NO_MATCH; // get the minimum match level that can count as a full match - struct cmd_token *token = start->data; + struct cmd_token *copy, *token = start->data; enum match_type minmatch = min_match_level(token->type); /* check history/stack of tokens @@ -326,8 +326,8 @@ static enum matcher_rv command_match_r(struct graph_node *start, vector vline, } if (*currbest) { // copy token, set arg and prepend to currbest - struct cmd_token *token = start->data; - struct cmd_token *copy = cmd_token_dup(token); + token = start->data; + copy = cmd_token_dup(token); copy->arg = XSTRDUP(MTYPE_CMD_ARG, input_token); listnode_add_before(*currbest, (*currbest)->head, copy); } else if (n + 1 == vector_active(vline) && status == MATCHER_NO_MATCH) diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c index ef03e8521..0d6200b00 100644 --- a/lib/grammar_sandbox.c +++ b/lib/grammar_sandbox.c @@ -315,7 +315,7 @@ static void cmd_graph_permute(struct list *out, struct graph_node **stack, struct graph_node *gn = stack[stackpos]; struct cmd_token *tok = gn->data; char *appendp = cmd + strlen(cmd); - size_t i, j; + size_t j; if (tok->type < SPECIAL_TKN) { sprintf(appendp, "%s ", tok->text); @@ -332,7 +332,7 @@ static void cmd_graph_permute(struct list *out, struct graph_node **stack, if (++stackpos == CMD_ARGC_MAX) return; - for (i = 0; i < vector_active(gn->to); i++) { + for (size_t i = 0; i < vector_active(gn->to); i++) { struct graph_node *gnext = vector_slot(gn->to, i); for (j = 0; j < stackpos; j++) if (stack[j] == gnext) diff --git a/lib/linklist.c b/lib/linklist.c index effd384e4..bee9d05a2 100644 --- a/lib/linklist.c +++ b/lib/linklist.c @@ -318,8 +318,8 @@ void list_sort(struct list *list, int (*cmp)(const void **, const void **)) qsort(items, n, sizeof(void *), realcmp); - for (unsigned int i = 0; i < n; ++i) - listnode_add(list, items[i]); + for (unsigned int j = 0; j < n; ++j) + listnode_add(list, items[j]); XFREE(MTYPE_TMP, items); } diff --git a/lib/termtable.c b/lib/termtable.c index ba85962cc..7bdb1ff87 100644 --- a/lib/termtable.c +++ b/lib/termtable.c @@ -395,7 +395,7 @@ char *ttable_dump(struct ttable *tt, const char *newline) memcpy(&buf[pos], left, lsize); pos += lsize; - for (size_t i = 0; i < width - lsize - rsize; i++) + for (size_t l = 0; l < width - lsize - rsize; l++) buf[pos++] = row[0].style.border.top; pos -= width - lsize - rsize; @@ -421,7 +421,7 @@ char *ttable_dump(struct ttable *tt, const char *newline) buf[pos++] = row[j].style.border.left; /* print left padding */ - for (int i = 0; i < row[j].style.lpad; i++) + for (int k = 0; k < row[j].style.lpad; k++) buf[pos++] = ' '; /* calculate padding for sprintf */ @@ -443,7 +443,7 @@ char *ttable_dump(struct ttable *tt, const char *newline) pos += sprintf(&buf[pos], fmt, abspad, row[j].text); /* print right padding */ - for (int i = 0; i < row[j].style.rpad; i++) + for (int k = 0; k < row[j].style.rpad; k++) buf[pos++] = ' '; /* if right border && not last col print right border */ @@ -483,7 +483,7 @@ char *ttable_dump(struct ttable *tt, const char *newline) memcpy(&buf[pos], left, lsize); pos += lsize; - for (size_t i = 0; i < width - lsize - rsize; i++) + for (size_t l = 0; l < width - lsize - rsize; l++) buf[pos++] = tt->style.border.bottom; memcpy(&buf[pos], right, rsize); diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index 7e979f2c8..777eed7b5 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -596,7 +596,6 @@ int main(int argc, char **argv, char **env) vtysh_execute("enable"); while (cmd != NULL) { - int ret; char *eol; while ((eol = strchr(cmd->line, '\n')) != NULL) { @@ -662,7 +661,7 @@ int main(int argc, char **argv, char **env) /* Boot startup configuration file. */ if (boot_flag) { vtysh_flock_config(frr_config); - int ret = vtysh_read_config(frr_config); + ret = vtysh_read_config(frr_config); vtysh_unflock_config(); if (ret) { fprintf(stderr, diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 63bb2754e..70bd8a784 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -585,7 +585,7 @@ static int netlink_route_change_read_unicast(struct nlmsghdr *h, ns_id_t ns_id, for (;;) { struct nexthop *nh = NULL; - vrf_id_t nh_vrf_id; + if (len < (int)sizeof(*rtnh) || rtnh->rtnh_len > len) break; @@ -2277,7 +2277,7 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id) /* Drop some "permanent" entries. */ if (ndm->ndm_state & NUD_PERMANENT) { - char buf[16] = "169.254.0.1"; + char b[16] = "169.254.0.1"; struct in_addr ipv4_ll; if (ndm->ndm_family != AF_INET) @@ -2289,7 +2289,7 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id) if (h->nlmsg_type != RTM_DELNEIGH) return 0; - inet_pton(AF_INET, buf, &ipv4_ll); + inet_pton(AF_INET, b, &ipv4_ll); if (ipv4_ll.s_addr != ip.ip._v4_addr.s_addr) return 0; |