From 034e792662a1c0c6ab52190e457b1f017bec01c6 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 1 Nov 2020 13:55:59 -0800 Subject: [PATCH] dmx: example code should set a good example Resolves warning from Oracle Parfait static analyser: Error: Unchecked result Unchecked result [unchecked-result-call-X]: Unchecked return value from call to XOpenDisplay. Value display must be ch ecked to ensure this function was successful. at line 73 of hw/dmx/examples/xbell.c in function 'main'. Signed-off-by: Alan Coopersmith --- hw/dmx/examples/xbell.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/dmx/examples/xbell.c b/hw/dmx/examples/xbell.c index 543db24bf..e64b9c90c 100644 --- a/hw/dmx/examples/xbell.c +++ b/hw/dmx/examples/xbell.c @@ -70,7 +70,7 @@ pks(XKeyboardState * ks) int main(int argc, char **argv) { - Display *display = XOpenDisplay(NULL); + Display *display; XKeyboardControl kc; XKeyboardState ks; unsigned long vm; @@ -86,6 +86,13 @@ main(int argc, char **argv) kc.bell_pitch = atoi(argv[3]); kc.bell_duration = atoi(argv[4]); + display = XOpenDisplay(NULL); + if (display == NULL) { + fprintf (stderr, "%s: unable to open display \"%s\".\n", + argv[0], XDisplayName (NULL)); + exit(1); + } + printf("Setting:\n"); pkc(&kc, vm); XChangeKeyboardControl(display, vm, &kc);