From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 41775CCA47C for ; Mon, 4 Jul 2022 16:22:10 +0000 (UTC) Received: from localhost ([::1]:39390 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o8Opt-0003nX-8v for qemu-devel@archiver.kernel.org; Mon, 04 Jul 2022 12:22:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8Oor-0002Qm-R3 for qemu-devel@nongnu.org; Mon, 04 Jul 2022 12:21:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:22636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o8Oop-0003OO-F5 for qemu-devel@nongnu.org; Mon, 04 Jul 2022 12:21:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656951662; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dNG6EvBYvsu+Vu3UGBZ3dhBxzLsoA2k3lqqk942lSJw=; b=Y0BEdD5bcNOd35lj4gg+PV2QBqf4WEAKGIi9bruFvmVWXNixzXT2A2fnVuoKYYNgU/Ly+x I5hCHDe29NNrMWGCfLYvlJSo06xjOyzNLfdYIiz0cD5FLFqaCKSEyfdmSmjq3/x2GuypYN A3jfQjpYUeYqu8GZjnZJ82U7kXz1muw= Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-85-8v8vkX8qNeqr2jF_0xO-9Q-1; Mon, 04 Jul 2022 12:21:01 -0400 X-MC-Unique: 8v8vkX8qNeqr2jF_0xO-9Q-1 Received: by mail-io1-f70.google.com with SMTP id n19-20020a056602341300b0066850b49e09so5702200ioz.12 for ; Mon, 04 Jul 2022 09:21:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=dNG6EvBYvsu+Vu3UGBZ3dhBxzLsoA2k3lqqk942lSJw=; b=LP3H85SfR45LckNQolqSPKTsFIwMaVioYAaa/rcdJNqlnbvLiPdENdnJy0raPClqnS zbHZtKehdA2w1FiLeBRziYBiT/kb7gACAr4+ZICpX58dBViEqAvawczuynxffDf4Ca9T W19WkTqGOwLnetyaoKB1otuxXyRAEsQXI438Dje/doRB+z2rK1SgwcclY7cku+RkUw/W B4V1bFuJYzipwSi//pBUPyNKMAj8/cDtQDfNGSgdMPwjoRGs1HKVnMl3wLwqNc84Qfm6 BhQzuDX6ro2Ul54mOySIPPbW6TSvdERnURdRMCjGxjoYerypX4UKTABX+xtK/HThEfiA EPng== X-Gm-Message-State: AJIora/vcZ9FiQ1iQMxPHkrZkCNdPIIDcz714x1xxA09Z4LsWD3W9pbu Idp7kwi6qtP5Oo7wiPBJF8KBjP7gLb2uo4E+LTIpe2BQhj/e0o2TpGWs5nEQHvlD9fV+jEoYsnl TocG7V1gJjm0OPD2qht+JCDrWTLh6x7o= X-Received: by 2002:a92:cda5:0:b0:2d9:5bc5:6661 with SMTP id g5-20020a92cda5000000b002d95bc56661mr17833802ild.16.1656951661106; Mon, 04 Jul 2022 09:21:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s/+bFwP3NFLxCXEhXCB9tGBdMIf2+KPtL97PvzmTJwGF+P76N8wQkbecn53EgjuYLUeu309AQtlsK38/P5zxw= X-Received: by 2002:a92:cda5:0:b0:2d9:5bc5:6661 with SMTP id g5-20020a92cda5000000b002d95bc56661mr17833776ild.16.1656951660874; Mon, 04 Jul 2022 09:21:00 -0700 (PDT) MIME-Version: 1.0 References: <20220517113524.197910-1-afaria@redhat.com> <20220517113524.197910-2-afaria@redhat.com> <89089143-3f55-02c4-c881-95d356108569@redhat.com> In-Reply-To: <89089143-3f55-02c4-c881-95d356108569@redhat.com> From: Alberto Faria Date: Mon, 4 Jul 2022 17:20:25 +0100 Message-ID: Subject: Re: [PATCH 01/18] block: Make blk_{pread, pwrite}() return 0 on success To: Hanna Reitz Cc: qemu-devel@nongnu.org, Andrew Jeffery , Peter Maydell , qemu-block@nongnu.org, Palmer Dabbelt , =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= , qemu-ppc@nongnu.org, Eric Blake , Vladimir Sementsov-Ogievskiy , John Snow , Stefan Hajnoczi , Jeff Cody , qemu-riscv@nongnu.org, =?UTF-8?Q?C=C3=A9dric_Le_Goater?= , Joel Stanley , Stefan Weil , Laurent Vivier , "Denis V. Lunev" , Juan Quintela , "Dr. David Alan Gilbert" , Niek Linnenbank , Greg Kurz , Daniel Henrique Barboza , Kevin Wolf , "Edgar E. Iglesias" , qemu-arm@nongnu.org, Fam Zheng , Alistair Francis , Beniamino Galvani , Bin Meng , David Gibson Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=170.10.129.124; envelope-from=afaria@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Mon, Jul 4, 2022 at 2:52 PM Hanna Reitz wrote: > There are a couple of places where you decided to replace =E2=80=9C*len= =E2=80=9D > variables that used to store the return value by a plain =E2=80=9Cret=E2= =80=9D. That > seems good to me, given how these functions no longer return length > values, but you haven=E2=80=99t done so consistently. Below, I have note= d > places where this wasn=E2=80=99t done; I wonder why, but my R-b stands > regardless of whether you change them too or not. Thanks, this was just an oversight on my part. I'll fix it. > > diff --git a/qemu-img.c b/qemu-img.c > > index 4cf4d2423d..9d98ef63ac 100644 > > --- a/qemu-img.c > > +++ b/qemu-img.c > > @@ -5120,30 +5120,27 @@ static int img_dd(int argc, char **argv) > > in.buf =3D g_new(uint8_t, in.bsz); > > > > for (out_pos =3D 0; in_pos < size; block_count++) { > > - int in_ret, out_ret; > > + int bytes, in_ret, out_ret; > > > > - if (in_pos + in.bsz > size) { > > - in_ret =3D blk_pread(blk1, in_pos, in.buf, size - in_pos); > > - } else { > > - in_ret =3D blk_pread(blk1, in_pos, in.buf, in.bsz); > > - } > > + bytes =3D (in_pos + in.bsz > size) ? size - in_pos : in.bsz; > > + > > + in_ret =3D blk_pread(blk1, in_pos, in.buf, bytes); > > if (in_ret < 0) { > > error_report("error while reading from input image file: = %s", > > strerror(-in_ret)); > > ret =3D -1; > > goto out; > > } > > - in_pos +=3D in_ret; > > - > > - out_ret =3D blk_pwrite(blk2, out_pos, in.buf, in_ret, 0); > > + in_pos +=3D bytes; > > > > + out_ret =3D blk_pwrite(blk2, out_pos, in.buf, bytes, 0); > > if (out_ret < 0) { > > error_report("error while writing to output image file: %= s", > > strerror(-out_ret)); > > ret =3D -1; > > goto out; > > } > > - out_pos +=3D out_ret; > > + out_pos +=3D bytes; > > } > > > > out: > > We could use this opportunity to drop in_ret and out_ret altogether (but > we can also decide not to). Dropping them sounds good to me. Alberto