From 6bb5f78bd2bdf10ddbb087171c6f640d425c9d40 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 30 Mar 2014 18:50:35 -0400 Subject: heretic: Eliminate use of sprintf(). Use snprintf() in place of sprintf(). This is part of fixing #371. --- src/heretic/i_sound.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/heretic/i_sound.c') diff --git a/src/heretic/i_sound.c b/src/heretic/i_sound.c index d3f04767..2dc66239 100644 --- a/src/heretic/i_sound.c +++ b/src/heretic/i_sound.c @@ -211,7 +211,8 @@ int I_GetSfxLumpNum(sfxinfo_t * sound) return 0; if (sound->link) sound = sound->link; -// sprintf(namebuf, "d%c%s", snd_prefixen[snd_SfxDevice], sound->name); +// snprintf(namebuf, sizeof(namebuf), "d%c%s", +// snd_prefixen[snd_SfxDevice], sound->name); return W_GetNumForName(sound->name); } @@ -319,14 +320,15 @@ void I_sndArbitrateCards(void) { if (debugmode) { - sprintf(tmp, "cfg p=0x%x, i=%d, d=%d\n", - snd_SBport, snd_SBirq, snd_SBdma); + snprintf(tmp, sizeof(tmp), "cfg p=0x%x, i=%d, d=%d\n", + snd_SBport, snd_SBirq, snd_SBdma); tprintf(tmp, 0); } if (SB_Detect(&snd_SBport, &snd_SBirq, &snd_SBdma, 0)) { - sprintf(tmp, "SB isn't responding at p=0x%x, i=%d, d=%d\n", - snd_SBport, snd_SBirq, snd_SBdma); + snprintf(tmp, sizeof(tmp), + "SB isn't responding at p=0x%x, i=%d, d=%d\n", + snd_SBport, snd_SBirq, snd_SBdma); tprintf(tmp, 0); } else @@ -334,8 +336,8 @@ void I_sndArbitrateCards(void) if (debugmode) { - sprintf(tmp, "SB_Detect returned p=0x%x,i=%d,d=%d\n", - snd_SBport, snd_SBirq, snd_SBdma); + snprintf(tmp, sizeof(tmp), "SB_Detect returned p=0x%x,i=%d,d=%d\n", + snd_SBport, snd_SBirq, snd_SBdma); tprintf(tmp, 0); } } @@ -352,14 +354,14 @@ void I_sndArbitrateCards(void) { if (debugmode) { - sprintf(tmp, "cfg p=0x%x\n", snd_Mport); + snprintf(tmp, sizeof(tmp), "cfg p=0x%x\n", snd_Mport); tprintf(tmp, 0); } if (MPU_Detect(&snd_Mport, &i)) { - sprintf(tmp, "The MPU-401 isn't reponding @ p=0x%x.\n", - snd_Mport); + snprintf(tmp, sizeof(tmp), + "The MPU-401 isn't reponding @ p=0x%x.\n", snd_Mport); tprintf(tmp, 0); } else @@ -397,11 +399,11 @@ void I_StartupSound(void) if (debugmode) { - sprintf(tmp, " Music device #%d & dmxCode=%d", snd_MusicDevice, - dmxCodes[snd_MusicDevice]); + snprintf(tmp, sizeof(tmp), " Music device #%d & dmxCode=%d", + snd_MusicDevice, dmxCodes[snd_MusicDevice]); tprintf(tmp, 0); - sprintf(tmp, " Sfx device #%d & dmxCode=%d\n", snd_SfxDevice, - dmxCodes[snd_SfxDevice]); + snprintf(tmp, sizeof(tmp), " Sfx device #%d & dmxCode=%d\n", + snd_SfxDevice, dmxCodes[snd_SfxDevice]); tprintf(tmp, 0); } @@ -412,7 +414,7 @@ void I_StartupSound(void) if (debugmode) { - sprintf(tmp, " DMX_Init() returned %d", rc); + snprintf(tmp, sizeof(tmp), " DMX_Init() returned %d", rc); tprintf(tmp, 0); } -- cgit v1.2.3