qcow2: remove useless NULL check
PATCH 1/1 qcow2: remove useless NULL check
g_strdup() already handles the case where the argument is NULL.
--- block/qcow2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/qcow2.c +2 -2
@@ -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); }
Signature · 1 line
2.11.0.295.gd7dffce1c.dirty
Quoted 6 lines · Marc-André Lureau
g_strdup()already handles the case where the argument is NULL.Signed-off-by Marc-André Lureau <[email protected]>--- block/qcow2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 17 lines
block/qcow2.c +2
-2@@ -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); }
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Quoted 12 lines · Marc-André Lureau
g_strdup()already handles the case where the argument is NULL.Signed-off-by Marc-André Lureau <[email protected]>--- block/qcow2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)block/qcow2.c +0
-0
block/qcow2.c static int qcow2_change_backing_file(BlockDriverState *bs, · line 2020
Quoted 7 lines
block/qcow2.c +2
-2@@ -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
Quoted 4 lines
block/qcow2.c +0
-0return qcow2_update_header (bs); }
Hi
----- Original Message -----
Quoted 26 lines · Marc-André Lureau
Quoted 12 lines
g_strdup()already handles the case where the argument is NULL.Signed-off-by Marc-André Lureau <[email protected]>--- block/qcow2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)block/qcow2.c +0
-0block/qcow2.c static int qcow2_change_backing_file(BlockDriverState · line 2023
Quoted 10 lines
block/qcow2.c +2
-2@@ -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_fileandbs->backing_formatare arrays. They will never be NULL.
Quoted 2 lines
The ternary operator tests
backing_fileandbacking_fmtwhich instead are pointers. So this is not an equivalent conversion.
oops my bad, ignore ;P a bit uncommon code though, could deserve a comment.
Quoted 10 lines
Max
Quoted 4 lines
return qcow2_update_header(bs);}