summaryrefslogtreecommitdiff
path: root/ui/curses.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-08-11 15:23:27 +0100
committerGerd Hoffmann <kraxel@redhat.com>2016-09-13 08:01:39 +0200
commit99a9ef44dca4be93f60c38d83a79eaaf8c56548a (patch)
tree4eb268a541e8609891f32e6365f9cf1046328cad /ui/curses.c
parentbba4e1b591531c087fce4ae501dc1ca299d8fb42 (diff)
downloadqemu-99a9ef44dca4be93f60c38d83a79eaaf8c56548a.tar.gz
ui/curses.c: Clean up nextchr logic
Coverity identifies that at the top of the while(1) loop in curses_refresh() the variable nextchr is always ERR, and so the else case of the first if() is dead code. Remove this dead code, and narrow the scope of the nextchr variable to the place where it's used. (This confused logic has been present since the curses code was added to QEMU in 2008.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1470925407-23850-3-git-send-email-peter.maydell@linaro.org Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui/curses.c')
-rw-r--r--ui/curses.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/ui/curses.c b/ui/curses.c
index f1f886c968..d06f724879 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -181,7 +181,7 @@ static kbd_layout_t *kbd_layout = NULL;
static void curses_refresh(DisplayChangeListener *dcl)
{
- int chr, nextchr, keysym, keycode, keycode_alt;
+ int chr, keysym, keycode, keycode_alt;
curses_winch_check();
@@ -195,15 +195,9 @@ static void curses_refresh(DisplayChangeListener *dcl)
graphic_hw_text_update(NULL, screen);
- nextchr = ERR;
while (1) {
/* while there are any pending key strokes to process */
- if (nextchr == ERR)
- chr = getch();
- else {
- chr = nextchr;
- nextchr = ERR;
- }
+ chr = getch();
if (chr == ERR)
break;
@@ -224,13 +218,12 @@ static void curses_refresh(DisplayChangeListener *dcl)
/* alt key */
if (keycode == 1) {
- nextchr = getch();
+ int nextchr = getch();
if (nextchr != ERR) {
chr = nextchr;
keycode_alt = ALT;
- keycode = curses2keycode[nextchr];
- nextchr = ERR;
+ keycode = curses2keycode[chr];
if (keycode != -1) {
keycode |= ALT;