From: "Marc-André Lureau" <mlureau@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
qemu-devel@nongnu.org, kwolf@redhat.com, qemu-trivial@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qcow2: remove useless NULL check
Date: Wed, 8 Feb 2017 09:00:37 -0500 (EST) [thread overview]
Message-ID: <1904417137.1617199.1486562437768.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <58a6feee-8828-d159-daf9-b460a6c0c7c4@redhat.com>
Hi
----- Original Message -----
> On 08.02.2017 09:09, Marc-André Lureau wrote:
> > g_strdup() already handles the case where the argument is NULL.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> > block/qcow2.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/block/qcow2.c b/block/qcow2.c
> > index 96fb8a8f16..9114218030 100644
> > --- a/block/qcow2.c
> > +++ b/block/qcow2.c
> > @@ -2016,8 +2016,8 @@ static int qcow2_change_backing_file(BlockDriverState
> > *bs,
> > g_free(s->image_backing_file);
> > g_free(s->image_backing_format);
> >
> > - s->image_backing_file = backing_file ? g_strdup(bs->backing_file) :
> > NULL;
> > - s->image_backing_format = backing_fmt ? g_strdup(bs->backing_format) :
> > NULL;
> > + s->image_backing_file = g_strdup(bs->backing_file);
> > + s->image_backing_format = g_strdup(bs->backing_format);
>
> bs->backing_file and bs->backing_format are arrays. They will never be NULL.
>
> The ternary operator tests backing_file and backing_fmt which instead
> are pointers. So this is not an equivalent conversion.
oops my bad, ignore ;P a bit uncommon code though, could deserve a comment.
>
> Max
>
> >
> > return qcow2_update_header(bs);
> > }
> >
>
>
>
prev parent reply other threads:[~2017-02-08 14:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-08 8:09 [Qemu-devel] [PATCH] qcow2: remove useless NULL check Marc-André Lureau
2017-02-08 13:53 ` Eric Blake
2017-02-08 13:54 ` Max Reitz
2017-02-08 14:00 ` Marc-André Lureau [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=1904417137.1617199.1486562437768.JavaMail.zimbra@redhat.com \
--to=mlureau@redhat.com \
--cc=kwolf@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@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).