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

zebra: Fix coverity issues #16270

Merged
merged 3 commits into from
Jun 25, 2024
Merged
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
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
Loading