Merge pull request #16270 from cscarpitta/fix/fix-coverity-issues

zebra: Fix coverity issues
This commit is contained in:
Donatas Abraitis 2024-06-25 08:53:13 +03:00 committed by GitHub
commit e5faf01dcc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -956,11 +956,12 @@ static bool zebra_srv6_sid_compose(struct in6_addr *sid_value,
uint32_t sid_func) uint32_t sid_func)
{ {
uint8_t offset, func_len; uint8_t offset, func_len;
struct srv6_sid_format *format = locator->sid_format; struct srv6_sid_format *format;
if (!sid_value || !locator) if (!sid_value || !locator)
return false; return false;
format = locator->sid_format;
if (format) { if (format) {
offset = format->block_len + format->node_len; offset = format->block_len + format->node_len;
func_len = format->function_len; func_len = format->function_len;
@ -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), __func__, srv6_sid_ctx2str(buf, sizeof(buf), ctx),
sid_value, srv6_sid_alloc_mode2str(alloc_mode)); sid_value, srv6_sid_alloc_mode2str(alloc_mode));
switch (alloc_mode) { if (alloc_mode == SRV6_SID_ALLOC_MODE_EXPLICIT) {
case SRV6_SID_ALLOC_MODE_EXPLICIT:
/* /*
* Explicit SID allocation: allocate a specific SID value * Explicit SID allocation: allocate a specific SID value
*/ */
@ -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); ret = get_srv6_sid_explicit(sid, ctx, sid_value);
} else {
break;
case SRV6_SID_ALLOC_MODE_DYNAMIC:
/* /*
* Dynamic SID allocation: allocate any available SID value * Dynamic SID allocation: allocate any available SID value
*/ */
@ -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); 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; return ret;
@ -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 for (ALL_LIST_ELEMENTS_RO(block->u.usid
.wide_lib[sid_func] .wide_lib[sid_func]
.func_allocated, .func_allocated,
node, sid_func_ptr)) node, sid_wide_func_ptr))
if (*sid_wide_func_ptr == sid_wide_func) if (*sid_wide_func_ptr == sid_wide_func)
break; break;