summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2024-05-02 18:33:22 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2024-05-02 18:33:22 -0700
commit6f3abc4e478b9d91c6c3ad41925353bb744e5d2f (patch)
tree5613be75eebbe0b1262474add9b7133e8838f70f
parent62bfb33c545c6afd0cd5ee050168ce1fd461a956 (diff)
negf: Fix -Wformat-truncation warningHEADmaster
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 <alan.coopersmith@oracle.com> Part-of: <https://gitlab.freedesktop.org/xorg/app/xcalc/-/merge_requests/13>
-rw-r--r--math.c2
1 files changed, 1 insertions, 1 deletions
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));
}