qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, qemu-trivial@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qcow2: remove useless NULL check
Date: Wed, 8 Feb 2017 14:54:10 +0100	[thread overview]
Message-ID: <58a6feee-8828-d159-daf9-b460a6c0c7c4@redhat.com> (raw)
In-Reply-To: <20170208080900.4092-1-marcandre.lureau@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1144 bytes --]

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.

Max

>  
>      return qcow2_update_header(bs);
>  }
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 512 bytes --]

  parent reply	other threads:[~2017-02-08 13:54 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 [this message]
2017-02-08 14:00   ` Marc-André Lureau

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=58a6feee-8828-d159-daf9-b460a6c0c7c4@redhat.com \
    --to=mreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=marcandre.lureau@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).