From nobody Tue Oct 28 20:59:22 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513624644366795.302104548533; Mon, 18 Dec 2017 11:17:24 -0800 (PST) Received: from localhost ([::1]:60548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eR0uW-0001G5-3P for importer@patchew.org; Mon, 18 Dec 2017 14:17:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50043) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eR0qO-0006Js-JU for qemu-devel@nongnu.org; Mon, 18 Dec 2017 14:13:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eR0qE-0004yP-Qu for qemu-devel@nongnu.org; Mon, 18 Dec 2017 14:12:56 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54790) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eR0qE-0004xS-Ha for qemu-devel@nongnu.org; Mon, 18 Dec 2017 14:12:46 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9DCAB5FD45 for ; Mon, 18 Dec 2017 19:12:45 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4726C78401; Mon, 18 Dec 2017 19:12:44 +0000 (UTC) From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Mon, 18 Dec 2017 19:12:18 +0000 Message-Id: <20171218191228.31018-4-berrange@redhat.com> In-Reply-To: <20171218191228.31018-1-berrange@redhat.com> References: <20171218191228.31018-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 18 Dec 2017 19:12:45 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1 03/13] ui: remove redundant indentation in vnc_client_update 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: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , P J P Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Now that previous dead / unreachable code has been removed, we can simplify the indentation in the vnc_client_update method. Signed-off-by: Daniel P. Berrange --- ui/vnc.c | 112 ++++++++++++++++++++++++++++++++---------------------------= ---- 1 file changed, 57 insertions(+), 55 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index 869c75bbcf..a61fcbd20c 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -963,74 +963,76 @@ static int find_and_clear_dirty_height(VncState *vs, =20 static int vnc_update_client(VncState *vs, int has_dirty) { + VncDisplay *vd =3D vs->vd; + VncJob *job; + int y; + int height, width; + int n =3D 0; + if (vs->disconnecting) { vnc_disconnect_finish(vs); return 0; } =20 vs->has_dirty +=3D has_dirty; - if (vs->need_update) { - VncDisplay *vd =3D vs->vd; - VncJob *job; - int y; - int height, width; - int n =3D 0; - - if (vs->output.offset && !vs->audio_cap && !vs->force_update) - /* kernel send buffers are full -> drop frames to throttle */ - return 0; + if (!vs->need_update) { + return 0; + } =20 - if (!vs->has_dirty && !vs->audio_cap && !vs->force_update) - return 0; + if (vs->output.offset && !vs->audio_cap && !vs->force_update) { + /* kernel send buffers are full -> drop frames to throttle */ + return 0; + } =20 - /* - * Send screen updates to the vnc client using the server - * surface and server dirty map. guest surface updates - * happening in parallel don't disturb us, the next pass will - * send them to the client. - */ - job =3D vnc_job_new(vs); - - height =3D pixman_image_get_height(vd->server); - width =3D pixman_image_get_width(vd->server); - - y =3D 0; - for (;;) { - int x, h; - unsigned long x2; - unsigned long offset =3D find_next_bit((unsigned long *) &vs->= dirty, - height * VNC_DIRTY_BPL(vs= ), - y * VNC_DIRTY_BPL(vs)); - if (offset =3D=3D height * VNC_DIRTY_BPL(vs)) { - /* no more dirty bits */ + if (!vs->has_dirty && !vs->audio_cap && !vs->force_update) { + return 0; + } + + /* + * Send screen updates to the vnc client using the server + * surface and server dirty map. guest surface updates + * happening in parallel don't disturb us, the next pass will + * send them to the client. + */ + job =3D vnc_job_new(vs); + + height =3D pixman_image_get_height(vd->server); + width =3D pixman_image_get_width(vd->server); + + y =3D 0; + for (;;) { + int x, h; + unsigned long x2; + unsigned long offset =3D find_next_bit((unsigned long *) &vs->dirt= y, + height * VNC_DIRTY_BPL(vs), + y * VNC_DIRTY_BPL(vs)); + if (offset =3D=3D height * VNC_DIRTY_BPL(vs)) { + /* no more dirty bits */ + break; + } + y =3D offset / VNC_DIRTY_BPL(vs); + x =3D offset % VNC_DIRTY_BPL(vs); + x2 =3D find_next_zero_bit((unsigned long *) &vs->dirty[y], + VNC_DIRTY_BPL(vs), x); + bitmap_clear(vs->dirty[y], x, x2 - x); + h =3D find_and_clear_dirty_height(vs, y, x, x2, height); + x2 =3D MIN(x2, width / VNC_DIRTY_PIXELS_PER_BIT); + if (x2 > x) { + n +=3D vnc_job_add_rect(job, x * VNC_DIRTY_PIXELS_PER_BIT, y, + (x2 - x) * VNC_DIRTY_PIXELS_PER_BIT, h); + } + if (!x && x2 =3D=3D width / VNC_DIRTY_PIXELS_PER_BIT) { + y +=3D h; + if (y =3D=3D height) { break; } - y =3D offset / VNC_DIRTY_BPL(vs); - x =3D offset % VNC_DIRTY_BPL(vs); - x2 =3D find_next_zero_bit((unsigned long *) &vs->dirty[y], - VNC_DIRTY_BPL(vs), x); - bitmap_clear(vs->dirty[y], x, x2 - x); - h =3D find_and_clear_dirty_height(vs, y, x, x2, height); - x2 =3D MIN(x2, width / VNC_DIRTY_PIXELS_PER_BIT); - if (x2 > x) { - n +=3D vnc_job_add_rect(job, x * VNC_DIRTY_PIXELS_PER_BIT,= y, - (x2 - x) * VNC_DIRTY_PIXELS_PER_BIT,= h); - } - if (!x && x2 =3D=3D width / VNC_DIRTY_PIXELS_PER_BIT) { - y +=3D h; - if (y =3D=3D height) { - break; - } - } } - - vnc_job_push(job); - vs->force_update =3D 0; - vs->has_dirty =3D 0; - return n; } =20 - return 0; + vnc_job_push(job); + vs->force_update =3D 0; + vs->has_dirty =3D 0; + return n; } =20 /* audio */ --=20 2.14.3