[Qemu-devel] [PATCH 3/3] opts: remove redundant check for NULL parameter

Daniel P. Berrangé posted 3 patches 7 years, 5 months ago
[Qemu-devel] [PATCH 3/3] opts: remove redundant check for NULL parameter
Posted by Daniel P. Berrangé 7 years, 5 months ago
No callers of get_opt_value() pass in a NULL for the "value" parameter,
so the check is redundant.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 util/qemu-option.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/util/qemu-option.c b/util/qemu-option.c
index 8a68bc2314..a1ff682aac 100644
--- a/util/qemu-option.c
+++ b/util/qemu-option.c
@@ -75,9 +75,7 @@ const char *get_opt_value(const char *p, char **value)
     size_t capacity = 0, length;
     const char *offset;
 
-    if (value) {
-        *value = NULL;
-    }
+    *value = NULL;
     while (1) {
         offset = strchr(p, ',');
         if (!offset) {
@@ -88,11 +86,9 @@ const char *get_opt_value(const char *p, char **value)
         if (*offset != '\0' && *(offset + 1) == ',') {
             length++;
         }
-        if (value) {
-            *value = g_renew(char, *value, capacity + length + 1);
-            strncpy(*value + capacity, p, length);
-            (*value)[capacity + length] = '\0';
-        }
+        *value = g_renew(char, *value, capacity + length + 1);
+        strncpy(*value + capacity, p, length);
+        (*value)[capacity + length] = '\0';
         capacity += length;
         if (*offset == '\0' ||
             *(offset + 1) != ',') {
-- 
2.17.0


Re: [Qemu-devel] [PATCH 3/3] opts: remove redundant check for NULL parameter
Posted by Eduardo Habkost 7 years, 3 months ago
On Mon, May 14, 2018 at 06:19:13PM +0100, Daniel P. Berrangé wrote:
> No callers of get_opt_value() pass in a NULL for the "value" parameter,
> so the check is redundant.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

Queueing on x86-next.

-- 
Eduardo