From patchwork Tue Sep 13 07:06:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 76038 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1219855qgf; Tue, 13 Sep 2016 00:09:06 -0700 (PDT) X-Received: by 10.55.67.139 with SMTP id q133mr22927205qka.71.1473750546046; Tue, 13 Sep 2016 00:09:06 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [208.118.235.17]) by mx.google.com with ESMTPS id v188si8714939qkh.245.2016.09.13.00.09.05 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 13 Sep 2016 00:09:06 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:46897 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjhq5-0003EB-KP for patch@linaro.org; Tue, 13 Sep 2016 03:09:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjhoA-0002Kd-Em for qemu-devel@nongnu.org; Tue, 13 Sep 2016 03:07:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjho4-0003rS-I6 for qemu-devel@nongnu.org; Tue, 13 Sep 2016 03:07:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55000) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjho4-0003rA-Cb for qemu-devel@nongnu.org; Tue, 13 Sep 2016 03:07:00 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 12121C04B320; Tue, 13 Sep 2016 07:07:00 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-48.ams2.redhat.com [10.36.116.48]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8D76xIO025256; Tue, 13 Sep 2016 03:06:59 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 50E57808A5; Tue, 13 Sep 2016 09:06:58 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 13 Sep 2016 09:06:52 +0200 Message-Id: <1473750414-16525-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1473750414-16525-1-git-send-email-kraxel@redhat.com> References: <1473750414-16525-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 13 Sep 2016 07:07:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/4] 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: Peter Maydell , Gerd Hoffmann Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell 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 Message-id: 1470925407-23850-3-git-send-email-peter.maydell@linaro.org Signed-off-by: Gerd Hoffmann --- ui/curses.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) -- 1.8.3.1 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;