Check for 0 before dividing by it. Patch from Paul Traina, modified

slightly by me.
This commit is contained in:
David Greenman 1995-05-05 06:15:11 +00:00
parent c8911fa27e
commit 9714de6a38
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=8288
2 changed files with 20 additions and 4 deletions

View File

@ -4,7 +4,7 @@
* v1.4 by Eric S. Raymond (esr@snark.thyrsus.com) Aug 1993
* modified for FreeBSD by Andrew A. Chernov <ache@astral.msk.su>
*
* $Id: spkr.c,v 1.11 1995/02/03 10:19:38 ache Exp $
* $Id: spkr.c,v 1.12 1995/03/16 18:12:05 bde Exp $
*/
#include "speaker.h"
@ -66,9 +66,14 @@ static void tone(thz, ticks)
/* emit tone of frequency thz for given number of ticks */
unsigned int thz, ticks;
{
unsigned int divisor = TIMER_CLK / thz;
unsigned int divisor;
int sps;
if (thz <= 0)
return;
divisor = TIMER_CLK / thz;
#ifdef DEBUG
(void) printf("tone: thz=%d ticks=%d\n", thz, ticks);
#endif /* DEBUG */
@ -201,6 +206,9 @@ int pitch, value, sustain;
sdenom *= DENOM_MULT;
}
if (value == 0 || sdenom == 0)
return;
if (pitch == -1)
rest(whole * snum / (value * sdenom));
else

View File

@ -4,7 +4,7 @@
* v1.4 by Eric S. Raymond (esr@snark.thyrsus.com) Aug 1993
* modified for FreeBSD by Andrew A. Chernov <ache@astral.msk.su>
*
* $Id: spkr.c,v 1.11 1995/02/03 10:19:38 ache Exp $
* $Id: spkr.c,v 1.12 1995/03/16 18:12:05 bde Exp $
*/
#include "speaker.h"
@ -66,9 +66,14 @@ static void tone(thz, ticks)
/* emit tone of frequency thz for given number of ticks */
unsigned int thz, ticks;
{
unsigned int divisor = TIMER_CLK / thz;
unsigned int divisor;
int sps;
if (thz <= 0)
return;
divisor = TIMER_CLK / thz;
#ifdef DEBUG
(void) printf("tone: thz=%d ticks=%d\n", thz, ticks);
#endif /* DEBUG */
@ -201,6 +206,9 @@ int pitch, value, sustain;
sdenom *= DENOM_MULT;
}
if (value == 0 || sdenom == 0)
return;
if (pitch == -1)
rest(whole * snum / (value * sdenom));
else