From 7bcc0252a93510268e45418b19fefa7987d225ff Mon Sep 17 00:00:00 2001 From: Robin Stuart Date: Wed, 30 Oct 2019 07:46:36 +0000 Subject: [PATCH] Supress malloc warning using gcc 8 Explicitly prevents malloc with negative number to supress -Walloc-size-larger-than Fixes #168 reported by Ian Jeffray --- backend/reedsol.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/reedsol.c b/backend/reedsol.c index 53b4e565..b1610800 100644 --- a/backend/reedsol.c +++ b/backend/reedsol.c @@ -49,7 +49,7 @@ // size. #include // only needed for debug (main) -#include // only needed for malloc/free +#include #include "reedsol.h" static int logmod; // 2**symsize - 1 static int rlen; @@ -75,6 +75,11 @@ void rs_init_gf(const int poly) { b >>= 1; m--; + // Ensure m not negative to supress gcc -Walloc-size-larger-than + if (m < 0) { + m = 0; + } + // Calculate the log/alog tables logmod = (1 << m) - 1; logt = (int *) malloc(sizeof (int) * (logmod + 1));