Skip to content

Commit

Permalink
bf_lpm_trie: fix gcc warning (#1181)
Browse files Browse the repository at this point in the history
This patch fixes the following compiler warning:

../src/bf_lpm_trie/bf_lpm_trie.c:167:56: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  167 |   memmove(&branches->branches[idx], &branches->branches[idx + 1], size);
      |                                                        ^
../src/bf_lpm_trie/bf_lpm_trie.c:152:7: note: 'idx' was declared here
  152 |   int idx;
      |       ^
../src/bf_lpm_trie/bf_lpm_trie.c:267:56: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  267 |   memmove(&prefixes->prefixes[idx], &prefixes->prefixes[idx + 1], size);
      |                                                        ^
../src/bf_lpm_trie/bf_lpm_trie.c:251:7: note: 'idx' was declared here

Signed-off-by: Radostin Stoyanov <[email protected]>
  • Loading branch information
rst0git authored Feb 15, 2023
1 parent 6ec3ef8 commit e3c90ce
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/bf_lpm_trie/bf_lpm_trie.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static inline int delete_branch(node_t *current_node, byte_t byte) {
branches_vec_t *branches = &current_node->branches;
int a = 0;
int b = branches->size;
int idx;
int idx = 0;
while (a < b) {
idx = a + (b - a) / 2;
byte_t v = branches->branches[idx].v;
Expand Down

0 comments on commit e3c90ce

Please sign in to comment.