Skip to content

Commit

Permalink
externalterm: rename macro for clarity
Browse files Browse the repository at this point in the history
REMOVE_SIGN tells more that it just takes the minus away.

Signed-off-by: Davide Bettio <davide@uninstall.it>
  • Loading branch information
bettio committed Nov 29, 2023
1 parent 077e089 commit 155ac69
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libAtomVM/externalterm.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#define SMALL_ATOM_EXT_BASE_SIZE 2

// Assuming two's-complement implementation of signed integers
#define SIGNED_INT_TO_UNSIGNED(val, unsigned_type) \
#define REMOVE_SIGN(val, unsigned_type) \
((val) < 0 ? ~((unsigned_type) (val)) + 1 : (unsigned_type) (val))

// MAINTENANCE NOTE. Range checking on the external term buffer is only performed in
Expand Down Expand Up @@ -240,7 +240,7 @@ static int serialize_term(uint8_t *buf, term t, GlobalContext *glb)
}
return INTEGER_EXT_SIZE;
} else {
avm_uint64_t unsigned_val = SIGNED_INT_TO_UNSIGNED(val, avm_uint64_t);
avm_uint64_t unsigned_val = REMOVE_SIGN(val, avm_uint64_t);
uint8_t num_bytes = get_num_bytes(unsigned_val);
if (buf != NULL) {
buf[0] = SMALL_BIG_EXT;
Expand Down

0 comments on commit 155ac69

Please sign in to comment.