From 2c034462e591e87b2264b94455c0b409b827846d Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Fri, 7 Oct 2016 20:00:27 +0000 Subject: [PATCH] Fixed -Wformat-length warning from experimental gcc-7: sbar.c: In function 'Sbar_DrawInventory': sbar.c:673:18: warning: '%3i' directive writing between 3 and 11 bytes into a region of size 6 [-Wformat-length=] sprintf (num, "%3i", q_min(999,cl.stats[STAT_SHELLS+i])); //johnfitz -- cap displayed value to 999 ^~~ sbar.c:673:17: note: directive argument in the range [-2147483648, 999] sprintf (num, "%3i", q_min(999,cl.stats[STAT_SHELLS+i])); //johnfitz -- cap displayed value to 999 ^~~~~ sbar.c:673:3: note: format output between 4 and 12 bytes into a destination of size 6 sprintf (num, "%3i", q_min(999,cl.stats[STAT_SHELLS+i])); //johnfitz -- cap displayed value to 999 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1346 af15c1b1-3010-417e-b628-4374ebc0bcbd --- Quake/sbar.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Quake/sbar.c b/Quake/sbar.c index 38998e3f..9c68780f 100644 --- a/Quake/sbar.c +++ b/Quake/sbar.c @@ -553,7 +553,7 @@ Sbar_DrawInventory */ void Sbar_DrawInventory (void) { - int i; + int i, val; char num[6]; float time; int flashon; @@ -670,7 +670,9 @@ void Sbar_DrawInventory (void) // ammo counts for (i = 0; i < 4; i++) { - sprintf (num, "%3i", q_min(999,cl.stats[STAT_SHELLS+i])); //johnfitz -- cap displayed value to 999 + val = cl.stats[STAT_SHELLS+i]; + val = (val < 0)? 0 : q_min(999,val);//johnfitz -- cap displayed value to 999 + sprintf (num, "%3i", val); if (num[0] != ' ') Sbar_DrawCharacter ( (6*i+1)*8 + 2, -24, 18 + num[0] - '0'); if (num[1] != ' ')