Skip to content

Commit

Permalink
Merge pull request #16270 from cscarpitta/fix/fix-coverity-issues
Browse files Browse the repository at this point in the history
zebra: Fix coverity issues
  • Loading branch information
ton31337 authored Jun 25, 2024
2 parents 67421ba + df97a9d commit e5faf01
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions zebra/zebra_srv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,11 +956,12 @@ static bool zebra_srv6_sid_compose(struct in6_addr *sid_value,
uint32_t sid_func)
{
uint8_t offset, func_len;
struct srv6_sid_format *format = locator->sid_format;
struct srv6_sid_format *format;

if (!sid_value || !locator)
return false;

format = locator->sid_format;
if (format) {
offset = format->block_len + format->node_len;
func_len = format->function_len;
Expand Down Expand Up @@ -1742,8 +1743,7 @@ int get_srv6_sid(struct zebra_srv6_sid **sid, struct srv6_sid_ctx *ctx,
__func__, srv6_sid_ctx2str(buf, sizeof(buf), ctx),
sid_value, srv6_sid_alloc_mode2str(alloc_mode));

switch (alloc_mode) {
case SRV6_SID_ALLOC_MODE_EXPLICIT:
if (alloc_mode == SRV6_SID_ALLOC_MODE_EXPLICIT) {
/*
* Explicit SID allocation: allocate a specific SID value
*/
Expand All @@ -1755,9 +1755,7 @@ int get_srv6_sid(struct zebra_srv6_sid **sid, struct srv6_sid_ctx *ctx,
}

ret = get_srv6_sid_explicit(sid, ctx, sid_value);

break;
case SRV6_SID_ALLOC_MODE_DYNAMIC:
} else {
/*
* Dynamic SID allocation: allocate any available SID value
*/
Expand All @@ -1776,16 +1774,6 @@ int get_srv6_sid(struct zebra_srv6_sid **sid, struct srv6_sid_ctx *ctx,
}

ret = get_srv6_sid_dynamic(sid, ctx, locator);

break;
case SRV6_SID_ALLOC_MODE_MAX:
case SRV6_SID_ALLOC_MODE_UNSPEC:
default:
flog_err(EC_ZEBRA_SM_CANNOT_ASSIGN_SID,
"%s: SRv6 Manager: Unrecognized alloc mode %u",
__func__, alloc_mode);
/* We should never arrive here */
assert(0);
}

return ret;
Expand Down Expand Up @@ -1856,7 +1844,7 @@ static bool release_srv6_sid_func_explicit(struct zebra_srv6_sid_block *block,
for (ALL_LIST_ELEMENTS_RO(block->u.usid
.wide_lib[sid_func]
.func_allocated,
node, sid_func_ptr))
node, sid_wide_func_ptr))
if (*sid_wide_func_ptr == sid_wide_func)
break;

Expand Down

0 comments on commit e5faf01

Please sign in to comment.