Skip to content

Commit

Permalink
Merge pull request #13670 from donaldsharp/coverity_99
Browse files Browse the repository at this point in the history
Coverity 99
  • Loading branch information
ton31337 authored Jun 5, 2023
2 parents 05cb9e5 + 60dc299 commit fecc953
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 90 deletions.
67 changes: 13 additions & 54 deletions bgpd/bgp_clist.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,6 @@ bool community_list_match(struct community *com, struct community_list *list)
struct community_entry *entry;

for (entry = list->head; entry; entry = entry->next) {
if (entry->any)
return entry->direct == COMMUNITY_PERMIT;

if (entry->style == COMMUNITY_LIST_STANDARD) {
if (community_include(entry->u.com, COMMUNITY_INTERNET))
return entry->direct == COMMUNITY_PERMIT;
Expand All @@ -681,9 +678,6 @@ bool lcommunity_list_match(struct lcommunity *lcom, struct community_list *list)
struct community_entry *entry;

for (entry = list->head; entry; entry = entry->next) {
if (entry->any)
return entry->direct == COMMUNITY_PERMIT;

if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) {
if (lcommunity_match(lcom, entry->u.lcom))
return entry->direct == COMMUNITY_PERMIT;
Expand All @@ -705,9 +699,6 @@ bool lcommunity_list_exact_match(struct lcommunity *lcom,
struct community_entry *entry;

for (entry = list->head; entry; entry = entry->next) {
if (entry->any)
return entry->direct == COMMUNITY_PERMIT;

if (entry->style == LARGE_COMMUNITY_LIST_STANDARD) {
if (lcommunity_cmp(lcom, entry->u.lcom))
return entry->direct == COMMUNITY_PERMIT;
Expand All @@ -724,9 +715,6 @@ bool ecommunity_list_match(struct ecommunity *ecom, struct community_list *list)
struct community_entry *entry;

for (entry = list->head; entry; entry = entry->next) {
if (entry->any)
return entry->direct == COMMUNITY_PERMIT;

if (entry->style == EXTCOMMUNITY_LIST_STANDARD) {
if (ecommunity_match(ecom, entry->u.ecom))
return entry->direct == COMMUNITY_PERMIT;
Expand All @@ -746,9 +734,6 @@ bool community_list_exact_match(struct community *com,
struct community_entry *entry;

for (entry = list->head; entry; entry = entry->next) {
if (entry->any)
return entry->direct == COMMUNITY_PERMIT;

if (entry->style == COMMUNITY_LIST_STANDARD) {
if (community_include(entry->u.com, COMMUNITY_INTERNET))
return entry->direct == COMMUNITY_PERMIT;
Expand Down Expand Up @@ -781,28 +766,18 @@ struct community *community_list_match_delete(struct community *com,
val = community_val_get(com, i);

for (entry = list->head; entry; entry = entry->next) {
if (entry->any) {
if (entry->direct == COMMUNITY_PERMIT) {
com_index_to_delete[delete_index] = i;
delete_index++;
}
break;
}

else if ((entry->style == COMMUNITY_LIST_STANDARD)
&& (community_include(entry->u.com,
COMMUNITY_INTERNET)
|| community_include(entry->u.com, val))) {
if ((entry->style == COMMUNITY_LIST_STANDARD) &&
(community_include(entry->u.com,
COMMUNITY_INTERNET) ||
community_include(entry->u.com, val))) {
if (entry->direct == COMMUNITY_PERMIT) {
com_index_to_delete[delete_index] = i;
delete_index++;
}
break;
}

else if ((entry->style == COMMUNITY_LIST_EXPANDED)
&& community_regexp_include(entry->reg, com,
i)) {
} else if ((entry->style == COMMUNITY_LIST_EXPANDED) &&
community_regexp_include(entry->reg, com,
i)) {
if (entry->direct == COMMUNITY_PERMIT) {
com_index_to_delete[delete_index] = i;
delete_index++;
Expand Down Expand Up @@ -836,12 +811,6 @@ static bool community_list_dup_check(struct community_list *list,
if (entry->direct != new->direct)
continue;

if (entry->any != new->any)
continue;

if (entry->any)
return true;

switch (entry->style) {
case COMMUNITY_LIST_STANDARD:
if (community_cmp(entry->u.com, new->u.com))
Expand Down Expand Up @@ -910,7 +879,6 @@ int community_list_set(struct community_list_handler *ch, const char *name,
entry = community_entry_new();
entry->direct = direct;
entry->style = style;
entry->any = (str ? false : true);
entry->u.com = com;
entry->reg = regex;
entry->seq = seqnum;
Expand Down Expand Up @@ -987,26 +955,19 @@ struct lcommunity *lcommunity_list_match_delete(struct lcommunity *lcom,
for (i = 0; i < lcom->size; i++) {
ptr = lcom->val + (i * LCOMMUNITY_SIZE);
for (entry = list->head; entry; entry = entry->next) {
if (entry->any) {
if (entry->direct == COMMUNITY_PERMIT) {
com_index_to_delete[delete_index] = i;
delete_index++;
}
break;
}

else if ((entry->style == LARGE_COMMUNITY_LIST_STANDARD)
&& lcommunity_include(entry->u.lcom, ptr)) {
if ((entry->style == LARGE_COMMUNITY_LIST_STANDARD) &&
lcommunity_include(entry->u.lcom, ptr)) {
if (entry->direct == COMMUNITY_PERMIT) {
com_index_to_delete[delete_index] = i;
delete_index++;
}
break;
}

else if ((entry->style == LARGE_COMMUNITY_LIST_EXPANDED)
&& lcommunity_regexp_include(entry->reg, lcom,
i)) {
else if ((entry->style ==
LARGE_COMMUNITY_LIST_EXPANDED) &&
lcommunity_regexp_include(entry->reg, lcom,
i)) {
if (entry->direct == COMMUNITY_PERMIT) {
com_index_to_delete[delete_index] = i;
delete_index++;
Expand Down Expand Up @@ -1125,7 +1086,6 @@ int lcommunity_list_set(struct community_list_handler *ch, const char *name,
entry = community_entry_new();
entry->direct = direct;
entry->style = style;
entry->any = (str ? false : true);
entry->u.lcom = lcom;
entry->reg = regex;
entry->seq = seqnum;
Expand Down Expand Up @@ -1246,7 +1206,6 @@ int extcommunity_list_set(struct community_list_handler *ch, const char *name,
entry = community_entry_new();
entry->direct = direct;
entry->style = style;
entry->any = false;
if (ecom)
entry->config = ecommunity_ecom2str(
ecom, ECOMMUNITY_FORMAT_COMMUNITY_LIST, 0);
Expand Down
3 changes: 0 additions & 3 deletions bgpd/bgp_clist.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ struct community_entry {
/* Standard or expanded. */
uint8_t style;

/* Any match. */
bool any;

/* Sequence number. */
int64_t seq;

Expand Down
44 changes: 13 additions & 31 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -20863,16 +20863,13 @@ static const char *community_list_config_str(struct community_entry *entry)
{
const char *str;

if (entry->any)
str = "";
else {
if (entry->style == COMMUNITY_LIST_STANDARD)
str = community_str(entry->u.com, false, false);
else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD)
str = lcommunity_str(entry->u.lcom, false, false);
else
str = entry->config;
}
if (entry->style == COMMUNITY_LIST_STANDARD)
str = community_str(entry->u.com, false, false);
else if (entry->style == LARGE_COMMUNITY_LIST_STANDARD)
str = lcommunity_str(entry->u.lcom, false, false);
else
str = entry->config;

return str;
}

Expand All @@ -20895,13 +20892,8 @@ static void community_list_show(struct vty *vty, struct community_list *list)
: "expanded",
list->name);
}
if (entry->any)
vty_out(vty, " %s\n",
community_direct_str(entry->direct));
else
vty_out(vty, " %s %s\n",
community_direct_str(entry->direct),
community_list_config_str(entry));
vty_out(vty, " %s %s\n", community_direct_str(entry->direct),
community_list_config_str(entry));
}
}

Expand Down Expand Up @@ -21260,13 +21252,8 @@ static void lcommunity_list_show(struct vty *vty, struct community_list *list)
: "expanded",
list->name);
}
if (entry->any)
vty_out(vty, " %s\n",
community_direct_str(entry->direct));
else
vty_out(vty, " %s %s\n",
community_direct_str(entry->direct),
community_list_config_str(entry));
vty_out(vty, " %s %s\n", community_direct_str(entry->direct),
community_list_config_str(entry));
}
}

Expand Down Expand Up @@ -21562,13 +21549,8 @@ static void extcommunity_list_show(struct vty *vty, struct community_list *list)
: "expanded",
list->name);
}
if (entry->any)
vty_out(vty, " %s\n",
community_direct_str(entry->direct));
else
vty_out(vty, " %s %s\n",
community_direct_str(entry->direct),
community_list_config_str(entry));
vty_out(vty, " %s %s\n", community_direct_str(entry->direct),
community_list_config_str(entry));
}
}

Expand Down
3 changes: 1 addition & 2 deletions mgmtd/mgmt_txn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,6 @@ static int mgmt_txn_create_config_batches(struct mgmt_txn_req *txn_req,
}

free(xpath);
xpath = NULL;
}

cmtcfg_req->cmt_stats->last_batch_cnt = num_chgs;
Expand Down Expand Up @@ -2542,7 +2541,7 @@ int mgmt_txn_notify_be_cfgdata_reply(
{
struct mgmt_txn_ctx *txn;
struct mgmt_txn_be_cfg_batch *cfg_btch;
struct mgmt_commit_cfg_req *cmtcfg_req = NULL;
struct mgmt_commit_cfg_req *cmtcfg_req;

txn = mgmt_txn_id2ctx(txn_id);
if (!txn || txn->type != MGMTD_TXN_TYPE_CONFIG)
Expand Down

0 comments on commit fecc953

Please sign in to comment.