From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1advF3-0006ez-T2 for qemu-devel@nongnu.org; Thu, 10 Mar 2016 02:42:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1advEy-0004Nx-Tk for qemu-devel@nongnu.org; Thu, 10 Mar 2016 02:42:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:49989) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1advEy-0004Ns-NR for qemu-devel@nongnu.org; Thu, 10 Mar 2016 02:42:36 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 7AFF4C0C4285 for ; Thu, 10 Mar 2016 07:42:35 +0000 (UTC) Message-ID: <1457595753.6405.8.camel@redhat.com> From: Gerd Hoffmann Date: Thu, 10 Mar 2016 08:42:33 +0100 In-Reply-To: <877fhax1uc.fsf@blackfin.pond.sub.org> References: <1457503813-31631-1-git-send-email-peterx@redhat.com> <1457503813-31631-3-git-send-email-peterx@redhat.com> <20160310015647.GG23632@ad.usersys.redhat.com> <877fhax1uc.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 2/2] usb: trivial cleanup for usb_mtp_add_str List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: pbonzini@redhat.com, Fam Zheng , qemu-devel@nongnu.org, Peter Xu On Do, 2016-03-10 at 07:51 +0100, Markus Armbruster wrote: > Fam Zheng writes: >=20 > > On Wed, 03/09 14:10, Peter Xu wrote: > >> Remove useless var "ret". > >>=20 > >> Signed-off-by: Peter Xu > >> --- > >> hw/usb/dev-mtp.c | 4 +--- > >> 1 file changed, 1 insertion(+), 3 deletions(-) > >>=20 > >> diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c > >> index cf63fd0..38cc4fc 100644 > >> --- a/hw/usb/dev-mtp.c > >> +++ b/hw/usb/dev-mtp.c > >> @@ -719,10 +719,8 @@ static void usb_mtp_add_str(MTPData *data, const = char *str) > >> { > >> uint32_t len =3D strlen(str)+1; > >> wchar_t *wstr =3D g_malloc(sizeof(wchar_t) * len); > >> - size_t ret; > >> =20 > >> - ret =3D mbstowcs(wstr, str, len); > >> - if (ret =3D=3D -1) { > >> + if (mbstowcs(wstr, str, len) =3D=3D -1) { > >> usb_mtp_add_wstr(data, L"Oops"); > >> } else { > >> usb_mtp_add_wstr(data, wstr); > >> --=20 > >> 2.4.3 > >>=20 > >>=20 > > > > The old way has no problem, no need to clean up, IMO. >=20 > It's a very small readability improvement, but it's an improvement. If > I was the maintainer, I'd take it. Matter of taste, I find the version with ret more readable (not surprising given I wrote that code ;) It's easier to see what the "if (...)" condition is because the line is shorter. cheers, Gerd