From nobody Sun Feb 8 01:33:12 2026 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548768218362151.07379028042476; Tue, 29 Jan 2019 05:23:38 -0800 (PST) Received: from localhost ([127.0.0.1]:49418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goTMX-0006Hp-BJ for importer@patchew.org; Tue, 29 Jan 2019 08:23:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goTIr-0003oo-6N for qemu-devel@nongnu.org; Tue, 29 Jan 2019 08:19:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goTIp-0003pv-D3 for qemu-devel@nongnu.org; Tue, 29 Jan 2019 08:19:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59596) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1goTIn-0003om-VM for qemu-devel@nongnu.org; Tue, 29 Jan 2019 08:19:47 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2741987649; Tue, 29 Jan 2019 13:19:45 +0000 (UTC) Received: from gigantic.usersys.redhat.com (helium.bos.redhat.com [10.18.17.132]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1158D1B468; Tue, 29 Jan 2019 13:19:42 +0000 (UTC) From: Bandan Das To: qemu-devel@nongnu.org Date: Tue, 29 Jan 2019 08:19:08 -0500 Message-Id: <20190129131908.27924-4-bsd@redhat.com> In-Reply-To: <20190129131908.27924-1-bsd@redhat.com> References: <20190129131908.27924-1-bsd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 29 Jan 2019 13:19:45 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 3/3] usb-mtp: replace the homebrew write with qemu_write_full X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, kraxel@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" qemu_write_full takes care of partial blocking writes, as in cases of larger file sizes Suggested-by: Peter Maydell Signed-off-by: Bandan Das --- hw/usb/dev-mtp.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 1204a61cba..2ccbce8794 100644 --- a/hw/usb/dev-mtp.c +++ b/hw/usb/dev-mtp.c @@ -1631,24 +1631,16 @@ static char *utf16_to_str(uint8_t len, uint16_t *ar= r) /* Wrapper around write, returns 0 on failure */ static uint64_t write_retry(int fd, void *buf, uint64_t size, off_t offset) { - uint64_t bytes_left =3D size, ret; + uint64_t ret =3D 0; =20 if (lseek(fd, offset, SEEK_SET) < 0) { goto done; } =20 - while (bytes_left > 0) { - ret =3D write(fd, buf, bytes_left); - if ((ret =3D=3D -1) && (errno !=3D EINTR || errno !=3D EAG= AIN || - errno !=3D EWOULDBLOCK)) { - break; - } - bytes_left -=3D ret; - buf +=3D ret; - } + ret =3D qemu_write_full(fd, buf, size); =20 done: - return size - bytes_left; + return ret; } =20 static void usb_mtp_update_object(MTPObject *parent, char *name) --=20 2.19.2