Skip to content

Commit caecf3b

Browse files
committed
fixup heap: fixed the bug of uninitialized variables
Signed-off-by: John Sanpe <sanpeqf@gmail.com>
1 parent 9fee55f commit caecf3b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/heap.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <bfdev/heap.h>
77
#include <bfdev/bitops.h>
88
#include <bfdev/titer.h>
9+
#include <bfdev/bug.h>
910
#include <export.h>
1011

1112
static __bfdev_always_inline void
@@ -179,12 +180,14 @@ bfdev_heap_parent(bfdev_heap_root_t *root, bfdev_heap_node_t **parentp,
179180
unsigned int depth;
180181

181182
link = &root->node;
182-
if (bfdev_unlikely(!*link)) {
183-
*parentp = BFDEV_NULL;
183+
*parentp = BFDEV_NULL;
184+
185+
if (bfdev_unlikely(!*link))
184186
return link;
185-
}
186187

187188
depth = bfdev_flsuf(root->count + 1);
189+
BFDEV_BUG_ON(!depth);
190+
188191
while (depth--) {
189192
*parentp = *link;
190193
if ((root->count + 1) & BFDEV_BIT(depth))

0 commit comments

Comments
 (0)