From 6f3abc4e478b9d91c6c3ad41925353bb744e5d2f Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 2 May 2024 18:33:22 -0700 Subject: negf: Fix -Wformat-truncation warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit math.c: In function ‘negf’: math.c:474:36: warning: ‘snprintf’ output may be truncated before the last format character [-Wformat-truncation=] 474 | snprintf(tmp, sizeof(tmp), "-%s", dispstr); | ^ math.c:474:5: note: ‘snprintf’ output between 2 and 33 bytes into a destination of size 32 474 | snprintf(tmp, sizeof(tmp), "-%s", dispstr); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Alan Coopersmith Part-of: --- math.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/math.c b/math.c index c51517c..2ea5400 100644 --- a/math.c +++ b/math.c @@ -470,7 +470,7 @@ negf(void) if (dispstr[0]=='-') /* already neg-ed */ strcpy(dispstr,dispstr+1); /* move str left once */ else { /* not neg-ed. add a '-' */ - char tmp[32]; + char tmp[LCD_STR_LEN + 1]; snprintf(tmp, sizeof(tmp), "-%s", dispstr); strlcpy(dispstr, tmp, sizeof(dispstr)); } -- cgit v1.2.3