Skip to content

Commit d220d08

Browse files
authored
Merge pull request #693 from sanpeqf/fixup-heap
fixup heap: fixed the bug of uninitialized variables
2 parents 9fee55f + caecf3b commit d220d08

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

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)