Skip to content

Commit 435d16d

Browse files
committed
Fix term asserts
memory.c had a missing semicolon, get/put_tuple_element in term.h unpacked header directly instead of using function. Additionally, first condition is already checked by term_is_tuple(). There's one unfixed assert TERM_DEBUG_ASSERT((t & 0x3) == 0x2); but fixing it would create conflicts with atomvm#1701 (changes magic values to macros). Signed-off-by: Jakub Gonet <jakub.gonet@swmansion.com>
1 parent 542d36b commit 435d16d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/libAtomVM/memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ void memory_sweep_mso_list(term mso_list, GlobalContext *global, bool from_task)
961961
while (l != term_nil()) {
962962
term h = term_get_list_head(l);
963963
// the mso list only contains boxed values; each refc is unique
964-
TERM_DEBUG_ASSERT(term_is_boxed(h))
964+
TERM_DEBUG_ASSERT(term_is_boxed(h));
965965
term *boxed_value = term_to_term_ptr(h);
966966
if (memory_is_moved_marker(boxed_value)) {
967967
h = memory_dereference_moved_marker(boxed_value);

src/libAtomVM/term.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ static inline void term_put_tuple_element(term t, uint32_t elem_index, term put_
16831683

16841684
term *boxed_value = term_to_term_ptr(t);
16851685

1686-
TERM_DEBUG_ASSERT(((boxed_value[0] & TERM_BOXED_TAG_MASK) == 0) && (elem_index < (boxed_value[0] >> 6)));
1686+
TERM_DEBUG_ASSERT((size_t) elem_index < term_get_size_from_boxed_header(boxed_value[0]));
16871687

16881688
boxed_value[elem_index + 1] = put_value;
16891689
}
@@ -1702,7 +1702,7 @@ static inline term term_get_tuple_element(term t, int elem_index)
17021702

17031703
const term *boxed_value = term_to_const_term_ptr(t);
17041704

1705-
TERM_DEBUG_ASSERT(((boxed_value[0] & TERM_BOXED_TAG_MASK) == 0) && (elem_index < (boxed_value[0] >> 6)));
1705+
TERM_DEBUG_ASSERT((size_t) elem_index < term_get_size_from_boxed_header(boxed_value[0]));
17061706

17071707
return boxed_value[elem_index + 1];
17081708
}

0 commit comments

Comments
 (0)