Skip to contentSkip to conversation

util/error: Remove an unnecessary NULL check

PATCH In review Philippe Mathieu-Daudé 4 participants 5 messages Dec 7, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 util/error: Remove an unnecessary NULL check

This NULL check was required while introduced in 680d16dcb79f. Later refactor added a NULL check in error_setv(), so this check is now redundant.

---
 util/error.c | 4 ----
 1 file changed, 4 deletions(-)
util/error.c +0 -4
index b5ccbd8eac..934a78e1b1 100644
@@ -103,10 +103,6 @@ void error_setg_errno_internal(Error **errp,
     va_list ap;
     int saved_errno = errno;
 
-    if (errp == NULL) {
-        return;
-    }
-
     va_start(ap, fmt);
     error_setv(errp, src, line, func, ERROR_CLASS_GENERIC_ERROR, fmt, ap,
                os_errno != 0 ? strerror(os_errno) : NULL);
Signature · 1 line
2.17.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Philippe Mathieu-Daudé

This NULL check was required while introduced in 680d16dcb79f. Later refactor added a NULL check in error_setv(), so this check is now redundant.

---
 util/error.c | 4 ----
 1 file changed, 4 deletions(-)

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 14 lines · Philippe Mathieu-Daudé

This NULL check was required while introduced in 680d16dcb79f. Later refactor added a NULL check in error_setv(), so this check is now redundant.

---
 util/error.c | 4 ----
 1 file changed, 4 deletions(-)
util/error.c +0 -0
index b5ccbd8eac..934a78e1b1 100644

util/error.c void error_setg_errno_internal(Error **errp, · line 104

Quoted 2 lines
util/error.c +0 -0
@@ -103,10 +103,6 @@ void error_setg_errno_internal(Error **errp,
     va_list ap;
     int saved_errno = errno;

Could the saved_errno now be removed, too, since err_setv does that again?

Thomas

Quoted 8 lines
util/error.c +0 -4
-    if (errp == NULL) {
-        return;
-    }
-
     va_start(ap, fmt);
     error_setv(errp, src, line, func, ERROR_CLASS_GENERIC_ERROR, fmt, ap,
                os_errno != 0 ? strerror(os_errno) : NULL);
 
#4 lore raw
Quoted 10 lines · Thomas Huth
Quoted 9 lines · Philippe Mathieu-Daudé

This NULL check was required while introduced in 680d16dcb79f. Later refactor added a NULL check in error_setv(), so this check is now redundant.

---
 util/error.c | 4 ----
 1 file changed, 4 deletions(-)
Quoted 9 lines

util/error.c void error_setg_errno_internal(Error **errp, · line 104

Quoted 7 lines
util/error.c +0 -0
index b5ccbd8eac..934a78e1b1 100644
@@ -103,10 +103,6 @@ void error_setg_errno_internal(Error **errp,
     va_list ap;
     int saved_errno = errno;

Could the saved_errno now be removed, too, since err_setv does that again?

Yes, good idea, I'll send another patch.

Quoted 14 lines

Thomas

Quoted 8 lines
util/error.c +0 -4
-    if (errp == NULL) {
-        return;
-    }
-
     va_start(ap, fmt);
     error_setv(errp, src, line, func, ERROR_CLASS_GENERIC_ERROR, fmt, ap,
                os_errno != 0 ? strerror(os_errno) : NULL);