qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: pbonzini@redhat.com, Fam Zheng <famz@redhat.com>,
	qemu-devel@nongnu.org, Peter Xu <peterx@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/2] usb: trivial cleanup for usb_mtp_add_str
Date: Thu, 10 Mar 2016 08:42:33 +0100	[thread overview]
Message-ID: <1457595753.6405.8.camel@redhat.com> (raw)
In-Reply-To: <877fhax1uc.fsf@blackfin.pond.sub.org>

On Do, 2016-03-10 at 07:51 +0100, Markus Armbruster wrote:
> Fam Zheng <famz@redhat.com> writes:
> 
> > On Wed, 03/09 14:10, Peter Xu wrote:
> >> Remove useless var "ret".
> >> 
> >> Signed-off-by: Peter Xu <peterx@redhat.com>
> >> ---
> >>  hw/usb/dev-mtp.c | 4 +---
> >>  1 file changed, 1 insertion(+), 3 deletions(-)
> >> 
> >> 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 = strlen(str)+1;
> >>      wchar_t *wstr = g_malloc(sizeof(wchar_t) * len);
> >> -    size_t ret;
> >>  
> >> -    ret = mbstowcs(wstr, str, len);
> >> -    if (ret == -1) {
> >> +    if (mbstowcs(wstr, str, len) == -1) {
> >>          usb_mtp_add_wstr(data, L"Oops");
> >>      } else {
> >>          usb_mtp_add_wstr(data, wstr);
> >> -- 
> >> 2.4.3
> >> 
> >> 
> >
> > The old way has no problem, no need to clean up, IMO.
> 
> 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

      reply	other threads:[~2016-03-10  7:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-09  6:10 [Qemu-devel] [PATCH 0/2] usb: trivial fixes Peter Xu
2016-03-09  6:10 ` [Qemu-devel] [PATCH 1/2] usb: fix unbound stack usage for usb_mtp_add_str Peter Xu
2016-03-10  1:54   ` Fam Zheng
2016-03-10  2:25     ` Peter Xu
2016-03-09  6:10 ` [Qemu-devel] [PATCH 2/2] usb: trivial cleanup " Peter Xu
2016-03-10  1:56   ` Fam Zheng
2016-03-10  6:51     ` Markus Armbruster
2016-03-10  7:42       ` Gerd Hoffmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1457595753.6405.8.camel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=armbru@redhat.com \
    --cc=famz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).