From caa132a236f12380dfa673adf8f9bdad0051f799 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 26 Jun 2017 14:29:30 +1000 Subject: [PATCH] esp8266/machine_rtc: Use correct arithmetic for aligning RTC mem len. --- esp8266/machine_rtc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esp8266/machine_rtc.c b/esp8266/machine_rtc.c index b17bcb2616..b92ce1d5a9 100644 --- a/esp8266/machine_rtc.c +++ b/esp8266/machine_rtc.c @@ -173,7 +173,7 @@ STATIC mp_obj_t pyb_rtc_memory(mp_uint_t n_args, const mp_obj_t *args) { // read RTC memory system_rtc_mem_read(MEM_USER_LEN_ADDR, &len, sizeof(len)); - system_rtc_mem_read(MEM_USER_DATA_ADDR, rtcram, len + (4 - len % 4)); + system_rtc_mem_read(MEM_USER_DATA_ADDR, rtcram, (len + 3) & ~3); return mp_obj_new_bytes(rtcram, len); } else { @@ -195,7 +195,7 @@ STATIC mp_obj_t pyb_rtc_memory(mp_uint_t n_args, const mp_obj_t *args) { rtcram[i] = ((uint8_t *)bufinfo.buf)[i]; } - system_rtc_mem_write(MEM_USER_DATA_ADDR, rtcram, len + (4 - len % 4)); + system_rtc_mem_write(MEM_USER_DATA_ADDR, rtcram, (len + 3) & ~3); return mp_const_none; }