Skip to content

Commit 88a9103

Browse files
committed
py/binary: Make use of MP_ALIGN.
1 parent 3048433 commit 88a9103

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

py/binary.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr) {
185185
size_t size = mp_binary_get_size(struct_type, val_type, &align);
186186
if (struct_type == '@') {
187187
// Make pointer aligned
188-
p = (byte*)(((mp_uint_t)p + align - 1) & ~((mp_uint_t)align - 1));
188+
p = (byte*)MP_ALIGN(p, (size_t)align);
189189
#if MP_ENDIANNESS_LITTLE
190190
struct_type = '<';
191191
#else
@@ -250,7 +250,7 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **
250250
size_t size = mp_binary_get_size(struct_type, val_type, &align);
251251
if (struct_type == '@') {
252252
// Make pointer aligned
253-
p = (byte*)(((mp_uint_t)p + align - 1) & ~((mp_uint_t)align - 1));
253+
p = (byte*)MP_ALIGN(p, (size_t)align);
254254
if (MP_ENDIANNESS_LITTLE) {
255255
struct_type = '<';
256256
} else {

0 commit comments

Comments
 (0)