From owner-svn-src-head@FreeBSD.ORG Wed May 7 13:53:39 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 392E03CA; Wed, 7 May 2014 13:53:39 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 26D04B74; Wed, 7 May 2014 13:53:39 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s47DrdDq094064; Wed, 7 May 2014 13:53:39 GMT (envelope-from ray@svn.freebsd.org) Received: (from ray@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s47DrdBI094063; Wed, 7 May 2014 13:53:39 GMT (envelope-from ray@svn.freebsd.org) Message-Id: <201405071353.s47DrdBI094063@svn.freebsd.org> From: Aleksandr Rybalko Date: Wed, 7 May 2014 13:53:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r265546 - head/sys/dev/vt X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 May 2014 13:53:39 -0000 Author: ray Date: Wed May 7 13:53:38 2014 New Revision: 265546 URL: http://svnweb.freebsd.org/changeset/base/265546 Log: Fix possible divide by zero. Spotted by: many Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/vt/vt_core.c Modified: head/sys/dev/vt/vt_core.c ============================================================================== --- head/sys/dev/vt/vt_core.c Wed May 7 12:48:18 2014 (r265545) +++ head/sys/dev/vt/vt_core.c Wed May 7 13:53:38 2014 (r265546) @@ -678,6 +678,22 @@ vtterm_bell(struct terminal *tm) } 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) { struct vt_window *vw = tm->tm_softc; @@ -1732,17 +1748,9 @@ skip_thunk: 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);