[Skiboot] [PATCH 02/51] ffspart, libflash: Fix stack size warnings
Andrew Jeffery
andrew at aj.id.au
Fri Feb 15 17:56:19 AEDT 2019
libflash/file.c: In function 'file_erase':
libflash/file.c:134:1: error: the frame size of 4128 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
}
^
and
ffspart.c: In function ‘main’:
ffspart.c:529:1: error: the frame size of 4864 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
}
^
In both cases, mark the local variables as static to avoid the stack.
The static approach is valid for file.c as the buffer is always filled
with `~0`. Given it's now going to be in .bss due to static we have to
still perform the memset(), but racing memset()s in this fashion won't
be harmful, just wasteful.
For ffspart.c's main(), there are bigger problems if that needs to be
re-entrant.
Signed-off-by: Andrew Jeffery <andrew at aj.id.au>
---
external/ffspart/ffspart.c | 4 +++-
libflash/file.c | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/external/ffspart/ffspart.c b/external/ffspart/ffspart.c
index bb46a9eaf311..9fc015cf872b 100644
--- a/external/ffspart/ffspart.c
+++ b/external/ffspart/ffspart.c
@@ -350,7 +350,9 @@ static void print_help(const char *pname)
int main(int argc, char *argv[])
{
- char *pnor = NULL, *input = NULL, line[MAX_LINE];
+ static char line[MAX_LINE];
+
+ char *pnor = NULL, *input = NULL;
bool toc_created = false, bad_input = false, allow_empty = false;
uint32_t block_size = 0, block_count = 0;
struct ffs_hdr *tocs[MAX_TOCS] = { 0 };
diff --git a/libflash/file.c b/libflash/file.c
index 72765b5777f9..d790e29df103 100644
--- a/libflash/file.c
+++ b/libflash/file.c
@@ -117,7 +117,7 @@ static int file_write(struct blocklevel_device *bl, uint64_t dst, const void *sr
*/
static int file_erase(struct blocklevel_device *bl, uint64_t dst, uint64_t len)
{
- char buf[4096];
+ static char buf[4096];
int i = 0;
int rc;
--
2.19.1
More information about the Skiboot
mailing list