From 52964228907add94a5349c9a225bb83716450c9c Mon Sep 17 00:00:00 2001 From: se Date: Thu, 14 Feb 2019 15:33:04 +0000 Subject: [PATCH] MFC r343339: Silence Clang Scan warning about use of unitialized variable. The logic is changed to depend on actual "beep" parameters instead of on a flag that may be set for invalid parameters. An embedded literal escape character has been replaced by "\e", since it could confuse terminals when displaying the affected line. --- usr.sbin/kbdcontrol/kbdcontrol.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/usr.sbin/kbdcontrol/kbdcontrol.c b/usr.sbin/kbdcontrol/kbdcontrol.c index 73ee449755b..3144e44d72b 100644 --- a/usr.sbin/kbdcontrol/kbdcontrol.c +++ b/usr.sbin/kbdcontrol/kbdcontrol.c @@ -961,6 +961,8 @@ set_bell_values(char *opt) int bell, duration, pitch; bell = 0; + duration = 0; + pitch = 0; if (!strncmp(opt, "quiet.", 6)) { bell = CONS_QUIET_BELL; opt += 6; @@ -991,8 +993,8 @@ set_bell_values(char *opt) } ioctl(0, CONS_BELLTYPE, &bell); - if (!(bell & CONS_VISUAL_BELL)) - fprintf(stderr, "[=%d;%dB", pitch, duration); + if (duration > 0 && pitch > 0) + fprintf(stderr, "\e[=%d;%dB", pitch, duration); } static void -- 2.45.0