* [Qemu-devel] [PATCH] qcow2: remove useless NULL check
@ 2017-02-08 8:09 Marc-André Lureau
2017-02-08 13:53 ` Eric Blake
2017-02-08 13:54 ` Max Reitz
0 siblings, 2 replies; 4+ messages in thread
From: Marc-André Lureau @ 2017-02-08 8:09 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, qemu-trivial, Marc-André Lureau
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);
return qcow2_update_header(bs);
}
--
2.11.0.295.gd7dffce1c.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] qcow2: remove useless NULL check
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
1 sibling, 0 replies; 4+ messages in thread
From: Eric Blake @ 2017-02-08 13:53 UTC (permalink / raw)
To: Marc-André Lureau, qemu-devel; +Cc: kwolf, qemu-trivial
[-- Attachment #1: Type: text/plain, Size: 1085 bytes --]
On 02/08/2017 02:09 AM, 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(-)
Reviewed-by: Eric Blake <eblake@redhat.com>
>
> 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);
>
> return qcow2_update_header(bs);
> }
>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] qcow2: remove useless NULL check
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
1 sibling, 1 reply; 4+ messages in thread
From: Max Reitz @ 2017-02-08 13:54 UTC (permalink / raw)
To: Marc-André Lureau, qemu-devel; +Cc: kwolf, qemu-trivial
[-- 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 --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] qcow2: remove useless NULL check
2017-02-08 13:54 ` Max Reitz
@ 2017-02-08 14:00 ` Marc-André Lureau
0 siblings, 0 replies; 4+ messages in thread
From: Marc-André Lureau @ 2017-02-08 14:00 UTC (permalink / raw)
To: Max Reitz; +Cc: Marc-André Lureau, qemu-devel, kwolf, qemu-trivial
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);
> > }
> >
>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-02-08 14:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.