From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550626001471728.6967521610953; Tue, 19 Feb 2019 17:26:41 -0800 (PST) Received: from localhost ([127.0.0.1]:57659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGei-0000yU-CZ for importer@patchew.org; Tue, 19 Feb 2019 20:26:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGR3-00059h-Iv for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGJ0-0001j3-VI for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:04:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40252) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGJ0-0001O3-G1; Tue, 19 Feb 2019 20:04:10 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4032080472; Wed, 20 Feb 2019 01:03:12 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 565F91001DE2; Wed, 20 Feb 2019 01:02:55 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:08 +0100 Message-Id: <20190220010232.18731-2-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 20 Feb 2019 01:03:12 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 01/25] chardev: Simplify IOWatchPoll::fd_can_read as a GSourceFunc 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" IOWatchPoll::fd_can_read() really is a GSourceFunc type, it simply returns a boolean value. Update the backends to return a boolean, whether there is data to read from the source or not. Suggested-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/char-fd.c | 4 ++-- chardev/char-io.c | 6 +++--- chardev/char-pty.c | 4 ++-- chardev/char-socket.c | 6 +++--- chardev/char-udp.c | 4 ++-- include/chardev/char-io.h | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/chardev/char-fd.c b/chardev/char-fd.c index 2c9b2ce567..2421d8e216 100644 --- a/chardev/char-fd.c +++ b/chardev/char-fd.c @@ -69,13 +69,13 @@ static gboolean fd_chr_read(QIOChannel *chan, GIOCondit= ion cond, void *opaque) return TRUE; } =20 -static int fd_chr_read_poll(void *opaque) +static gboolean fd_chr_read_poll(void *opaque) { Chardev *chr =3D CHARDEV(opaque); FDChardev *s =3D FD_CHARDEV(opaque); =20 s->max_size =3D qemu_chr_be_can_write(chr); - return s->max_size; + return s->max_size > 0; } =20 static GSource *fd_chr_add_watch(Chardev *chr, GIOCondition cond) diff --git a/chardev/char-io.c b/chardev/char-io.c index 8ced184160..2c1c69098e 100644 --- a/chardev/char-io.c +++ b/chardev/char-io.c @@ -30,7 +30,7 @@ typedef struct IOWatchPoll { QIOChannel *ioc; GSource *src; =20 - IOCanReadHandler *fd_can_read; + GSourceFunc fd_can_read; GSourceFunc fd_read; void *opaque; } IOWatchPoll; @@ -44,7 +44,7 @@ static gboolean io_watch_poll_prepare(GSource *source, gint *timeout) { IOWatchPoll *iwp =3D io_watch_poll_from_source(source); - bool now_active =3D iwp->fd_can_read(iwp->opaque) > 0; + bool now_active =3D iwp->fd_can_read(iwp->opaque); bool was_active =3D iwp->src !=3D NULL; if (was_active =3D=3D now_active) { return FALSE; @@ -76,7 +76,7 @@ static GSourceFuncs io_watch_poll_funcs =3D { =20 GSource *io_add_watch_poll(Chardev *chr, QIOChannel *ioc, - IOCanReadHandler *fd_can_read, + GSourceFunc fd_can_read, QIOChannelFunc fd_read, gpointer user_data, GMainContext *context) diff --git a/chardev/char-pty.c b/chardev/char-pty.c index b034332edd..7777f6ddef 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -119,13 +119,13 @@ static GSource *pty_chr_add_watch(Chardev *chr, GIOCo= ndition cond) return qio_channel_create_watch(s->ioc, cond); } =20 -static int pty_chr_read_poll(void *opaque) +static gboolean pty_chr_read_poll(void *opaque) { Chardev *chr =3D CHARDEV(opaque); PtyChardev *s =3D PTY_CHARDEV(opaque); =20 s->read_bytes =3D qemu_chr_be_can_write(chr); - return s->read_bytes; + return s->read_bytes > 0; } =20 static gboolean pty_chr_read(QIOChannel *chan, GIOCondition cond, void *op= aque) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 4fcdd8aedd..262a59b64f 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -147,7 +147,7 @@ static void tcp_chr_accept(QIONetListener *listener, QIOChannelSocket *cioc, void *opaque); =20 -static int tcp_chr_read_poll(void *opaque); +static gboolean tcp_chr_read_poll(void *opaque); static void tcp_chr_disconnect(Chardev *chr); =20 /* Called with chr_write_lock held. */ @@ -184,7 +184,7 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *b= uf, int len) } } =20 -static int tcp_chr_read_poll(void *opaque) +static gboolean tcp_chr_read_poll(void *opaque) { Chardev *chr =3D CHARDEV(opaque); SocketChardev *s =3D SOCKET_CHARDEV(opaque); @@ -192,7 +192,7 @@ static int tcp_chr_read_poll(void *opaque) return 0; } s->max_size =3D qemu_chr_be_can_write(chr); - return s->max_size; + return s->max_size > 0; } =20 static void tcp_chr_process_IAC_bytes(Chardev *chr, diff --git a/chardev/char-udp.c b/chardev/char-udp.c index 097a2f0f42..b6e399e983 100644 --- a/chardev/char-udp.c +++ b/chardev/char-udp.c @@ -65,7 +65,7 @@ static void udp_chr_flush_buffer(UdpChardev *s) } } =20 -static int udp_chr_read_poll(void *opaque) +static gboolean udp_chr_read_poll(void *opaque) { Chardev *chr =3D CHARDEV(opaque); UdpChardev *s =3D UDP_CHARDEV(opaque); @@ -77,7 +77,7 @@ static int udp_chr_read_poll(void *opaque) */ udp_chr_flush_buffer(s); =20 - return s->max_size; + return s->max_size > 0; } =20 static gboolean udp_chr_read(QIOChannel *chan, GIOCondition cond, void *op= aque) diff --git a/include/chardev/char-io.h b/include/chardev/char-io.h index 9638da5100..a173874538 100644 --- a/include/chardev/char-io.h +++ b/include/chardev/char-io.h @@ -31,7 +31,7 @@ /* Can only be used for read */ GSource *io_add_watch_poll(Chardev *chr, QIOChannel *ioc, - IOCanReadHandler *fd_can_read, + GSourceFunc fd_can_read, QIOChannelFunc fd_read, gpointer user_data, GMainContext *context); --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625989745914.4045684879545; Tue, 19 Feb 2019 17:26:29 -0800 (PST) Received: from localhost ([127.0.0.1]:57653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGeT-0000j2-8Z for importer@patchew.org; Tue, 19 Feb 2019 20:26:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41530) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQw-0006Bq-DG for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGJ3-0001nO-Ss for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:04:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52550) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGJ3-0001SH-Hm; Tue, 19 Feb 2019 20:04:13 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8302D81DFE; Wed, 20 Feb 2019 01:03:23 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C7F281001E7E; Wed, 20 Feb 2019 01:03:12 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:09 +0100 Message-Id: <20190220010232.18731-3-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 20 Feb 2019 01:03:23 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 02/25] chardev: Assert IOCanReadHandler can not be negative 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The backend should not return a negative length to read. We will later change the prototype of IOCanReadHandler to return an unsigned length. Meanwhile make sure the return length is positive. Suggested-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- chardev/char.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/chardev/char.c b/chardev/char.c index f6d61fa5f8..71ecd32b25 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -159,12 +159,15 @@ int qemu_chr_write(Chardev *s, const uint8_t *buf, in= t len, bool write_all) int qemu_chr_be_can_write(Chardev *s) { CharBackend *be =3D s->be; + int receivable_bytes; =20 if (!be || !be->chr_can_read) { return 0; } =20 - return be->chr_can_read(be->opaque); + receivable_bytes =3D be->chr_can_read(be->opaque); + assert(receivable_bytes >=3D 0); + return receivable_bytes; } =20 void qemu_chr_be_write_impl(Chardev *s, uint8_t *buf, int len) --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625837680887.6614151913598; Tue, 19 Feb 2019 17:23:57 -0800 (PST) Received: from localhost ([127.0.0.1]:57583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGc6-0006lW-JW for importer@patchew.org; Tue, 19 Feb 2019 20:23:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQp-00052u-1P for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGJ3-0001nT-Uw for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:04:19 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44062) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGJ3-0001aT-HK; Tue, 19 Feb 2019 20:04:13 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 405BA81F19; Wed, 20 Feb 2019 01:03:46 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4679C1001E7E; Wed, 20 Feb 2019 01:03:23 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:10 +0100 Message-Id: <20190220010232.18731-4-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 20 Feb 2019 01:03:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 03/25] chardev/wctablet: Use unsigned type to hold unsigned value 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" TabletChardev::query is an array of uint8_t. Use the same type to hold it (this also silent a -Wsign-conversion warning in the trace function). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gerd Hoffmann Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/trace-events | 2 +- chardev/wctablet.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/chardev/trace-events b/chardev/trace-events index d0e5f3bbc1..562bfe70e9 100644 --- a/chardev/trace-events +++ b/chardev/trace-events @@ -5,7 +5,7 @@ wct_init(void) "" wct_cmd_re(void) "" wct_cmd_st(void) "" wct_cmd_sp(void) "" -wct_cmd_ts(int input) "0x%02x" +wct_cmd_ts(uint8_t input) "0x%02x" wct_cmd_other(const char *cmd) "%s" wct_speed(int speed) "%d" =20 diff --git a/chardev/wctablet.c b/chardev/wctablet.c index 35dbd29a33..cf7a08a363 100644 --- a/chardev/wctablet.c +++ b/chardev/wctablet.c @@ -207,7 +207,8 @@ static int wctablet_chr_write(struct Chardev *chr, const uint8_t *buf, int len) { TabletChardev *tablet =3D WCTABLET_CHARDEV(chr); - unsigned int i, clen; + size_t i; + unsigned int clen; char *pos; =20 if (tablet->line_speed !=3D 9600) { @@ -269,7 +270,7 @@ static int wctablet_chr_write(struct Chardev *chr, =20 } else if (strncmp((char *)tablet->query, "TS", 2) =3D=3D 0 && clen =3D=3D 3) { - unsigned int input =3D tablet->query[2]; + uint8_t input =3D tablet->query[2]; uint8_t codes[7] =3D { 0xa3, ((input & 0x80) =3D=3D 0) ? 0x7e : 0x7f, --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550626075399882.3914090909186; Tue, 19 Feb 2019 17:27:55 -0800 (PST) Received: from localhost ([127.0.0.1]:57672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGfu-00021h-91 for importer@patchew.org; Tue, 19 Feb 2019 20:27:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGR7-0005xU-MD for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGIz-0001iT-VB for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:04:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52758) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGIz-0001h5-MC; Tue, 19 Feb 2019 20:04:09 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B0E8D81DF9; Wed, 20 Feb 2019 01:04:05 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 05EA71001E7E; Wed, 20 Feb 2019 01:03:46 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:11 +0100 Message-Id: <20190220010232.18731-5-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 20 Feb 2019 01:04:05 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 04/25] chardev: Let qemu_chr_be_can_write() return a size_t types 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" In the previous commit we added an assert to be sure than qemu_chr_be_can_write() will never return a negative value. We can now change its prototype to return a size_t. Adapt the backends accordingly. Suggested-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/baum.c | 6 +++--- chardev/char-fd.c | 2 +- chardev/char-pty.c | 4 ++-- chardev/char-socket.c | 7 ++++--- chardev/char-udp.c | 4 ++-- chardev/char-win.c | 2 +- chardev/char.c | 2 +- chardev/msmouse.c | 4 ++-- chardev/spice.c | 2 +- chardev/wctablet.c | 4 ++-- hw/bt/hci-csr.c | 2 +- include/chardev/char-fd.h | 2 +- include/chardev/char.h | 2 +- ui/console.c | 6 +++--- 14 files changed, 25 insertions(+), 24 deletions(-) diff --git a/chardev/baum.c b/chardev/baum.c index 78b0c87625..1d69d62158 100644 --- a/chardev/baum.c +++ b/chardev/baum.c @@ -265,7 +265,7 @@ static int baum_deferred_init(BaumChardev *baum) static void baum_chr_accept_input(struct Chardev *chr) { BaumChardev *baum =3D BAUM_CHARDEV(chr); - int room, first; + size_t room, first; =20 if (!baum->out_buf_used) return; @@ -292,7 +292,7 @@ static void baum_write_packet(BaumChardev *baum, const = uint8_t *buf, int len) { Chardev *chr =3D CHARDEV(baum); uint8_t io_buf[1 + 2 * len], *cur =3D io_buf; - int room; + size_t room; *cur++ =3D ESC; while (len--) if ((*cur++ =3D *buf++) =3D=3D ESC) @@ -303,7 +303,7 @@ static void baum_write_packet(BaumChardev *baum, const = uint8_t *buf, int len) /* Fits */ qemu_chr_be_write(chr, io_buf, len); } else { - int first; + size_t first; uint8_t out; /* Can't fit all, send what can be, and store the rest. */ qemu_chr_be_write(chr, io_buf, room); diff --git a/chardev/char-fd.c b/chardev/char-fd.c index 2421d8e216..0fe2822869 100644 --- a/chardev/char-fd.c +++ b/chardev/char-fd.c @@ -43,7 +43,7 @@ static gboolean fd_chr_read(QIOChannel *chan, GIOConditio= n cond, void *opaque) { Chardev *chr =3D CHARDEV(opaque); FDChardev *s =3D FD_CHARDEV(opaque); - int len; + size_t len; uint8_t buf[CHR_READ_BUF_LEN]; ssize_t ret; =20 diff --git a/chardev/char-pty.c b/chardev/char-pty.c index 7777f6ddef..eae25f043b 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -34,7 +34,7 @@ typedef struct { Chardev parent; QIOChannel *ioc; - int read_bytes; + size_t read_bytes; =20 int connected; GSource *timer_src; @@ -132,7 +132,7 @@ static gboolean pty_chr_read(QIOChannel *chan, GIOCondi= tion cond, void *opaque) { Chardev *chr =3D CHARDEV(opaque); PtyChardev *s =3D PTY_CHARDEV(opaque); - gsize len; + size_t len; uint8_t buf[CHR_READ_BUF_LEN]; ssize_t ret; =20 diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 262a59b64f..4010c343e0 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -60,7 +60,7 @@ typedef struct { GSource *hup_source; QCryptoTLSCreds *tls_creds; TCPChardevState state; - int max_size; + size_t max_size; int do_telnetopt; int do_nodelay; int *read_msgfds; @@ -493,10 +493,11 @@ static gboolean tcp_chr_read(QIOChannel *chan, GIOCon= dition cond, void *opaque) Chardev *chr =3D CHARDEV(opaque); SocketChardev *s =3D SOCKET_CHARDEV(opaque); uint8_t buf[CHR_READ_BUF_LEN]; - int len, size; + size_t len; + int size; =20 if ((s->state !=3D TCP_CHARDEV_STATE_CONNECTED) || - s->max_size <=3D 0) { + s->max_size =3D=3D 0) { return TRUE; } len =3D sizeof(buf); diff --git a/chardev/char-udp.c b/chardev/char-udp.c index b6e399e983..d4f40626e4 100644 --- a/chardev/char-udp.c +++ b/chardev/char-udp.c @@ -39,7 +39,7 @@ typedef struct { uint8_t buf[CHR_READ_BUF_LEN]; int bufcnt; int bufptr; - int max_size; + size_t max_size; } UdpChardev; =20 #define UDP_CHARDEV(obj) OBJECT_CHECK(UdpChardev, (obj), TYPE_CHARDEV_UDP) @@ -58,7 +58,7 @@ static void udp_chr_flush_buffer(UdpChardev *s) Chardev *chr =3D CHARDEV(s); =20 while (s->max_size > 0 && s->bufptr < s->bufcnt) { - int n =3D MIN(s->max_size, s->bufcnt - s->bufptr); + size_t n =3D MIN(s->max_size, s->bufcnt - s->bufptr); qemu_chr_be_write(chr, &s->buf[s->bufptr], n); s->bufptr +=3D n; s->max_size =3D qemu_chr_be_can_write(chr); diff --git a/chardev/char-win.c b/chardev/char-win.c index 05518e0958..30361e8852 100644 --- a/chardev/char-win.c +++ b/chardev/char-win.c @@ -29,7 +29,7 @@ static void win_chr_read(Chardev *chr, DWORD len) { WinChardev *s =3D WIN_CHARDEV(chr); - int max_size =3D qemu_chr_be_can_write(chr); + size_t max_size =3D qemu_chr_be_can_write(chr); int ret, err; uint8_t buf[CHR_READ_BUF_LEN]; DWORD size; diff --git a/chardev/char.c b/chardev/char.c index 71ecd32b25..3149cd3ba9 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -156,7 +156,7 @@ int qemu_chr_write(Chardev *s, const uint8_t *buf, int = len, bool write_all) return offset; } =20 -int qemu_chr_be_can_write(Chardev *s) +size_t qemu_chr_be_can_write(Chardev *s) { CharBackend *be =3D s->be; int receivable_bytes; diff --git a/chardev/msmouse.c b/chardev/msmouse.c index 0ffd137ce8..cdb6f86037 100644 --- a/chardev/msmouse.c +++ b/chardev/msmouse.c @@ -38,7 +38,7 @@ typedef struct { bool btns[INPUT_BUTTON__MAX]; bool btnc[INPUT_BUTTON__MAX]; uint8_t outbuf[32]; - int outlen; + size_t outlen; } MouseChardev; =20 #define TYPE_CHARDEV_MSMOUSE "chardev-msmouse" @@ -48,7 +48,7 @@ typedef struct { static void msmouse_chr_accept_input(Chardev *chr) { MouseChardev *mouse =3D MOUSE_CHARDEV(chr); - int len; + size_t len; =20 len =3D qemu_chr_be_can_write(chr); if (len > mouse->outlen) { diff --git a/chardev/spice.c b/chardev/spice.c index 173c257949..ad180a8a13 100644 --- a/chardev/spice.c +++ b/chardev/spice.c @@ -43,7 +43,7 @@ static int vmc_write(SpiceCharDeviceInstance *sin, const = uint8_t *buf, int len) uint8_t* p =3D (uint8_t*)buf; =20 while (len > 0) { - int can_write =3D qemu_chr_be_can_write(chr); + size_t can_write =3D qemu_chr_be_can_write(chr); last_out =3D MIN(len, can_write); if (last_out <=3D 0) { break; diff --git a/chardev/wctablet.c b/chardev/wctablet.c index cf7a08a363..daae570bc7 100644 --- a/chardev/wctablet.c +++ b/chardev/wctablet.c @@ -74,7 +74,7 @@ typedef struct { =20 /* Command to be sent to serial port */ uint8_t outbuf[WC_OUTPUT_BUF_MAX_LEN]; - int outlen; + size_t outlen; =20 int line_speed; bool send_events; @@ -186,7 +186,7 @@ static QemuInputHandler wctablet_handler =3D { static void wctablet_chr_accept_input(Chardev *chr) { TabletChardev *tablet =3D WCTABLET_CHARDEV(chr); - int len, canWrite; + size_t len, canWrite; =20 canWrite =3D qemu_chr_be_can_write(chr); len =3D canWrite; diff --git a/hw/bt/hci-csr.c b/hw/bt/hci-csr.c index fa6660a113..e837a3fa1f 100644 --- a/hw/bt/hci-csr.c +++ b/hw/bt/hci-csr.c @@ -38,7 +38,7 @@ struct csrhci_s { #define FIFO_LEN 4096 int out_start; int out_len; - int out_size; + size_t out_size; uint8_t outfifo[FIFO_LEN * 2]; uint8_t inpkt[FIFO_LEN]; enum { diff --git a/include/chardev/char-fd.h b/include/chardev/char-fd.h index e7c2b176f9..36c6b89cee 100644 --- a/include/chardev/char-fd.h +++ b/include/chardev/char-fd.h @@ -31,7 +31,7 @@ typedef struct FDChardev { Chardev parent; =20 QIOChannel *ioc_in, *ioc_out; - int max_size; + size_t max_size; } FDChardev; =20 #define TYPE_CHARDEV_FD "chardev-fd" diff --git a/include/chardev/char.h b/include/chardev/char.h index c0b57f7685..0341dd1ba2 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -173,7 +173,7 @@ Chardev *qemu_chr_new_noreplay(const char *label, const= char *filename, * * Returns: the number of bytes the front end can receive via @qemu_chr_be= _write */ -int qemu_chr_be_can_write(Chardev *s); +size_t qemu_chr_be_can_write(Chardev *s); =20 /** * qemu_chr_be_write: diff --git a/ui/console.c b/ui/console.c index 6d2282d3e9..42f04e2b37 100644 --- a/ui/console.c +++ b/ui/console.c @@ -61,8 +61,8 @@ enum TTYState { =20 typedef struct QEMUFIFO { uint8_t *buf; - int buf_size; - int count, wptr, rptr; + size_t buf_size, count; + int wptr, rptr; } QEMUFIFO; =20 static int qemu_fifo_write(QEMUFIFO *f, const uint8_t *buf, int len1) @@ -1110,7 +1110,7 @@ static int vc_chr_write(Chardev *chr, const uint8_t *= buf, int len) static void kbd_send_chars(void *opaque) { QemuConsole *s =3D opaque; - int len; + size_t len; uint8_t buf[16]; =20 len =3D qemu_chr_be_can_write(s->chr); --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625872767488.80859442008216; Tue, 19 Feb 2019 17:24:32 -0800 (PST) Received: from localhost ([127.0.0.1]:57589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGcf-0007G5-Nq for importer@patchew.org; Tue, 19 Feb 2019 20:24:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQl-00052t-6R for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGKu-0002cV-Fn for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:06:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40844) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGKq-0001qY-24; Tue, 19 Feb 2019 20:06:07 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C68627A19B; Wed, 20 Feb 2019 01:04:26 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 422121001E7E; Wed, 20 Feb 2019 01:04:05 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:12 +0100 Message-Id: <20190220010232.18731-6-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 20 Feb 2019 01:04:27 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 05/25] gdbstub: Use size_t for strlen() return value 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since strlen() returns an unsigned value, it is pointless to convert it to a signed one. Use size_t to hold its return value. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- gdbstub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdbstub.c b/gdbstub.c index bc774ae992..76eca3bb7e 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -1693,7 +1693,7 @@ static int gdb_handle_packet(GDBState *s, const char = *line_buf) } #else /* !CONFIG_USER_ONLY */ else if (strncmp(p, "Rcmd,", 5) =3D=3D 0) { - int len =3D strlen(p + 5); + size_t len =3D strlen(p + 5); =20 if ((len % 2) !=3D 0) { put_packet(s, "E01"); --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625276497633.7854379346019; Tue, 19 Feb 2019 17:14:36 -0800 (PST) Received: from localhost ([127.0.0.1]:57418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGT3-0007bE-8u for importer@patchew.org; Tue, 19 Feb 2019 20:14:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQh-00052t-Ar for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGMN-0003Rj-OV for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:07:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52394) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGMA-0001uM-T3; Tue, 19 Feb 2019 20:07:30 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 72E8FC04F4AC; Wed, 20 Feb 2019 01:04:46 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B38C1001E7E; Wed, 20 Feb 2019 01:04:27 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:13 +0100 Message-Id: <20190220010232.18731-7-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 20 Feb 2019 01:04:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 06/25] gdbstub: Use size_t to hold GDBState::last_packet_len 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" In put_packet_binary() we have: uint8_t *p; for(;;) { p =3D s->last_packet; *(p++) =3D ... s->last_packet_len =3D p - s->last_packet; put_buffer(s, (uint8_t *)s->last_packet, s->last_packet_len); The 'p' pointer start at s->last_packet, then is only incremented. Since we have "p >=3D s->last_packet", we are sure than "p - s->last_packet >=3D 0", thus "p - s->last_packet" is positive. The few other places where s->last_packet_len is set is with constant positive values. It makes sense to use size_t to hold last_packet_len values. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- gdbstub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdbstub.c b/gdbstub.c index 76eca3bb7e..69340d7cd1 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -323,7 +323,7 @@ typedef struct GDBState { int line_sum; /* running checksum */ int line_csum; /* checksum at the end of the packet */ uint8_t last_packet[MAX_PACKET_LENGTH + 4]; - int last_packet_len; + size_t last_packet_len; int signal; #ifdef CONFIG_USER_ONLY int fd; --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155062566968199.6470550011943; Tue, 19 Feb 2019 17:21:09 -0800 (PST) Received: from localhost ([127.0.0.1]:57539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGZO-0004WA-Iy for importer@patchew.org; Tue, 19 Feb 2019 20:21:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQh-00059h-9z for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGMO-0003S5-M4 for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:07:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53270) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGME-0001xM-Gg; Tue, 19 Feb 2019 20:07:38 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1483181DF3; Wed, 20 Feb 2019 01:04:56 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3865D1001DE2; Wed, 20 Feb 2019 01:04:46 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:14 +0100 Message-Id: <20190220010232.18731-8-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 20 Feb 2019 01:04:56 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 07/25] gdbstub: Let put_buffer() use size_t 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" All callers provide a size_t argument, we can safely use size_t for this function. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- gdbstub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gdbstub.c b/gdbstub.c index 69340d7cd1..860e9bb7c7 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -475,10 +475,10 @@ static int gdb_continue_partial(GDBState *s, char *ne= wstates) return res; } =20 -static void put_buffer(GDBState *s, const uint8_t *buf, int len) +static void put_buffer(GDBState *s, const uint8_t *buf, size_t len) { #ifdef CONFIG_USER_ONLY - int ret; + ssize_t ret; =20 while (len > 0) { ret =3D send(s->fd, buf, len, 0); --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625816527704.5802918944026; Tue, 19 Feb 2019 17:23:36 -0800 (PST) Received: from localhost ([127.0.0.1]:57580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGbi-0006QN-EE for importer@patchew.org; Tue, 19 Feb 2019 20:23:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQl-00059w-2r for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGLa-00039G-2w for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:06:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51840) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGLQ-00022e-Sd; Tue, 19 Feb 2019 20:06:42 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E1C6687638; Wed, 20 Feb 2019 01:05:14 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C94BA1001E87; Wed, 20 Feb 2019 01:04:56 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:15 +0100 Message-Id: <20190220010232.18731-9-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 20 Feb 2019 01:05:15 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 08/25] ui/gtk: Remove pointless cast 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The 'size' value is of type 'guint' which is already unsigned. Remove the useless cast. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gerd Hoffmann --- ui/gtk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/gtk.c b/ui/gtk.c index 949b143e4e..b5879fdece 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1764,7 +1764,7 @@ static gboolean gd_vc_in(VteTerminal *terminal, gchar= *text, guint size, } } =20 - qemu_chr_be_write(vc->vte.chr, (uint8_t *)text, (unsigned int)size); + qemu_chr_be_write(vc->vte.chr, (uint8_t *)text, size); return TRUE; } =20 --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625786030805.5366786474915; Tue, 19 Feb 2019 17:23:06 -0800 (PST) Received: from localhost ([127.0.0.1]:57576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGbH-000636-0n for importer@patchew.org; Tue, 19 Feb 2019 20:23:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQg-0005xU-QS for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGMT-0003T7-4D for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:07:51 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48422) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGMM-00027i-63; Tue, 19 Feb 2019 20:07:40 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D44317266B; Wed, 20 Feb 2019 01:05:26 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AAF561001E7E; Wed, 20 Feb 2019 01:05:15 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:16 +0100 Message-Id: <20190220010232.18731-10-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 20 Feb 2019 01:05:27 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 09/25] vhost-user: Express sizeof with size_t 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" VHOST_USER_HDR_SIZE uses offsetof(), thus is an expression of type size_t. Update the format string accordingly. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- hw/virtio/vhost-user.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 564a31d12c..2eb7143d3d 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -215,11 +215,12 @@ static int vhost_user_read(struct vhost_dev *dev, Vho= stUserMsg *msg) struct vhost_user *u =3D dev->opaque; CharBackend *chr =3D u->user->chr; uint8_t *p =3D (uint8_t *) msg; - int r, size =3D VHOST_USER_HDR_SIZE; + int r; + size_t size =3D VHOST_USER_HDR_SIZE; =20 r =3D qemu_chr_fe_read_all(chr, p, size); if (r !=3D size) { - error_report("Failed to read msg header. Read %d instead of %d." + error_report("Failed to read msg header. Read %d instead of %zu." " Original request %d.", r, size, msg->hdr.request); goto fail; } @@ -235,7 +236,7 @@ static int vhost_user_read(struct vhost_dev *dev, Vhost= UserMsg *msg) /* validate message size is sane */ if (msg->hdr.size > VHOST_USER_PAYLOAD_SIZE) { error_report("Failed to read msg header." - " Size %d exceeds the maximum %zu.", msg->hdr.size, + " Size %u exceeds the maximum %zu.", msg->hdr.size, VHOST_USER_PAYLOAD_SIZE); goto fail; } @@ -246,7 +247,7 @@ static int vhost_user_read(struct vhost_dev *dev, Vhost= UserMsg *msg) r =3D qemu_chr_fe_read_all(chr, p, size); if (r !=3D size) { error_report("Failed to read msg payload." - " Read %d instead of %d.", r, msg->hdr.size); + " Read %d instead of %u.", r, msg->hdr.size); goto fail; } } @@ -300,7 +301,8 @@ static int vhost_user_write(struct vhost_dev *dev, Vhos= tUserMsg *msg, { struct vhost_user *u =3D dev->opaque; CharBackend *chr =3D u->user->chr; - int ret, size =3D VHOST_USER_HDR_SIZE + msg->hdr.size; + int ret; + size_t size =3D VHOST_USER_HDR_SIZE + msg->hdr.size; =20 /* * For non-vring specific requests, like VHOST_USER_SET_MEM_TABLE, @@ -320,7 +322,7 @@ static int vhost_user_write(struct vhost_dev *dev, Vhos= tUserMsg *msg, ret =3D qemu_chr_fe_write_all(chr, (const uint8_t *) msg, size); if (ret !=3D size) { error_report("Failed to write msg." - " Wrote %d instead of %d.", ret, size); + " Wrote %d instead of %zu.", ret, size); return -1; } =20 --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625366902793.8842033874441; Tue, 19 Feb 2019 17:16:06 -0800 (PST) Received: from localhost ([127.0.0.1]:57462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGUV-0000al-2S for importer@patchew.org; Tue, 19 Feb 2019 20:16:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGPj-0005AX-Jp for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:11:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGPf-0004j2-99 for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:11:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45034) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGPP-0002NG-QY; Tue, 19 Feb 2019 20:10:50 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4CB68811A9; Wed, 20 Feb 2019 01:05:38 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8CBDD1001DE2; Wed, 20 Feb 2019 01:05:27 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:17 +0100 Message-Id: <20190220010232.18731-11-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 20 Feb 2019 01:05:38 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 10/25] usb-redir: Verify usbredirparser_write get called with positive count 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The usbredirparser_write handler should never be called with a negative size payload, return an error if this is not the case. Now that we are sure the 'count' value is positive, make it obvious by casting it to a size_t. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Gerd Hoffmann --- hw/usb/redirect.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c index 18a42d1938..131eae2e7e 100644 --- a/hw/usb/redirect.c +++ b/hw/usb/redirect.c @@ -285,7 +285,11 @@ static int usbredir_write(void *priv, uint8_t *data, i= nt count) return 0; } =20 - r =3D qemu_chr_fe_write(&dev->cs, data, count); + if (count < 0) { + ERROR("Illegal write count: %i\n", count); + return 0; + } + r =3D qemu_chr_fe_write(&dev->cs, data, (size_t)count); if (r < count) { if (!dev->watch) { dev->watch =3D qemu_chr_fe_add_watch(&dev->cs, G_IO_OUT | G_IO= _HUP, --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625672923446.5667453122395; Tue, 19 Feb 2019 17:21:12 -0800 (PST) Received: from localhost ([127.0.0.1]:57537 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGZM-0004Uu-RA for importer@patchew.org; Tue, 19 Feb 2019 20:21:04 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQl-0005xU-4k for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGL0-0002n8-Aj for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:06:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:19308) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGKy-0002Xv-0M; Tue, 19 Feb 2019 20:06:12 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D811380F91; Wed, 20 Feb 2019 01:05:50 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DCA311001DE2; Wed, 20 Feb 2019 01:05:38 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:18 +0100 Message-Id: <20190220010232.18731-12-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 20 Feb 2019 01:05:51 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 11/25] xen: Let xencons_send() take a 'size' argument 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The single caller of xencons_send(), con_event() already use the difference 'con->buffer.size - con->buffer.consumed'. Deduplicate by passing the difference as an argument. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/char/xen_console.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index 91f34ef06c..083b2c8e2a 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -144,11 +144,10 @@ static void xencons_receive(void *opaque, const uint8= _t *buf, int len) xen_pv_send_notify(&con->xendev); } =20 -static void xencons_send(struct XenConsole *con) +static void xencons_send(struct XenConsole *con, ssize_t size) { - ssize_t len, size; + ssize_t len; =20 - size =3D con->buffer.size - con->buffer.consumed; if (qemu_chr_fe_backend_connected(&con->chr)) { len =3D qemu_chr_fe_write(&con->chr, con->buffer.data + con->buffer.consumed, @@ -280,10 +279,13 @@ static void con_disconnect(struct XenLegacyDevice *xe= ndev) static void con_event(struct XenLegacyDevice *xendev) { struct XenConsole *con =3D container_of(xendev, struct XenConsole, xen= dev); + ssize_t size; =20 buffer_append(con); - if (con->buffer.size - con->buffer.consumed) - xencons_send(con); + size =3D con->buffer.size - con->buffer.consumed; + if (size) { + xencons_send(con, size); + } } =20 /* -------------------------------------------------------------------- */ --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625600583473.5266254518392; Tue, 19 Feb 2019 17:20:00 -0800 (PST) Received: from localhost ([127.0.0.1]:57504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGYE-0003Ya-De for importer@patchew.org; Tue, 19 Feb 2019 20:19:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQP-0005cx-VS for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:11:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGN4-0003r2-PH for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:08:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48588) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGMz-0002bE-UI; Tue, 19 Feb 2019 20:08:18 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9E35F5944D; Wed, 20 Feb 2019 01:06:03 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 55C561001E7E; Wed, 20 Feb 2019 01:05:51 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:19 +0100 Message-Id: <20190220010232.18731-13-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 20 Feb 2019 01:06:03 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 12/25] xen: Let buffer_append() return the size consumed 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The buffer.size and buffer.consumed fields are only updated within the buffer_append() body. We can simply let buffer_append() return the difference (the buffer consumed). Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/char/xen_console.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index 083b2c8e2a..1a30014a11 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -48,7 +48,7 @@ struct XenConsole { int backlog; }; =20 -static void buffer_append(struct XenConsole *con) +static ssize_t buffer_append(struct XenConsole *con) { struct buffer *buffer =3D &con->buffer; XENCONS_RING_IDX cons, prod, size; @@ -59,8 +59,9 @@ static void buffer_append(struct XenConsole *con) xen_mb(); =20 size =3D prod - cons; - if ((size =3D=3D 0) || (size > sizeof(intf->out))) - return; + if ((size =3D=3D 0) || (size > sizeof(intf->out))) { + goto out; + } =20 if ((buffer->capacity - buffer->size) < size) { buffer->capacity +=3D (size + 1024); @@ -89,6 +90,9 @@ static void buffer_append(struct XenConsole *con) if (buffer->consumed > buffer->max_capacity - over) buffer->consumed =3D buffer->max_capacity - over; } + + out: + return buffer->size - buffer->consumed; } =20 static void buffer_advance(struct buffer *buffer, size_t len) @@ -281,8 +285,7 @@ static void con_event(struct XenLegacyDevice *xendev) struct XenConsole *con =3D container_of(xendev, struct XenConsole, xen= dev); ssize_t size; =20 - buffer_append(con); - size =3D con->buffer.size - con->buffer.consumed; + size =3D buffer_append(con); if (size) { xencons_send(con, size); } --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625474467475.27551350479007; Tue, 19 Feb 2019 17:17:54 -0800 (PST) Received: from localhost ([127.0.0.1]:57480 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGWF-0001sA-3p for importer@patchew.org; Tue, 19 Feb 2019 20:17:51 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQh-0005A7-Cm for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGMC-0003PO-6Q for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:07:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48640) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGLr-0002qP-Qk; Tue, 19 Feb 2019 20:07:11 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5C2C859450; Wed, 20 Feb 2019 01:06:16 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 16F361001DE2; Wed, 20 Feb 2019 01:06:03 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:20 +0100 Message-Id: <20190220010232.18731-14-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 20 Feb 2019 01:06:16 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [RFC PATCH v3 13/25] xen: Let buffer_append() return a size_t 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" To the Xen team: this is not trivial to me to demonstrate this assertion can never happen, but then the whole series is justified and I can convert qemu_chr_fe_write() to use size_t argument. Can you help me here? Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/char/xen_console.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index 1a30014a11..5b672a5a24 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -92,6 +92,7 @@ static ssize_t buffer_append(struct XenConsole *con) } =20 out: + assert(buffer->size >=3D buffer->consumed); return buffer->size - buffer->consumed; } =20 --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15506254531541012.0517167892716; Tue, 19 Feb 2019 17:17:33 -0800 (PST) Received: from localhost ([127.0.0.1]:57471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGVu-0001cp-3s for importer@patchew.org; Tue, 19 Feb 2019 20:17:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQZ-00052t-90 for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGN0-0003ps-4C for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:08:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41620) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGMx-00031l-VX; Tue, 19 Feb 2019 20:08:17 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 10B8F8830E; Wed, 20 Feb 2019 01:06:29 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E4A811001DE2; Wed, 20 Feb 2019 01:06:16 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:21 +0100 Message-Id: <20190220010232.18731-15-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 20 Feb 2019 01:06:29 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 14/25] virtio-serial: Let VirtIOSerialPortClass::have_data() use size_t 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Both callers in hw/char/virtio-serial-bus.c provide unsigned values, even the trace event display an unsigned value. Convert the have_data() handler to take an unsigned value. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- It is funny/scary that there are big comments about how to treat errors to set the return value, then the return value is simply ignored by the caller. --- hw/char/virtio-console.c | 2 +- include/hw/virtio/virtio-serial.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/char/virtio-console.c b/hw/char/virtio-console.c index 2cbe1d4ed5..19639dca3b 100644 --- a/hw/char/virtio-console.c +++ b/hw/char/virtio-console.c @@ -45,7 +45,7 @@ static gboolean chr_write_unblocked(GIOChannel *chan, GIO= Condition cond, =20 /* Callback function that's called when the guest sends us data */ static ssize_t flush_buf(VirtIOSerialPort *port, - const uint8_t *buf, ssize_t len) + const uint8_t *buf, size_t len) { VirtConsole *vcon =3D VIRTIO_CONSOLE(port); ssize_t ret; diff --git a/include/hw/virtio/virtio-serial.h b/include/hw/virtio/virtio-s= erial.h index 12657a9f39..f1a5ccf4f7 100644 --- a/include/hw/virtio/virtio-serial.h +++ b/include/hw/virtio/virtio-serial.h @@ -81,7 +81,7 @@ typedef struct VirtIOSerialPortClass { * 'len'. In this case, throttling will be enabled for this port. */ ssize_t (*have_data)(VirtIOSerialPort *port, const uint8_t *buf, - ssize_t len); + size_t len); } VirtIOSerialPortClass; =20 /* --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625371375716.8641548594823; Tue, 19 Feb 2019 17:16:11 -0800 (PST) Received: from localhost ([127.0.0.1]:57467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGUa-0000gB-AR for importer@patchew.org; Tue, 19 Feb 2019 20:16:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGPu-00059h-Dc for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:11:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGOq-0004NU-Qx for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:10:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41686) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGOc-00035E-7x; Tue, 19 Feb 2019 20:10:01 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 17E4D88317; Wed, 20 Feb 2019 01:06:42 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A6981001E87; Wed, 20 Feb 2019 01:06:29 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:22 +0100 Message-Id: <20190220010232.18731-16-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 20 Feb 2019 01:06:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 15/25] spapr-vty: Let vty_putchars() use size_t 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Both callers (h_put_term_char and rtas_display_character) use an unsigned value. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/char/spapr_vty.c | 2 +- include/hw/ppc/spapr_vio.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/char/spapr_vty.c b/hw/char/spapr_vty.c index 6748334ded..92b8c40410 100644 --- a/hw/char/spapr_vty.c +++ b/hw/char/spapr_vty.c @@ -83,7 +83,7 @@ static int vty_getchars(VIOsPAPRDevice *sdev, uint8_t *bu= f, int max) return n; } =20 -void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len) +void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, size_t len) { VIOsPAPRVTYDevice *dev =3D VIO_SPAPR_VTY_DEVICE(sdev); =20 diff --git a/include/hw/ppc/spapr_vio.h b/include/hw/ppc/spapr_vio.h index e8b006d18f..ed79d2f380 100644 --- a/include/hw/ppc/spapr_vio.h +++ b/include/hw/ppc/spapr_vio.h @@ -126,7 +126,7 @@ static inline int spapr_vio_dma_set(VIOsPAPRDevice *dev= , uint64_t taddr, int spapr_vio_send_crq(VIOsPAPRDevice *dev, uint8_t *crq); =20 VIOsPAPRDevice *vty_lookup(sPAPRMachineState *spapr, target_ulong reg); -void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len); +void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, size_t len); void spapr_vty_create(VIOsPAPRBus *bus, Chardev *chardev); void spapr_vlan_create(VIOsPAPRBus *bus, NICInfo *nd); void spapr_vscsi_create(VIOsPAPRBus *bus); --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550626173552609.5318917605834; Tue, 19 Feb 2019 17:29:33 -0800 (PST) Received: from localhost ([127.0.0.1]:57701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGhW-0003TL-Gr for importer@patchew.org; Tue, 19 Feb 2019 20:29:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGRr-00076E-0Q for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:13:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGRb-0005IO-3p for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:13:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49374) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGRY-0003HF-7z; Tue, 19 Feb 2019 20:13:01 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4BC211E2D4; Wed, 20 Feb 2019 01:06:55 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8BB1A1001DE2; Wed, 20 Feb 2019 01:06:42 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:23 +0100 Message-Id: <20190220010232.18731-17-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 20 Feb 2019 01:06:55 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 16/25] tpm: Use size_t to hold sizes 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Avoid to use a signed type to hold an unsigned value. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/tpm/tpm_emulator.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c index 70f4b10284..931e56f6ed 100644 --- a/hw/tpm/tpm_emulator.c +++ b/hw/tpm/tpm_emulator.c @@ -87,17 +87,18 @@ static int tpm_emulator_ctrlcmd(TPMEmulator *tpm, unsig= ned long cmd, void *msg, { CharBackend *dev =3D &tpm->ctrl_chr; uint32_t cmd_no =3D cpu_to_be32(cmd); - ssize_t n =3D sizeof(uint32_t) + msg_len_in; + size_t sz =3D sizeof(uint32_t) + msg_len_in; + ssize_t n; uint8_t *buf =3D NULL; int ret =3D -1; =20 qemu_mutex_lock(&tpm->mutex); =20 - buf =3D g_alloca(n); + buf =3D g_alloca(sz); memcpy(buf, &cmd_no, sizeof(cmd_no)); memcpy(buf + sizeof(cmd_no), msg, msg_len_in); =20 - n =3D qemu_chr_fe_write_all(dev, buf, n); + n =3D qemu_chr_fe_write_all(dev, buf, sz); if (n <=3D 0) { goto end; } --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625174427799.7243301925381; Tue, 19 Feb 2019 17:12:54 -0800 (PST) Received: from localhost ([127.0.0.1]:57400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGRJ-000629-CA for importer@patchew.org; Tue, 19 Feb 2019 20:12:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGPb-00052u-DY for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:10:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGPK-0004bw-Sf for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:10:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46518) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGPD-0003Lw-8I; Tue, 19 Feb 2019 20:10:37 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0120EA4050; Wed, 20 Feb 2019 01:07:08 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B890B1001E7E; Wed, 20 Feb 2019 01:06:55 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:24 +0100 Message-Id: <20190220010232.18731-18-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 20 Feb 2019 01:07:08 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 17/25] net/filter-mirror: Use size_t 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since iov_size() returns a size_t, no need to use a signed type. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- net/filter-mirror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/filter-mirror.c b/net/filter-mirror.c index 3a61cf21e8..97b52d0544 100644 --- a/net/filter-mirror.c +++ b/net/filter-mirror.c @@ -48,7 +48,7 @@ static int filter_send(MirrorState *s, { NetFilterState *nf =3D NETFILTER(s); int ret =3D 0; - ssize_t size =3D 0; + size_t size =3D 0; uint32_t len =3D 0; char *buf; =20 --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550626266856553.7774907308033; Tue, 19 Feb 2019 17:31:06 -0800 (PST) Received: from localhost ([127.0.0.1]:57752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGiu-0004pH-Cv for importer@patchew.org; Tue, 19 Feb 2019 20:30:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGSY-0007gz-AV for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:14:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGSN-0005RX-8J for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:13:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59110) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGS7-0003OK-8g; Tue, 19 Feb 2019 20:13:39 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B6A613ABD; Wed, 20 Feb 2019 01:07:21 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B6FF51001DE2; Wed, 20 Feb 2019 01:07:08 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:25 +0100 Message-Id: <20190220010232.18731-19-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 20 Feb 2019 01:07:21 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 18/25] s390x/3270: Let insert_IAC_escape_char() use size_t 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This function takes size_t argument and return a size_t. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/char/terminal3270.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/char/terminal3270.c b/hw/char/terminal3270.c index 35b079d5c4..1cb48a3c6f 100644 --- a/hw/char/terminal3270.c +++ b/hw/char/terminal3270.c @@ -199,9 +199,10 @@ static int read_payload_3270(EmulatedCcw3270Device *de= v) } =20 /* TN3270 uses binary transmission, which needs escape IAC to IAC IAC */ -static int insert_IAC_escape_char(uint8_t *outv, int out_len) +static size_t insert_IAC_escape_char(uint8_t *outv, size_t out_len) { - int IAC_num =3D 0, new_out_len, i, j; + size_t new_out_len; + int IAC_num =3D 0, i, j; =20 for (i =3D 0; i < out_len; i++) { if (outv[i] =3D=3D IAC) { @@ -232,7 +233,7 @@ static int write_payload_3270(EmulatedCcw3270Device *de= v, uint8_t cmd) int count =3D ccw_dstream_avail(get_cds(t)); int bound =3D (OUTPUT_BUFFER_SIZE - 3) / 2; int len =3D MIN(count, bound); - int out_len =3D 0; + size_t out_len =3D 0; =20 if (!t->handshake_done) { if (!(t->outv[0] =3D=3D IAC && t->outv[1] !=3D IAC)) { --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625184268600.1333009479507; Tue, 19 Feb 2019 17:13:04 -0800 (PST) Received: from localhost ([127.0.0.1]:57402 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGRW-0006LB-5Z for importer@patchew.org; Tue, 19 Feb 2019 20:12:58 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGPj-00052u-Bv for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:11:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGP5-0004T4-7Y for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:10:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56540) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGOz-0003QO-E7; Tue, 19 Feb 2019 20:10:24 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1C900C058CAF; Wed, 20 Feb 2019 01:07:34 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1166C1001DE2; Wed, 20 Feb 2019 01:07:21 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:26 +0100 Message-Id: <20190220010232.18731-20-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 20 Feb 2019 01:07:34 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 19/25] s390/ebcdic: Use size_t to iterate over arrays 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/s390x/ebcdic.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/hw/s390x/ebcdic.h b/include/hw/s390x/ebcdic.h index 69a04cab62..d89174e113 100644 --- a/include/hw/s390x/ebcdic.h +++ b/include/hw/s390x/ebcdic.h @@ -83,18 +83,18 @@ static const uint8_t ascii2ebcdic[] =3D { 0x90, 0x3F, 0x3F, 0x3F, 0x3F, 0xEA, 0x3F, 0xFF }; =20 -static inline void ebcdic_put(uint8_t *p, const char *ascii, int len) +static inline void ebcdic_put(uint8_t *p, const char *ascii, size_t len) { - int i; + size_t i; =20 for (i =3D 0; i < len; i++) { p[i] =3D ascii2ebcdic[(uint8_t)ascii[i]]; } } =20 -static inline void ascii_put(uint8_t *p, const char *ebcdic, int len) +static inline void ascii_put(uint8_t *p, const char *ebcdic, size_t len) { - int i; + size_t i; =20 for (i =3D 0; i < len; i++) { p[i] =3D ebcdic2ascii[(uint8_t)ebcdic[i]]; --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 155062522289127.705382579377556; Tue, 19 Feb 2019 17:13:42 -0800 (PST) Received: from localhost ([127.0.0.1]:57408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGS6-0006rY-Qi for importer@patchew.org; Tue, 19 Feb 2019 20:13:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQ9-0005AX-1H for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:11:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGOA-00048j-Rv for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:09:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59248) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGNt-0003TU-7k; Tue, 19 Feb 2019 20:09:15 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7952720200; Wed, 20 Feb 2019 01:07:46 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 907471001E87; Wed, 20 Feb 2019 01:07:34 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:27 +0100 Message-Id: <20190220010232.18731-21-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 20 Feb 2019 01:07:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 20/25] s390x/sclp: Use a const variable to improve readability 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We will reuse this variable in the next patch. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/char/sclpconsole-lm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c index dbc91a1e5b..49543e2c83 100644 --- a/hw/char/sclpconsole-lm.c +++ b/hw/char/sclpconsole-lm.c @@ -210,13 +210,14 @@ static int process_mdb(SCLPEvent *event, MDBO *mdbo) int rc; int len; uint8_t buffer[SIZE_BUFFER]; - - len =3D be16_to_cpu(mdbo->length); - len -=3D sizeof(mdbo->length) + sizeof(mdbo->type) + const size_t hlen =3D sizeof(mdbo->length) + + sizeof(mdbo->type) + sizeof(mdbo->mto.line_type_flags) + sizeof(mdbo->mto.alarm_control) + sizeof(mdbo->mto._reserved); =20 + len =3D be16_to_cpu(mdbo->length); + len -=3D hlen; assert(len <=3D SIZE_BUFFER); =20 /* convert EBCDIC SCLP contents to ASCII console message */ --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550626363591361.0988256401155; Tue, 19 Feb 2019 17:32:43 -0800 (PST) Received: from localhost ([127.0.0.1]:57783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGkX-0006Ay-Js for importer@patchew.org; Tue, 19 Feb 2019 20:32:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGSa-0007lR-La for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:14:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGSY-0005V6-0A for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:14:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45838) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGSE-0003ml-Ly; Tue, 19 Feb 2019 20:13:48 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 60EC681F1B; Wed, 20 Feb 2019 01:08:07 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3D36B1001DE2; Wed, 20 Feb 2019 01:07:46 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:28 +0100 Message-Id: <20190220010232.18731-22-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 20 Feb 2019 01:08:07 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 21/25] s390x/sclp: Use size_t in process_mdb() 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since it is unlikely we have sizeof(mdbo->mto.message) < 0, we can convert this variable to an unsigned type. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/char/sclpconsole-lm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c index 49543e2c83..48c76d863e 100644 --- a/hw/char/sclpconsole-lm.c +++ b/hw/char/sclpconsole-lm.c @@ -208,7 +208,7 @@ static int write_console_data(SCLPEvent *event, const u= int8_t *buf, int len) static int process_mdb(SCLPEvent *event, MDBO *mdbo) { int rc; - int len; + uint16_t len; uint8_t buffer[SIZE_BUFFER]; const size_t hlen =3D sizeof(mdbo->length) + sizeof(mdbo->type) @@ -217,6 +217,7 @@ static int process_mdb(SCLPEvent *event, MDBO *mdbo) + sizeof(mdbo->mto._reserved); =20 len =3D be16_to_cpu(mdbo->length); + assert(len >=3D hlen); len -=3D hlen; assert(len <=3D SIZE_BUFFER); =20 --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550626501058206.2611719026197; Tue, 19 Feb 2019 17:35:01 -0800 (PST) Received: from localhost ([127.0.0.1]:57811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGmn-00087D-2G for importer@patchew.org; Tue, 19 Feb 2019 20:34:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGTs-0000c3-Dd for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:15:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGTg-0005lt-3I for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:15:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56886) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGTN-0003r8-No; Tue, 19 Feb 2019 20:14:59 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E6C37C057F9F; Wed, 20 Feb 2019 01:08:22 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22EB31001DE2; Wed, 20 Feb 2019 01:08:07 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:29 +0100 Message-Id: <20190220010232.18731-23-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 20 Feb 2019 01:08:23 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 22/25] s390x/sclp: Let write_console_data() take a size_t 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Since all callers provide an unsigned value, we can safely use a size_t argument. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/char/sclpconsole-lm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c index 48c76d863e..290d3118a5 100644 --- a/hw/char/sclpconsole-lm.c +++ b/hw/char/sclpconsole-lm.c @@ -191,7 +191,7 @@ static int read_event_data(SCLPEvent *event, EventBuffe= rHeader *evt_buf_hdr, * - write console data to character layer * returns < 0 if an error occurred */ -static int write_console_data(SCLPEvent *event, const uint8_t *buf, int le= n) +static int write_console_data(SCLPEvent *event, const uint8_t *buf, size_t= len) { SCLPConsoleLM *scon =3D SCLPLM_CONSOLE(event); =20 --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625596723378.2500656226057; Tue, 19 Feb 2019 17:19:56 -0800 (PST) Received: from localhost ([127.0.0.1]:57502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGY9-0003OO-Db for importer@patchew.org; Tue, 19 Feb 2019 20:19:49 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41251) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQC-0005cx-Mw for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:11:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGPy-0004ov-7E for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:11:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42303) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGPj-0003tM-Ma; Tue, 19 Feb 2019 20:11:10 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3402985541; Wed, 20 Feb 2019 01:08:34 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7AAD91001E7E; Wed, 20 Feb 2019 01:08:23 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:30 +0100 Message-Id: <20190220010232.18731-24-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 20 Feb 2019 01:08:34 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 23/25] hw/ipmi: Assert outlen > outpos 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" A througfull audit show that all time data is added to outbuf[], 'outlen' is incremented. Then at creation and each time continue_send() returns it pass thru check_reset which resets 'outpos', thus we always have 'outlen >=3D outpos'. Also due to the check on entry, we know outlen !=3D 0. We can then add an assertion on 'outlen > outpos', which will helps the next patch to safely convert 'outlen - outpos' as an unsigned type (size_t). Make this assertion explicit by casting 'outlen - outpos' size_t. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/ipmi/ipmi_bmc_extern.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/ipmi/ipmi_bmc_extern.c b/hw/ipmi/ipmi_bmc_extern.c index bf0b7ee0f5..ca61b04942 100644 --- a/hw/ipmi/ipmi_bmc_extern.c +++ b/hw/ipmi/ipmi_bmc_extern.c @@ -107,8 +107,9 @@ static void continue_send(IPMIBmcExtern *ibe) goto check_reset; } send: + assert(ibe->outlen > ibe->outpos); ret =3D qemu_chr_fe_write(&ibe->chr, ibe->outbuf + ibe->outpos, - ibe->outlen - ibe->outpos); + (size_t)(ibe->outlen - ibe->outpos)); if (ret > 0) { ibe->outpos +=3D ret; } --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550626469930452.70136643504; Tue, 19 Feb 2019 17:34:29 -0800 (PST) Received: from localhost ([127.0.0.1]:57803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGmH-0007dT-Nt for importer@patchew.org; Tue, 19 Feb 2019 20:34:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGX6-0002u8-LA for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:18:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGWj-0006ho-C1 for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:18:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57138) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGWX-0003zL-6G; Tue, 19 Feb 2019 20:18:11 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1FC33C062C6A; Wed, 20 Feb 2019 01:08:49 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AB2531001DE2; Wed, 20 Feb 2019 01:08:34 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:31 +0100 Message-Id: <20190220010232.18731-25-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 20 Feb 2019 01:08:49 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 24/25] chardev: Let qemu_chr_fe_write[_all] use size_t type argument 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" All caller have been audited and call these functions with unsigned arguments. Most of them use a size_t argument, or directly pass sizeof(). One case is unclear: the mux_chr_write() call in chardev/char-mux.c. There we add an assert (which will be removed in few patches) and cast the parameter as size_t to make explicit this value is unsigned. Suggested-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- chardev/char-fe.c | 4 ++-- chardev/char-mux.c | 3 ++- include/chardev/char-fe.h | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/chardev/char-fe.c b/chardev/char-fe.c index f3530a90e6..ab2a01709d 100644 --- a/chardev/char-fe.c +++ b/chardev/char-fe.c @@ -31,7 +31,7 @@ #include "chardev/char-io.h" #include "chardev/char-mux.h" =20 -int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len) +int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, size_t len) { Chardev *s =3D be->chr; =20 @@ -42,7 +42,7 @@ int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf= , int len) return qemu_chr_write(s, buf, len, false); } =20 -int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len) +int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, size_t len) { Chardev *s =3D be->chr; =20 diff --git a/chardev/char-mux.c b/chardev/char-mux.c index 23aa82125d..7a3ff21db4 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -38,7 +38,8 @@ static int mux_chr_write(Chardev *chr, const uint8_t *buf= , int len) MuxChardev *d =3D MUX_CHARDEV(chr); int ret; if (!d->timestamps) { - ret =3D qemu_chr_fe_write(&d->chr, buf, len); + assert(len >=3D 0); + ret =3D qemu_chr_fe_write(&d->chr, buf, (size_t)len); } else { int i; =20 diff --git a/include/chardev/char-fe.h b/include/chardev/char-fe.h index aa1b864ccd..5fb2c2e7ec 100644 --- a/include/chardev/char-fe.h +++ b/include/chardev/char-fe.h @@ -203,7 +203,7 @@ guint qemu_chr_fe_add_watch(CharBackend *be, GIOConditi= on cond, * * Returns: the number of bytes consumed (0 if no associated Chardev) */ -int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, int len); +int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, size_t len); =20 /** * qemu_chr_fe_write_all: @@ -217,7 +217,7 @@ int qemu_chr_fe_write(CharBackend *be, const uint8_t *b= uf, int len); * * Returns: the number of bytes consumed (0 if no associated Chardev) */ -int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, int len); +int qemu_chr_fe_write_all(CharBackend *be, const uint8_t *buf, size_t len); =20 /** * qemu_chr_fe_read_all: --=20 2.20.1 From nobody Sun Nov 9 11:36:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550625994313622.813071012683; Tue, 19 Feb 2019 17:26:34 -0800 (PST) Received: from localhost ([127.0.0.1]:57655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGeX-0000nW-62 for importer@patchew.org; Tue, 19 Feb 2019 20:26:25 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41603) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQx-0006Ll-JH for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGQn-00055g-93 for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54418) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGQl-00042S-7A; Tue, 19 Feb 2019 20:12:13 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F1BBB81DF3; Wed, 20 Feb 2019 01:08:58 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A515A1018A02; Wed, 20 Feb 2019 01:08:49 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:32 +0100 Message-Id: <20190220010232.18731-26-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 20 Feb 2019 01:08:59 +0000 (UTC) Content-Transfer-Encoding: quoted-printable 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] [PATCH v3 25/25] chardev: Let qemu_chr_write[_all] use size_t 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: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We now know all callers use a size_t argument. We can convert qemu_chr_write() and qemu_chr_write_all() to use a size_t argument. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- chardev/char.c | 8 ++++---- include/chardev/char.h | 2 +- include/sysemu/replay.h | 2 +- replay/replay-char.c | 2 +- stubs/replay.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index 3149cd3ba9..8f1f56a802 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -99,8 +99,8 @@ static void qemu_chr_write_log(Chardev *s, const uint8_t = *buf, size_t len) } =20 static int qemu_chr_write_buffer(Chardev *s, - const uint8_t *buf, int len, - int *offset, bool write_all) + const uint8_t *buf, size_t len, + size_t *offset, bool write_all) { ChardevClass *cc =3D CHARDEV_GET_CLASS(s); int res =3D 0; @@ -132,9 +132,9 @@ static int qemu_chr_write_buffer(Chardev *s, return res; } =20 -int qemu_chr_write(Chardev *s, const uint8_t *buf, int len, bool write_all) +int qemu_chr_write(Chardev *s, const uint8_t *buf, size_t len, bool write_= all) { - int offset =3D 0; + size_t offset =3D 0; int res; =20 if (qemu_chr_replay(s) && replay_mode =3D=3D REPLAY_MODE_PLAY) { diff --git a/include/chardev/char.h b/include/chardev/char.h index 0341dd1ba2..2e3b5a15ca 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -221,7 +221,7 @@ void qemu_chr_set_feature(Chardev *chr, ChardevFeature feature); QemuOpts *qemu_chr_parse_compat(const char *label, const char *filename, bool permit_mux_mon); -int qemu_chr_write(Chardev *s, const uint8_t *buf, int len, bool write_all= ); +int qemu_chr_write(Chardev *s, const uint8_t *buf, size_t len, bool write_= all); #define qemu_chr_write_all(s, buf, len) qemu_chr_write(s, buf, len, true) int qemu_chr_wait_connected(Chardev *chr, Error **errp); =20 diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index 3a7c58e423..334944715d 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -158,7 +158,7 @@ void replay_chr_be_write(struct Chardev *s, uint8_t *bu= f, int len); /*! Writes char write return value to the replay log. */ void replay_char_write_event_save(int res, int offset); /*! Reads char write return value from the replay log. */ -void replay_char_write_event_load(int *res, int *offset); +void replay_char_write_event_load(int *res, size_t *offset); /*! Reads information about read_all character event. */ int replay_char_read_all_load(uint8_t *buf); /*! Writes character read_all error code into the replay log. */ diff --git a/replay/replay-char.c b/replay/replay-char.c index 736cc8c2e6..f0308578eb 100644 --- a/replay/replay-char.c +++ b/replay/replay-char.c @@ -104,7 +104,7 @@ void replay_char_write_event_save(int res, int offset) replay_put_dword(offset); } =20 -void replay_char_write_event_load(int *res, int *offset) +void replay_char_write_event_load(int *res, size_t *offset) { g_assert(replay_mutex_locked()); =20 diff --git a/stubs/replay.c b/stubs/replay.c index 4ac607895d..cf584d3191 100644 --- a/stubs/replay.c +++ b/stubs/replay.c @@ -44,7 +44,7 @@ void replay_char_write_event_save(int res, int offset) abort(); } =20 -void replay_char_write_event_load(int *res, int *offset) +void replay_char_write_event_load(int *res, size_t *offset) { abort(); } --=20 2.20.1