Fix possible divide by zero.

Spotted by:	many

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Aleksandr Rybalko 2014-05-07 13:53:38 +00:00
parent 3c0b107a16
commit 4efec7a83d

View File

@ -677,6 +677,22 @@ vtterm_bell(struct terminal *tm)
sysbeep(1193182 / VT_BELLPITCH, VT_BELLDURATION);
}
static void
vtterm_beep(struct terminal *tm, u_int param)
{
u_int freq, period;
if ((param == 0) || ((param & 0xffff) == 0)) {
vtterm_bell(tm);
return;
}
period = ((param >> 16) & 0xffff) * hz / 1000;
freq = 1193182 / (param & 0xffff);
sysbeep(freq, period);
}
static void
vtterm_cursor(struct terminal *tm, const term_pos_t *p)
{
@ -1732,17 +1748,9 @@ vtterm_ioctl(struct terminal *tm, u_long cmd, caddr_t data,
td->td_frame->tf_rflags &= ~PSL_IOPL;
#endif
return (0);
case KDMKTONE: { /* sound the bell */
int freq, period;
freq = 1193182 / ((*(int*)data) & 0xffff);
period = (((*(int*)data)>>16) & 0xffff) * hz / 1000;
if(*(int*)data)
sysbeep(freq, period);
else
vtterm_bell(tm);
case KDMKTONE: /* sound the bell */
vtterm_beep(tm, *(u_int *)data);
return (0);
}
case KIOCSOUND: /* make tone (*data) hz */
/* TODO */
return (0);