Skip to content

Commit 1ccbc6b

Browse files
committed
Fix term/non-term func CodeQL alerts with casts and proper types
Signed-off-by: Paul Guyot <pguyot@kallisys.net>
1 parent 6f66fa4 commit 1ccbc6b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/libAtomVM/jit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ static term jit_bitstring_extract_integer(
13041304
if (n <= 64) {
13051305
union maybe_unsigned_int64 value;
13061306
bool status = bitstring_extract_integer(
1307-
((term) bin_ptr) | TERM_PRIMARY_BOXED, offset, n, bs_flags, &value);
1307+
(term) (((uintptr_t) bin_ptr) | TERM_PRIMARY_BOXED), offset, n, bs_flags, &value);
13081308
if (UNLIKELY(!status)) {
13091309
return FALSE_ATOM;
13101310
}
@@ -1336,13 +1336,13 @@ static term jit_bitstring_extract_float(Context *ctx, term *bin_ptr, size_t offs
13361336
bool status;
13371337
switch (n) {
13381338
case 16:
1339-
status = bitstring_extract_f16(((term) bin_ptr) | TERM_PRIMARY_BOXED, offset, n, bs_flags, &value);
1339+
status = bitstring_extract_f16((term) (((uintptr_t) bin_ptr) | TERM_PRIMARY_BOXED), offset, n, bs_flags, &value);
13401340
break;
13411341
case 32:
1342-
status = bitstring_extract_f32(((term) bin_ptr) | TERM_PRIMARY_BOXED, offset, n, bs_flags, &value);
1342+
status = bitstring_extract_f32((term) (((uintptr_t) bin_ptr) | TERM_PRIMARY_BOXED), offset, n, bs_flags, &value);
13431343
break;
13441344
case 64:
1345-
status = bitstring_extract_f64(((term) bin_ptr) | TERM_PRIMARY_BOXED, offset, n, bs_flags, &value);
1345+
status = bitstring_extract_f64((term) (((uintptr_t) bin_ptr) | TERM_PRIMARY_BOXED), offset, n, bs_flags, &value);
13461346
break;
13471347
default:
13481348
status = false;

src/libAtomVM/opcodesswitch.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2927,7 +2927,7 @@ HOT_FUNC int scheduler_entry_point(GlobalContext *glb)
29272927
// Redo the offset computation and refetch the label
29282928
int label;
29292929
DECODE_LABEL(label, pc)
2930-
int timeout;
2930+
term timeout;
29312931
DECODE_COMPACT_TERM(timeout, pc)
29322932
TRACE("wait_timeout_trap_handler, label: %i\n", label);
29332933
PROCESS_SIGNAL_MESSAGES();
@@ -4464,8 +4464,8 @@ HOT_FUNC int scheduler_entry_point(GlobalContext *glb)
44644464
DECODE_COMPACT_TERM(src, pc);
44654465
term arg2;
44664466
DECODE_COMPACT_TERM(arg2, pc);
4467-
term flags;
4468-
DECODE_LITERAL(flags, pc);
4467+
uint32_t flags_value;
4468+
DECODE_LITERAL(flags_value, pc);
44694469

44704470
#ifdef IMPL_CODE_LOADER
44714471
TRACE("bs_skip_utf16/5\n");
@@ -4481,7 +4481,7 @@ HOT_FUNC int scheduler_entry_point(GlobalContext *glb)
44814481

44824482
int32_t val = 0;
44834483
size_t out_size = 0;
4484-
bool is_valid = bitstring_match_utf16(src_bin, (size_t) offset_bits, &val, &out_size, flags);
4484+
bool is_valid = bitstring_match_utf16(src_bin, (size_t) offset_bits, &val, &out_size, flags_value);
44854485

44864486
if (!is_valid) {
44874487
pc = mod->labels[fail];
@@ -4576,8 +4576,8 @@ HOT_FUNC int scheduler_entry_point(GlobalContext *glb)
45764576
DECODE_COMPACT_TERM(src, pc);
45774577
term arg2;
45784578
DECODE_COMPACT_TERM(arg2, pc);
4579-
term flags;
4580-
DECODE_LITERAL(flags, pc);
4579+
uint32_t flags_value;
4580+
DECODE_LITERAL(flags_value, pc);
45814581

45824582
#ifdef IMPL_CODE_LOADER
45834583
TRACE("bs_skip_utf32/5\n");
@@ -4592,7 +4592,7 @@ HOT_FUNC int scheduler_entry_point(GlobalContext *glb)
45924592
avm_int_t offset_bits = term_get_match_state_offset(src);
45934593

45944594
int32_t val = 0;
4595-
bool is_valid = bitstring_match_utf32(src_bin, (size_t) offset_bits, &val, flags);
4595+
bool is_valid = bitstring_match_utf32(src_bin, (size_t) offset_bits, &val, flags_value);
45964596

45974597
if (!is_valid) {
45984598
pc = mod->labels[fail];

0 commit comments

Comments
 (0)