From 84bfd68fb5fc32debaf95551ffeafb5ea1583033 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Sat, 15 Aug 2020 09:57:10 -0400 Subject: [PATCH] Battery_bench & announce_status stack fix had stack growing the wrong way Change-Id: I51bf14526f5239e77e15dc0ffd76ad3ed8bdcbc8 --- apps/plugins/announce_status.c | 6 +++--- apps/plugins/battery_bench.c | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/plugins/announce_status.c b/apps/plugins/announce_status.c index a1e9f430a8..92f9aa28ec 100644 --- a/apps/plugins/announce_status.c +++ b/apps/plugins/announce_status.c @@ -438,7 +438,7 @@ void plugin_buffer_init(void) { rb->memset(&gThread, 0, sizeof(gThread)); gThread.buf = rb->plugin_get_buffer(&gThread.buf_size); - ALIGN_BUFFER(gThread.buf, gThread.buf_size, 4); + ALIGN_BUFFER(gThread.buf, gThread.buf_size, sizeof(long)); } } @@ -448,9 +448,9 @@ void thread_create(void) gThread.stacksize = gThread.buf_size; gThread.buf_size -= gThread.stacksize; - gThread.stack = (long *) gThread.buf + gThread.buf_size; + gThread.stack = (long *) gThread.buf; - ALIGN_BUFFER(gThread.stack, gThread.stacksize, 4); + ALIGN_BUFFER(gThread.stack, gThread.stacksize, sizeof(long)); if (gThread.stacksize < DEFAULT_STACK_SIZE) { diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index 75c448bb27..ff979abd8e 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c @@ -656,9 +656,7 @@ enum plugin_status plugin_start(const void* parameter) rb->memset(buf, 0, buf_size); gThread.stacksize = buf_size; - gThread.stack = (long *) buf + buf_size; /* stack grows towards *buf */ - - ALIGN_BUFFER(gThread.stack, gThread.stacksize, sizeof(long)); + gThread.stack = (long *) buf; if (gThread.stacksize < MIN_THREAD_STACK_SIZE) {