aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/kbdcontrol
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2019-01-23 10:05:27 +0000
committerStefan Eßer <se@FreeBSD.org>2019-01-23 10:05:27 +0000
commit96329ce7e2edd7c2688428123ffdb5a42092d5b2 (patch)
tree629336b38d60ed8a6a5189515bf13c52670e20e1 /usr.sbin/kbdcontrol
parentd65e72a8188d69cd41f595ea570a8b1536ed3203 (diff)
downloadsrc-96329ce7e2edd7c2688428123ffdb5a42092d5b2.tar.gz
src-96329ce7e2edd7c2688428123ffdb5a42092d5b2.zip
Silence Clang Scan warning about use of unitialized variable.
While the warning is a false positive, it is possible to clarify the code by always initializing the variable. This does also allow to make the sending of the "beep" control sequence depend on the validity of its parameters. I have left the redundant assignment of 0 to the now initialized variables in place since this makes the code simpler to understand and does not add any run-time overhead (the compiler completely removes the "else if" test and the assignments). There was an embedded literal escape character in a string, which messes up diplaying the source code on a terminal that interprets ANSI sequences. The literal escape has been replaced by \e (non-standard, but supported by all relevant compilers, and already used in other source files in base). MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=343339
Diffstat (limited to 'usr.sbin/kbdcontrol')
-rw-r--r--usr.sbin/kbdcontrol/kbdcontrol.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.sbin/kbdcontrol/kbdcontrol.c b/usr.sbin/kbdcontrol/kbdcontrol.c
index 73ee449755b6..3144e44d72b3 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 @@ badopt:
}
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