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+ssh://svn.code.sf.net/p/quakespasm/code/trunk@1346 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2016-10-07 20:00:27 +00:00
parent 06d52b08aa
commit dd4c570a94

View file

@ -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] != ' ')