[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 2/4] ui/curses.c: Clean up nextchr logic
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PULL 2/4] ui/curses.c: Clean up nextchr logic |
Date: |
Tue, 13 Sep 2016 09:06:52 +0200 |
From: Peter Maydell <address@hidden>
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 <address@hidden>
Message-id: address@hidden
Signed-off-by: Gerd Hoffmann <address@hidden>
---
ui/curses.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/ui/curses.c b/ui/curses.c
index f1f886c..d06f724 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;
--
1.8.3.1
- [Qemu-devel] [PULL 0/4] ui: misc small fixes for vnc, spice and curses., Gerd Hoffmann, 2016/09/13
- [Qemu-devel] [PULL 2/4] ui/curses.c: Clean up nextchr logic,
Gerd Hoffmann <=
- [Qemu-devel] [PULL 1/4] ui/curses.c: Ensure we don't read off the end of curses2qemu array, Gerd Hoffmann, 2016/09/13
- [Qemu-devel] [PULL 3/4] qemu-options.hx: correct spice options streaming-video default document value to 'off', Gerd Hoffmann, 2016/09/13
- [Qemu-devel] [PULL 4/4] vnc: fix qemu crash because of SIGSEGV, Gerd Hoffmann, 2016/09/13
- Re: [Qemu-devel] [PULL 0/4] ui: misc small fixes for vnc, spice and curses., Peter Maydell, 2016/09/13