From patchwork Thu Aug 11 14:23:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9275355 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D04C56022E for ; Thu, 11 Aug 2016 14:27:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1FFB286AE for ; Thu, 11 Aug 2016 14:27:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6C65286C0; Thu, 11 Aug 2016 14:27:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 91152286AE for ; Thu, 11 Aug 2016 14:27:28 +0000 (UTC) Received: from localhost ([::1]:48858 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXqxD-0003yb-99 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 11 Aug 2016 10:27:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXqtW-0001XC-5N for qemu-devel@nongnu.org; Thu, 11 Aug 2016 10:23:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bXqtV-0007zi-8S for qemu-devel@nongnu.org; Thu, 11 Aug 2016 10:23:38 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:58595) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bXqtV-0007wH-16 for qemu-devel@nongnu.org; Thu, 11 Aug 2016 10:23:37 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1bXqtM-0002fT-V8; Thu, 11 Aug 2016 15:23:28 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 11 Aug 2016 15:23:27 +0100 Message-Id: <1470925407-23850-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470925407-23850-1-git-send-email-peter.maydell@linaro.org> References: <1470925407-23850-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH 2/2] ui/curses.c: Clean up nextchr logic X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , patches@linaro.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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;