From patchwork Wed Feb 20 01:02:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10821009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F3926CB for ; Wed, 20 Feb 2019 01:26:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 791F72D030 for ; Wed, 20 Feb 2019 01:26:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B5C92D057; Wed, 20 Feb 2019 01:26:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D937B2D030 for ; Wed, 20 Feb 2019 01:26:06 +0000 (UTC) Received: from localhost ([127.0.0.1]:57659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGeE-0000yU-3I for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:26:06 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é Reviewed-by: Marc-André 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, GIOCondition cond, void *opaque) return TRUE; } -static int fd_chr_read_poll(void *opaque) +static gboolean fd_chr_read_poll(void *opaque) { Chardev *chr = CHARDEV(opaque); FDChardev *s = FD_CHARDEV(opaque); s->max_size = qemu_chr_be_can_write(chr); - return s->max_size; + return s->max_size > 0; } 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; - 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 = io_watch_poll_from_source(source); - bool now_active = iwp->fd_can_read(iwp->opaque) > 0; + bool now_active = iwp->fd_can_read(iwp->opaque); bool was_active = iwp->src != NULL; if (was_active == now_active) { return FALSE; @@ -76,7 +76,7 @@ static GSourceFuncs io_watch_poll_funcs = { 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, GIOCondition cond) return qio_channel_create_watch(s->ioc, cond); } -static int pty_chr_read_poll(void *opaque) +static gboolean pty_chr_read_poll(void *opaque) { Chardev *chr = CHARDEV(opaque); PtyChardev *s = PTY_CHARDEV(opaque); s->read_bytes = qemu_chr_be_can_write(chr); - return s->read_bytes; + return s->read_bytes > 0; } static gboolean pty_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque) 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); -static int tcp_chr_read_poll(void *opaque); +static gboolean tcp_chr_read_poll(void *opaque); static void tcp_chr_disconnect(Chardev *chr); /* Called with chr_write_lock held. */ @@ -184,7 +184,7 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len) } } -static int tcp_chr_read_poll(void *opaque) +static gboolean tcp_chr_read_poll(void *opaque) { Chardev *chr = CHARDEV(opaque); SocketChardev *s = SOCKET_CHARDEV(opaque); @@ -192,7 +192,7 @@ static int tcp_chr_read_poll(void *opaque) return 0; } s->max_size = qemu_chr_be_can_write(chr); - return s->max_size; + return s->max_size > 0; } 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) } } -static int udp_chr_read_poll(void *opaque) +static gboolean udp_chr_read_poll(void *opaque) { Chardev *chr = CHARDEV(opaque); UdpChardev *s = UDP_CHARDEV(opaque); @@ -77,7 +77,7 @@ static int udp_chr_read_poll(void *opaque) */ udp_chr_flush_buffer(s); - return s->max_size; + return s->max_size > 0; } static gboolean udp_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque) 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); From patchwork Wed Feb 20 01:02:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10821005 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3095B1575 for ; Wed, 20 Feb 2019 01:25:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1AD372D057 for ; Wed, 20 Feb 2019 01:25:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0EF002D05A; Wed, 20 Feb 2019 01:25:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AEC842D057 for ; Wed, 20 Feb 2019 01:25:51 +0000 (UTC) Received: from localhost ([127.0.0.1]:57653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGdz-0000j2-0K for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:25:51 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é --- 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, int len, bool write_all) int qemu_chr_be_can_write(Chardev *s) { CharBackend *be = s->be; + int receivable_bytes; if (!be || !be->chr_can_read) { return 0; } - return be->chr_can_read(be->opaque); + receivable_bytes = be->chr_can_read(be->opaque); + assert(receivable_bytes >= 0); + return receivable_bytes; } void qemu_chr_be_write_impl(Chardev *s, uint8_t *buf, int len) From patchwork Wed Feb 20 01:02:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10821001 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F9106CB for ; Wed, 20 Feb 2019 01:23:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 094C92CFCE for ; Wed, 20 Feb 2019 01:23:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F15892CFDB; Wed, 20 Feb 2019 01:23:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9231E2CFCE for ; Wed, 20 Feb 2019 01:23:22 +0000 (UTC) Received: from localhost ([127.0.0.1]:57583 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGbZ-0006lW-Rm for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:23:21 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é Reviewed-by: Gerd Hoffmann Reviewed-by: Marc-André 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" 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 = WCTABLET_CHARDEV(chr); - unsigned int i, clen; + size_t i; + unsigned int clen; char *pos; if (tablet->line_speed != 9600) { @@ -269,7 +270,7 @@ static int wctablet_chr_write(struct Chardev *chr, } else if (strncmp((char *)tablet->query, "TS", 2) == 0 && clen == 3) { - unsigned int input = tablet->query[2]; + uint8_t input = tablet->query[2]; uint8_t codes[7] = { 0xa3, ((input & 0x80) == 0) ? 0x7e : 0x7f, From patchwork Wed Feb 20 01:02:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10821011 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 354D76CB for ; Wed, 20 Feb 2019 01:27:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D4762D030 for ; Wed, 20 Feb 2019 01:27:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E9E22D057; Wed, 20 Feb 2019 01:27:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4CA552D030 for ; Wed, 20 Feb 2019 01:27:20 +0000 (UTC) Received: from localhost ([127.0.0.1]:57672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGfP-00021h-Ju for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:27:19 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é Reviewed-by: Marc-André 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 = BAUM_CHARDEV(chr); - int room, first; + size_t room, first; 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 = CHARDEV(baum); uint8_t io_buf[1 + 2 * len], *cur = io_buf; - int room; + size_t room; *cur++ = ESC; while (len--) if ((*cur++ = *buf++) == 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, GIOCondition cond, void *opaque) { Chardev *chr = CHARDEV(opaque); FDChardev *s = FD_CHARDEV(opaque); - int len; + size_t len; uint8_t buf[CHR_READ_BUF_LEN]; ssize_t ret; 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; int connected; GSource *timer_src; @@ -132,7 +132,7 @@ static gboolean pty_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque) { Chardev *chr = CHARDEV(opaque); PtyChardev *s = PTY_CHARDEV(opaque); - gsize len; + size_t len; uint8_t buf[CHR_READ_BUF_LEN]; ssize_t ret; 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, GIOCondition cond, void *opaque) Chardev *chr = CHARDEV(opaque); SocketChardev *s = SOCKET_CHARDEV(opaque); uint8_t buf[CHR_READ_BUF_LEN]; - int len, size; + size_t len; + int size; if ((s->state != TCP_CHARDEV_STATE_CONNECTED) || - s->max_size <= 0) { + s->max_size == 0) { return TRUE; } len = 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; #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 = CHARDEV(s); while (s->max_size > 0 && s->bufptr < s->bufcnt) { - int n = MIN(s->max_size, s->bufcnt - s->bufptr); + size_t n = MIN(s->max_size, s->bufcnt - s->bufptr); qemu_chr_be_write(chr, &s->buf[s->bufptr], n); s->bufptr += n; s->max_size = 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 = WIN_CHARDEV(chr); - int max_size = qemu_chr_be_can_write(chr); + size_t max_size = 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; } -int qemu_chr_be_can_write(Chardev *s) +size_t qemu_chr_be_can_write(Chardev *s) { CharBackend *be = 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; #define TYPE_CHARDEV_MSMOUSE "chardev-msmouse" @@ -48,7 +48,7 @@ typedef struct { static void msmouse_chr_accept_input(Chardev *chr) { MouseChardev *mouse = MOUSE_CHARDEV(chr); - int len; + size_t len; len = 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 = (uint8_t*)buf; while (len > 0) { - int can_write = qemu_chr_be_can_write(chr); + size_t can_write = qemu_chr_be_can_write(chr); last_out = MIN(len, can_write); if (last_out <= 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 { /* Command to be sent to serial port */ uint8_t outbuf[WC_OUTPUT_BUF_MAX_LEN]; - int outlen; + size_t outlen; int line_speed; bool send_events; @@ -186,7 +186,7 @@ static QemuInputHandler wctablet_handler = { static void wctablet_chr_accept_input(Chardev *chr) { TabletChardev *tablet = WCTABLET_CHARDEV(chr); - int len, canWrite; + size_t len, canWrite; canWrite = qemu_chr_be_can_write(chr); len = 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; QIOChannel *ioc_in, *ioc_out; - int max_size; + size_t max_size; } FDChardev; #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); /** * 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 { typedef struct QEMUFIFO { uint8_t *buf; - int buf_size; - int count, wptr, rptr; + size_t buf_size, count; + int wptr, rptr; } QEMUFIFO; 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 = opaque; - int len; + size_t len; uint8_t buf[16]; len = qemu_chr_be_can_write(s->chr); From patchwork Wed Feb 20 01:02:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10821003 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7B9DB6CB for ; Wed, 20 Feb 2019 01:23:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 619DA2930F for ; Wed, 20 Feb 2019 01:23:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F15C29342; Wed, 20 Feb 2019 01:23:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E93F92930F for ; Wed, 20 Feb 2019 01:23:58 +0000 (UTC) Received: from localhost ([127.0.0.1]:57589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGcA-0007G5-5B for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:23:58 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é Reviewed-by: Marc-André 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) == 0) { - int len = strlen(p + 5); + size_t len = strlen(p + 5); if ((len % 2) != 0) { put_packet(s, "E01"); From patchwork Wed Feb 20 01:02:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10820969 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9AD99922 for ; Wed, 20 Feb 2019 01:13:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80C3C2893F for ; Wed, 20 Feb 2019 01:13:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6E66B28A5A; Wed, 20 Feb 2019 01:13:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2014C2893F for ; Wed, 20 Feb 2019 01:13:58 +0000 (UTC) Received: from localhost ([127.0.0.1]:57418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGST-0007bE-Co for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:13:57 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP In put_packet_binary() we have: uint8_t *p; for(;;) { p = s->last_packet; *(p++) = ... s->last_packet_len = 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 >= s->last_packet", we are sure than "p - s->last_packet >= 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é Reviewed-by: Marc-André 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; From patchwork Wed Feb 20 01:02:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10820985 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42B3414E1 for ; Wed, 20 Feb 2019 01:20:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C7582C165 for ; Wed, 20 Feb 2019 01:20:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F3D22CFCE; Wed, 20 Feb 2019 01:20:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CC8492C165 for ; Wed, 20 Feb 2019 01:20:31 +0000 (UTC) Received: from localhost ([127.0.0.1]:57539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGYp-0004WA-43 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:20:31 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP All callers provide a size_t argument, we can safely use size_t for this function. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Marc-André 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 *newstates) return res; } -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; while (len > 0) { ret = send(s->fd, buf, len, 0); From patchwork Wed Feb 20 01:02:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10820999 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 804F46CB for ; Wed, 20 Feb 2019 01:23:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E4D42CFCD for ; Wed, 20 Feb 2019 01:23:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A36E2CFD7; Wed, 20 Feb 2019 01:23:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ED1B32CFCD for ; Wed, 20 Feb 2019 01:23:00 +0000 (UTC) Received: from localhost ([127.0.0.1]:57580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGbE-0006QN-75 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:23:00 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The 'size' value is of type 'guint' which is already unsigned. Remove the useless cast. Signed-off-by: Philippe Mathieu-Daudé 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, } } - 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; } From patchwork Wed Feb 20 01:02:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10820997 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2C5E6CB for ; Wed, 20 Feb 2019 01:22:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB70D2C165 for ; Wed, 20 Feb 2019 01:22:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDCD62CFCE; Wed, 20 Feb 2019 01:22:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6579B2C165 for ; Wed, 20 Feb 2019 01:22:30 +0000 (UTC) Received: from localhost ([127.0.0.1]:57576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGaj-000636-9r for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:22:29 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é Reviewed-by: Marc-André 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, VhostUserMsg *msg) struct vhost_user *u = dev->opaque; CharBackend *chr = u->user->chr; uint8_t *p = (uint8_t *) msg; - int r, size = VHOST_USER_HDR_SIZE; + int r; + size_t size = VHOST_USER_HDR_SIZE; r = qemu_chr_fe_read_all(chr, p, size); if (r != 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, VhostUserMsg *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, VhostUserMsg *msg) r = qemu_chr_fe_read_all(chr, p, size); if (r != 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, VhostUserMsg *msg, { struct vhost_user *u = dev->opaque; CharBackend *chr = u->user->chr; - int ret, size = VHOST_USER_HDR_SIZE + msg->hdr.size; + int ret; + size_t size = VHOST_USER_HDR_SIZE + msg->hdr.size; /* * For non-vring specific requests, like VHOST_USER_SET_MEM_TABLE, @@ -320,7 +322,7 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg, ret = qemu_chr_fe_write_all(chr, (const uint8_t *) msg, size); if (ret != size) { error_report("Failed to write msg." - " Wrote %d instead of %d.", ret, size); + " Wrote %d instead of %zu.", ret, size); return -1; } From patchwork Wed Feb 20 01:02:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10820971 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2EC4D922 for ; Wed, 20 Feb 2019 01:15:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 141832C4D0 for ; Wed, 20 Feb 2019 01:15:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 01B7D2C4D4; Wed, 20 Feb 2019 01:15:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A99AD2C4D0 for ; Wed, 20 Feb 2019 01:15:25 +0000 (UTC) Received: from localhost ([127.0.0.1]:57462 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGTs-0000al-Vf for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:15:25 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é 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, int count) return 0; } - r = qemu_chr_fe_write(&dev->cs, data, count); + if (count < 0) { + ERROR("Illegal write count: %i\n", count); + return 0; + } + r = qemu_chr_fe_write(&dev->cs, data, (size_t)count); if (r < count) { if (!dev->watch) { dev->watch = qemu_chr_fe_add_watch(&dev->cs, G_IO_OUT | G_IO_HUP, From patchwork Wed Feb 20 01:02:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10820983 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9B0C6CB for ; Wed, 20 Feb 2019 01:20:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F6E92C165 for ; Wed, 20 Feb 2019 01:20:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C7DF2CFCE; Wed, 20 Feb 2019 01:20:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3C3522C165 for ; Wed, 20 Feb 2019 01:20:30 +0000 (UTC) Received: from localhost ([127.0.0.1]:57537 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGYn-0004Uu-Gt for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:20:29 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é Reviewed-by: Marc-André Lureau --- 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); } -static void xencons_send(struct XenConsole *con) +static void xencons_send(struct XenConsole *con, ssize_t size) { - ssize_t len, size; + ssize_t len; - size = con->buffer.size - con->buffer.consumed; if (qemu_chr_fe_backend_connected(&con->chr)) { len = qemu_chr_fe_write(&con->chr, con->buffer.data + con->buffer.consumed, @@ -280,10 +279,13 @@ static void con_disconnect(struct XenLegacyDevice *xendev) static void con_event(struct XenLegacyDevice *xendev) { struct XenConsole *con = container_of(xendev, struct XenConsole, xendev); + ssize_t size; buffer_append(con); - if (con->buffer.size - con->buffer.consumed) - xencons_send(con); + size = con->buffer.size - con->buffer.consumed; + if (size) { + xencons_send(con, size); + } } /* -------------------------------------------------------------------- */ From patchwork Wed Feb 20 01:02:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10820981 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 536566CB for ; Wed, 20 Feb 2019 01:19:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D5242CF1C for ; Wed, 20 Feb 2019 01:19:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 315BA2CF1F; Wed, 20 Feb 2019 01:19:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D3C242CF20 for ; Wed, 20 Feb 2019 01:19:17 +0000 (UTC) Received: from localhost ([127.0.0.1]:57504 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGXd-0003Ya-3X for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:19:17 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é --- 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; }; -static void buffer_append(struct XenConsole *con) +static ssize_t buffer_append(struct XenConsole *con) { struct buffer *buffer = &con->buffer; XENCONS_RING_IDX cons, prod, size; @@ -59,8 +59,9 @@ static void buffer_append(struct XenConsole *con) xen_mb(); size = prod - cons; - if ((size == 0) || (size > sizeof(intf->out))) - return; + if ((size == 0) || (size > sizeof(intf->out))) { + goto out; + } if ((buffer->capacity - buffer->size) < size) { buffer->capacity += (size + 1024); @@ -89,6 +90,9 @@ static void buffer_append(struct XenConsole *con) if (buffer->consumed > buffer->max_capacity - over) buffer->consumed = buffer->max_capacity - over; } + + out: + return buffer->size - buffer->consumed; } static void buffer_advance(struct buffer *buffer, size_t len) @@ -281,8 +285,7 @@ static void con_event(struct XenLegacyDevice *xendev) struct XenConsole *con = container_of(xendev, struct XenConsole, xendev); ssize_t size; - buffer_append(con); - size = con->buffer.size - con->buffer.consumed; + size = buffer_append(con); if (size) { xencons_send(con, size); } From patchwork Wed Feb 20 01:02:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10820977 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B4F1922 for ; Wed, 20 Feb 2019 01:17:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA7042C4D1 for ; Wed, 20 Feb 2019 01:17:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBC7C2C5A4; Wed, 20 Feb 2019 01:17:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8C4F42C4D1 for ; Wed, 20 Feb 2019 01:17:14 +0000 (UTC) Received: from localhost ([127.0.0.1]:57480 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGVa-0001sA-Gm for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:17:10 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é --- 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) } out: + assert(buffer->size >= buffer->consumed); return buffer->size - buffer->consumed; } From patchwork Wed Feb 20 01:02:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10820975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7B6E26CB for ; Wed, 20 Feb 2019 01:16:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 641B22C4D1 for ; Wed, 20 Feb 2019 01:16:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56FF82C5A4; Wed, 20 Feb 2019 01:16:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 043A42C4D1 for ; Wed, 20 Feb 2019 01:16:52 +0000 (UTC) Received: from localhost ([127.0.0.1]:57471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGVH-0001cp-5k for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:16:51 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é Reviewed-by: Marc-André Lureau --- 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, GIOCondition cond, /* 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 = VIRTIO_CONSOLE(port); ssize_t ret; diff --git a/include/hw/virtio/virtio-serial.h b/include/hw/virtio/virtio-serial.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; /* From patchwork Wed Feb 20 01:02:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10820973 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C6F3A922 for ; Wed, 20 Feb 2019 01:15:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B18472C4D0 for ; Wed, 20 Feb 2019 01:15:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A5BFE2C4D4; Wed, 20 Feb 2019 01:15:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5959B2C4D0 for ; Wed, 20 Feb 2019 01:15:28 +0000 (UTC) Received: from localhost ([127.0.0.1]:57467 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGTv-0000gB-JQ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:15:27 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Both callers (h_put_term_char and rtas_display_character) use an unsigned value. Signed-off-by: Philippe Mathieu-Daudé Acked-by: David Gibson --- 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 *buf, int max) return n; } -void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, int len) +void vty_putchars(VIOsPAPRDevice *sdev, uint8_t *buf, size_t len) { VIOsPAPRVTYDevice *dev = VIO_SPAPR_VTY_DEVICE(sdev); 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); 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); From patchwork Wed Feb 20 01:02:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10821015 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1E6826CB for ; Wed, 20 Feb 2019 01:29:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05E192C1B8 for ; Wed, 20 Feb 2019 01:29:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBFEA2CB29; Wed, 20 Feb 2019 01:29:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 96EDA2C1B8 for ; Wed, 20 Feb 2019 01:29:01 +0000 (UTC) Received: from localhost ([127.0.0.1]:57701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGh2-0003TL-Rn for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:29:00 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Avoid to use a signed type to hold an unsigned value. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Marc-André Lureau --- 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, unsigned long cmd, void *msg, { CharBackend *dev = &tpm->ctrl_chr; uint32_t cmd_no = cpu_to_be32(cmd); - ssize_t n = sizeof(uint32_t) + msg_len_in; + size_t sz = sizeof(uint32_t) + msg_len_in; + ssize_t n; uint8_t *buf = NULL; int ret = -1; qemu_mutex_lock(&tpm->mutex); - buf = g_alloca(n); + buf = g_alloca(sz); memcpy(buf, &cmd_no, sizeof(cmd_no)); memcpy(buf + sizeof(cmd_no), msg, msg_len_in); - n = qemu_chr_fe_write_all(dev, buf, n); + n = qemu_chr_fe_write_all(dev, buf, sz); if (n <= 0) { goto end; } From patchwork Wed Feb 20 01:02:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10820963 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D8BA922 for ; Wed, 20 Feb 2019 01:12:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC2662D9AF for ; Wed, 20 Feb 2019 01:12:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD88B2D9D8; Wed, 20 Feb 2019 01:12:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 82EC12D9AF for ; Wed, 20 Feb 2019 01:12:08 +0000 (UTC) Received: from localhost ([127.0.0.1]:57400 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQh-000629-4T for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:12:07 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since iov_size() returns a size_t, no need to use a signed type. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Marc-André Lureau --- 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 = NETFILTER(s); int ret = 0; - ssize_t size = 0; + size_t size = 0; uint32_t len = 0; char *buf; From patchwork Wed Feb 20 01:02:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10821017 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24CF9139A for ; Wed, 20 Feb 2019 01:30:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DB3D2D07F for ; Wed, 20 Feb 2019 01:30:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2B832D06E; Wed, 20 Feb 2019 01:30:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9A9472D06E for ; Wed, 20 Feb 2019 01:30:19 +0000 (UTC) Received: from localhost ([127.0.0.1]:57752 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGiI-0004pH-Rb for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:30:18 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This function takes size_t argument and return a size_t. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cornelia Huck --- 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 *dev) } /* 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 = 0, new_out_len, i, j; + size_t new_out_len; + int IAC_num = 0, i, j; for (i = 0; i < out_len; i++) { if (outv[i] == IAC) { @@ -232,7 +233,7 @@ static int write_payload_3270(EmulatedCcw3270Device *dev, uint8_t cmd) int count = ccw_dstream_avail(get_cds(t)); int bound = (OUTPUT_BUFFER_SIZE - 3) / 2; int len = MIN(count, bound); - int out_len = 0; + size_t out_len = 0; if (!t->handshake_done) { if (!(t->outv[0] == IAC && t->outv[1] != IAC)) { From patchwork Wed Feb 20 01:02:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10820965 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0370D139A for ; Wed, 20 Feb 2019 01:12:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E1B292D9AF for ; Wed, 20 Feb 2019 01:12:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D50932D9D8; Wed, 20 Feb 2019 01:12:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8C6BB2D9AF for ; Wed, 20 Feb 2019 01:12:22 +0000 (UTC) Received: from localhost ([127.0.0.1]:57402 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGQv-0006LB-LR for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:12:21 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Philippe Mathieu-Daudé Acked-by: Cornelia Huck --- 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[] = { 0x90, 0x3F, 0x3F, 0x3F, 0x3F, 0xEA, 0x3F, 0xFF }; -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; for (i = 0; i < len; i++) { p[i] = ascii2ebcdic[(uint8_t)ascii[i]]; } } -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; for (i = 0; i < len; i++) { p[i] = ebcdic2ascii[(uint8_t)ebcdic[i]]; From patchwork Wed Feb 20 01:02:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10820967 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 29D1D922 for ; Wed, 20 Feb 2019 01:13:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11E892D9AF for ; Wed, 20 Feb 2019 01:13:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02C502D9D8; Wed, 20 Feb 2019 01:13:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 96C892D9AF for ; Wed, 20 Feb 2019 01:13:01 +0000 (UTC) Received: from localhost ([127.0.0.1]:57408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGRY-0006rY-PP for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:13:00 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP We will reuse this variable in the next patch. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cornelia Huck --- 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 = be16_to_cpu(mdbo->length); - len -= sizeof(mdbo->length) + sizeof(mdbo->type) + const size_t hlen = sizeof(mdbo->length) + + sizeof(mdbo->type) + sizeof(mdbo->mto.line_type_flags) + sizeof(mdbo->mto.alarm_control) + sizeof(mdbo->mto._reserved); + len = be16_to_cpu(mdbo->length); + len -= hlen; assert(len <= SIZE_BUFFER); /* convert EBCDIC SCLP contents to ASCII console message */ From patchwork Wed Feb 20 01:02:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10821021 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 51644139A for ; Wed, 20 Feb 2019 01:32:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 397EB2D093 for ; Wed, 20 Feb 2019 01:32:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D6212D0A0; Wed, 20 Feb 2019 01:32:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CB7102D093 for ; Wed, 20 Feb 2019 01:32:05 +0000 (UTC) Received: from localhost ([127.0.0.1]:57783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGk1-0006Ay-2x for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:32:05 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é Reviewed-by: Cornelia Huck --- 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 uint8_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 = sizeof(mdbo->length) + sizeof(mdbo->type) @@ -217,6 +217,7 @@ static int process_mdb(SCLPEvent *event, MDBO *mdbo) + sizeof(mdbo->mto._reserved); len = be16_to_cpu(mdbo->length); + assert(len >= hlen); len -= hlen; assert(len <= SIZE_BUFFER); From patchwork Wed Feb 20 01:02:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10821025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 45EC36C2 for ; Wed, 20 Feb 2019 01:34:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DE642C30F for ; Wed, 20 Feb 2019 01:34:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F9AC2C3B9; Wed, 20 Feb 2019 01:34:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CABD92C30F for ; Wed, 20 Feb 2019 01:34:29 +0000 (UTC) Received: from localhost ([127.0.0.1]:57811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGmL-00087D-1g for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:34:29 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Since all callers provide an unsigned value, we can safely use a size_t argument. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Cornelia Huck --- 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, EventBufferHeader *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 len) +static int write_console_data(SCLPEvent *event, const uint8_t *buf, size_t len) { SCLPConsoleLM *scon = SCLPLM_CONSOLE(event); From patchwork Wed Feb 20 01:02:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10820979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C1206CB for ; Wed, 20 Feb 2019 01:19:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 651502CF1B for ; Wed, 20 Feb 2019 01:19:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54DFF2CF1F; Wed, 20 Feb 2019 01:19:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F170F2CF1B for ; Wed, 20 Feb 2019 01:19:12 +0000 (UTC) Received: from localhost ([127.0.0.1]:57502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGXY-0003OO-7f for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:19:12 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 >= outpos'. Also due to the check on entry, we know outlen != 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é Reviewed-by: Corey Minyard --- 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 = 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 += ret; } From patchwork Wed Feb 20 01:02:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10821023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DCD7B139A for ; Wed, 20 Feb 2019 01:34:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2C36285C8 for ; Wed, 20 Feb 2019 01:34:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2EB1287BF; Wed, 20 Feb 2019 01:34:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 50522285C8 for ; Wed, 20 Feb 2019 01:34:03 +0000 (UTC) Received: from localhost ([127.0.0.1]:57803 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGlu-0007dT-Dp for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:34:02 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é Reviewed-by: Marc-André Lureau --- 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" -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 = be->chr; @@ -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); } -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 = be->chr; 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 = MUX_CHARDEV(chr); int ret; if (!d->timestamps) { - ret = qemu_chr_fe_write(&d->chr, buf, len); + assert(len >= 0); + ret = qemu_chr_fe_write(&d->chr, buf, (size_t)len); } else { int i; 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, GIOCondition 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); /** * qemu_chr_fe_write_all: @@ -217,7 +217,7 @@ int qemu_chr_fe_write(CharBackend *be, const uint8_t *buf, 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); /** * qemu_chr_fe_read_all: From patchwork Wed Feb 20 01:02:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 10821007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C9B8D6CB for ; Wed, 20 Feb 2019 01:25:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B24002D04C for ; Wed, 20 Feb 2019 01:25:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3BE72D058; Wed, 20 Feb 2019 01:25:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3D0A12D04C for ; Wed, 20 Feb 2019 01:25:56 +0000 (UTC) Received: from localhost ([127.0.0.1]:57655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGe3-0000nW-Gc for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Feb 2019 20:25:55 -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_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , 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) 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_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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é --- 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) } 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 = CHARDEV_GET_CLASS(s); int res = 0; @@ -132,9 +132,9 @@ static int qemu_chr_write_buffer(Chardev *s, return res; } -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 = 0; + size_t offset = 0; int res; if (qemu_chr_replay(s) && replay_mode == 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); 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 *buf, 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); } -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()); 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(); } -void replay_char_write_event_load(int *res, int *offset) +void replay_char_write_event_load(int *res, size_t *offset) { abort(); }