Skip to content

Commit 49c47da

Browse files
stinosdpgeorge
authored andcommitted
Fix errors after enabling -Wpointer-arith
1 parent 4e54c87 commit 49c47da

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

py/objarray.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include <string.h>
2929
#include <assert.h>
30+
#include <stdint.h>
3031

3132
#include "mpconfig.h"
3233
#include "nlr.h"
@@ -292,7 +293,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
292293
#endif
293294
} else {
294295
res = array_new(o->typecode, slice.stop - slice.start);
295-
memcpy(res->items, o->items + slice.start * sz, (slice.stop - slice.start) * sz);
296+
memcpy(res->items, (uint8_t*)o->items + slice.start * sz, (slice.stop - slice.start) * sz);
296297
}
297298
return res;
298299
#endif
@@ -331,7 +332,7 @@ STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_ui
331332
// read-only memoryview
332333
return 1;
333334
}
334-
bufinfo->buf += (mp_uint_t)o->free * sz;
335+
bufinfo->buf = (uint8_t*)bufinfo->buf + (mp_uint_t)o->free * sz;
335336
}
336337
#endif
337338
return 0;

stmhal/string0.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ void *memcpy(void *dst, const void *src, size_t n) {
6565
}
6666

6767
void *memmove(void *dest, const void *src, size_t n) {
68-
if (src < dest && dest < src + n) {
68+
if (src < dest && (uint8_t*)dest < (const uint8_t*)src + n) {
6969
// need to copy backwards
70-
uint8_t *d = dest + n - 1;
71-
const uint8_t *s = src + n - 1;
70+
uint8_t *d = (uint8_t*)dest + n - 1;
71+
const uint8_t *s = (const uint8_t*)src + n - 1;
7272
for (; n > 0; n--) {
7373
*d-- = *s--;
7474
}

0 commit comments

Comments
 (0)