Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib vtysh zebra: variable shadowing fixes #3007

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ in one shot. */

/* Free printed buffer data. */
while (written > 0) {
struct buffer_data *d;
if (!(d = b->head)) {
flog_err(
LIB_ERR_DEVELOPMENT,
Expand Down
6 changes: 3 additions & 3 deletions lib/command_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/grammar_sandbox.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lib/linklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
8 changes: 4 additions & 4 deletions lib/termtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
Expand All @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions vtysh/vtysh_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions zebra/rt_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,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;
Expand Down Expand Up @@ -2271,7 +2271,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)
Expand All @@ -2283,7 +2283,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;

Expand Down