Skip to content

Commit

Permalink
Fix usage of binary_hist_size() in raft reference client
Browse files Browse the repository at this point in the history
  • Loading branch information
00pauln00 committed May 31, 2024
1 parent 1d0ea9a commit 50ab2c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/include/binary_hist.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ binary_hist_init(struct binary_hist *bh, int start_bit, int num_buckets)
static inline int
binary_hist_size(const struct binary_hist *bh)
{
if (!bh)
return -EINVAL;

return bh->bh_num_buckets;
}

Expand Down
10 changes: 8 additions & 2 deletions test/raft-reference-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1105,8 +1105,14 @@ raft_client_test_instance_hist_lreg_multi_facet_handler(
struct raft_instance_hist_stats *rihs,
struct lreg_value *lv)
{
if (!lv ||
lv->lrv_value_idx_in >= binary_hist_size(&rihs->rihs_bh))
if (!lv || !rihs)
return -EINVAL;

int hsz = binary_hist_size(&rihs->rihs_bh);
if (hsz < 0)
return hsz;

if (lv->lrv_value_idx_in >= (uint32_t)hsz)
return -EINVAL;

else if (op == LREG_NODE_CB_OP_WRITE_VAL)
Expand Down

0 comments on commit 50ab2c4

Please sign in to comment.