mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 02:37:21 +00:00
lib: fix clang SA warnings
Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
parent
fa62132278
commit
00138ffb47
23
lib/darr.h
23
lib/darr.h
@ -77,6 +77,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <zebra.h>
|
#include <zebra.h>
|
||||||
|
#include <limits.h>
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
DECLARE_MTYPE(DARR);
|
DECLARE_MTYPE(DARR);
|
||||||
@ -249,6 +250,10 @@ void *__darr_resize(void *a, uint count, size_t esize, struct memtype *mt);
|
|||||||
* pointers into the previous memory block are no longer valid. The `A` value
|
* pointers into the previous memory block are no longer valid. The `A` value
|
||||||
* is guaranteed not to change if there is sufficient capacity in the array.
|
* is guaranteed not to change if there is sufficient capacity in the array.
|
||||||
*
|
*
|
||||||
|
* The exception to the no-change rule is if @C is passed as 0, it will be
|
||||||
|
* considered 1 so that an array is always allocated if currently NULL,
|
||||||
|
* i.e., @A will never be NULL after a call to darr_ensure_cap_mt()
|
||||||
|
*
|
||||||
* Args:
|
* Args:
|
||||||
* A: (IN/OUT) the dynamic array, can be NULL.
|
* A: (IN/OUT) the dynamic array, can be NULL.
|
||||||
* C: Total capacity to guarantee.
|
* C: Total capacity to guarantee.
|
||||||
@ -259,8 +264,9 @@ void *__darr_resize(void *a, uint count, size_t esize, struct memtype *mt);
|
|||||||
#define darr_ensure_cap_mt(A, C, MT) \
|
#define darr_ensure_cap_mt(A, C, MT) \
|
||||||
({ \
|
({ \
|
||||||
/* Cast to avoid warning when C == 0 */ \
|
/* Cast to avoid warning when C == 0 */ \
|
||||||
if ((ssize_t)darr_cap(A) < (ssize_t)(C)) \
|
uint _c = (C) > 0 ? (C) : 1; \
|
||||||
_darr_resize_mt((A), (C), MT); \
|
if ((size_t)darr_cap(A) < _c) \
|
||||||
|
_darr_resize_mt((A), _c, MT); \
|
||||||
(A); \
|
(A); \
|
||||||
})
|
})
|
||||||
#define darr_ensure_cap(A, C) darr_ensure_cap_mt(A, C, MTYPE_DARR)
|
#define darr_ensure_cap(A, C) darr_ensure_cap_mt(A, C, MTYPE_DARR)
|
||||||
@ -285,11 +291,14 @@ void *__darr_resize(void *a, uint count, size_t esize, struct memtype *mt);
|
|||||||
*/
|
*/
|
||||||
#define darr_ensure_i_mt(A, I, MT) \
|
#define darr_ensure_i_mt(A, I, MT) \
|
||||||
({ \
|
({ \
|
||||||
if ((int)(I) > darr_maxi(A)) \
|
assert((int)(I) >= 0 && (int)(I) <= INT_MAX); \
|
||||||
_darr_resize_mt((A), (I) + 1, MT); \
|
int _i = (int)(I); \
|
||||||
if ((I) + 1 > _darr_len(A)) \
|
if (_i > darr_maxi(A)) \
|
||||||
_darr_len(A) = (I) + 1; \
|
_darr_resize_mt((A), _i + 1, MT); \
|
||||||
&(A)[I]; \
|
assert((A) != NULL); \
|
||||||
|
if ((uint)_i + 1 > _darr_len(A)) \
|
||||||
|
_darr_len(A) = _i + 1; \
|
||||||
|
&(A)[_i]; \
|
||||||
})
|
})
|
||||||
#define darr_ensure_i(A, I) darr_ensure_i_mt(A, I, MTYPE_DARR)
|
#define darr_ensure_i(A, I) darr_ensure_i_mt(A, I, MTYPE_DARR)
|
||||||
|
|
||||||
|
@ -806,6 +806,13 @@ static const struct lysc_node *nb_op_sib_first(struct nb_op_yield_state *ys,
|
|||||||
const struct lysc_node *sib = lysc_node_child(parent);
|
const struct lysc_node *sib = lysc_node_child(parent);
|
||||||
const struct lysc_node *first_sib;
|
const struct lysc_node *first_sib;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE: when we want to handle root level walks we will need to use
|
||||||
|
* lys_getnext() to walk root level of each module and
|
||||||
|
* ly_ctx_get_module_iter() to walk the modules.
|
||||||
|
*/
|
||||||
|
assert(darr_len(ys->node_infos) > 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The top of the node stack points at @parent.
|
* The top of the node stack points at @parent.
|
||||||
*
|
*
|
||||||
@ -814,7 +821,7 @@ static const struct lysc_node *nb_op_sib_first(struct nb_op_yield_state *ys,
|
|||||||
* base of the user query, return the next schema node from the query
|
* base of the user query, return the next schema node from the query
|
||||||
* string (schema_path).
|
* string (schema_path).
|
||||||
*/
|
*/
|
||||||
assert(darr_last(ys->node_infos)->schema == parent);
|
assert(darr_last(ys->node_infos) != NULL && darr_last(ys->node_infos)->schema == parent);
|
||||||
if (darr_lasti(ys->node_infos) < ys->query_base_level)
|
if (darr_lasti(ys->node_infos) < ys->query_base_level)
|
||||||
return ys->schema_path[darr_lasti(ys->node_infos) + 1];
|
return ys->schema_path[darr_lasti(ys->node_infos) + 1];
|
||||||
|
|
||||||
@ -1010,10 +1017,14 @@ static enum nb_error __walk(struct nb_op_yield_state *ys, bool is_resume)
|
|||||||
* should be kept.
|
* should be kept.
|
||||||
*/
|
*/
|
||||||
ret = nb_op_iter_leaf(ys, nn, xpath_child);
|
ret = nb_op_iter_leaf(ys, nn, xpath_child);
|
||||||
|
if (ret != NB_OK)
|
||||||
|
goto done;
|
||||||
sib = nb_op_sib_next(ys, sib);
|
sib = nb_op_sib_next(ys, sib);
|
||||||
continue;
|
continue;
|
||||||
case LYS_LEAFLIST:
|
case LYS_LEAFLIST:
|
||||||
ret = nb_op_iter_leaflist(ys, nn, xpath_child);
|
ret = nb_op_iter_leaflist(ys, nn, xpath_child);
|
||||||
|
if (ret != NB_OK)
|
||||||
|
goto done;
|
||||||
sib = nb_op_sib_next(ys, sib);
|
sib = nb_op_sib_next(ys, sib);
|
||||||
continue;
|
continue;
|
||||||
case LYS_CONTAINER:
|
case LYS_CONTAINER:
|
||||||
|
@ -1105,7 +1105,7 @@ static int fe_adapter_send_tree_data(struct mgmt_fe_session_ctx *session,
|
|||||||
LYD_PRINT_WITHSIBLINGS));
|
LYD_PRINT_WITHSIBLINGS));
|
||||||
/* buf may have been reallocated and moved */
|
/* buf may have been reallocated and moved */
|
||||||
msg = (typeof(msg))buf;
|
msg = (typeof(msg))buf;
|
||||||
|
(void)msg; /* suppress clang-SA unused warning on safety code */
|
||||||
|
|
||||||
if (ret != LY_SUCCESS) {
|
if (ret != LY_SUCCESS) {
|
||||||
MGMTD_FE_ADAPTER_ERR("Error building get-tree result for client %s session-id %" PRIu64
|
MGMTD_FE_ADAPTER_ERR("Error building get-tree result for client %s session-id %" PRIu64
|
||||||
|
Loading…
Reference in New Issue
Block a user