thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-opts-remove-redundant-check-for-NULL-parameter.patch

Pablo Greco e6a3ae
From 1906ff6940bb9f84f0f6a66980354e66b5124558 Mon Sep 17 00:00:00 2001
Pablo Greco e6a3ae
From: Laszlo Ersek <lersek@redhat.com>
Pablo Greco e6a3ae
Date: Thu, 12 Sep 2019 13:05:03 +0100
Pablo Greco e6a3ae
Subject: [PATCH 06/22] opts: remove redundant check for NULL parameter
Pablo Greco e6a3ae
MIME-Version: 1.0
Pablo Greco e6a3ae
Content-Type: text/plain; charset=UTF-8
Pablo Greco e6a3ae
Content-Transfer-Encoding: 8bit
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RH-Author: Laszlo Ersek <lersek@redhat.com>
Pablo Greco e6a3ae
Message-id: <20190912130503.14094-7-lersek@redhat.com>
Pablo Greco e6a3ae
Patchwork-id: 90432
Pablo Greco e6a3ae
O-Subject: [RHEL-8.2.0 qemu-kvm PATCH 6/6] opts: remove redundant check for NULL parameter
Pablo Greco e6a3ae
Bugzilla: 1749022
Pablo Greco e6a3ae
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
From: Daniel P. Berrangé <berrange@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
No callers of get_opt_value() pass in a NULL for the "value" parameter,
Pablo Greco e6a3ae
so the check is redundant.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RHEL8 notes:
Pablo Greco e6a3ae
Pablo Greco e6a3ae
- Context difference in "util/qemu-option.c", function get_opt_value();
Pablo Greco e6a3ae
  upstream has commit 5c99fa375da1 ("cutils: Provide strchrnul",
Pablo Greco e6a3ae
  2018-06-29), part of v3.0.0, but downstream lacks it. Harmless, because
Pablo Greco e6a3ae
  said upstream commit only refactors get_opt_value().
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Pablo Greco e6a3ae
Message-Id: <20180514171913.17664-4-berrange@redhat.com>
Pablo Greco e6a3ae
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Pablo Greco e6a3ae
Tested-by: Roman Kagan <rkagan@virtuozzo.com>
Pablo Greco e6a3ae
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Pablo Greco e6a3ae
(cherry picked from commit 0c2f6e7ee99517449b4ed6cf333c2d9456d8fe35)
Pablo Greco e6a3ae
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Pablo Greco e6a3ae
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
---
Pablo Greco e6a3ae
 util/qemu-option.c | 12 ++++--------
Pablo Greco e6a3ae
 1 file changed, 4 insertions(+), 8 deletions(-)
Pablo Greco e6a3ae
Pablo Greco e6a3ae
diff --git a/util/qemu-option.c b/util/qemu-option.c
Pablo Greco e6a3ae
index a396d60..940f7a3 100644
Pablo Greco e6a3ae
--- a/util/qemu-option.c
Pablo Greco e6a3ae
+++ b/util/qemu-option.c
Pablo Greco e6a3ae
@@ -75,9 +75,7 @@ const char *get_opt_value(const char *p, char **value)
Pablo Greco e6a3ae
     size_t capacity = 0, length;
Pablo Greco e6a3ae
     const char *offset;
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
-    if (value) {
Pablo Greco e6a3ae
-        *value = NULL;
Pablo Greco e6a3ae
-    }
Pablo Greco e6a3ae
+    *value = NULL;
Pablo Greco e6a3ae
     while (1) {
Pablo Greco e6a3ae
         offset = strchr(p, ',');
Pablo Greco e6a3ae
         if (!offset) {
Pablo Greco e6a3ae
@@ -88,11 +86,9 @@ const char *get_opt_value(const char *p, char **value)
Pablo Greco e6a3ae
         if (*offset != '\0' && *(offset + 1) == ',') {
Pablo Greco e6a3ae
             length++;
Pablo Greco e6a3ae
         }
Pablo Greco e6a3ae
-        if (value) {
Pablo Greco e6a3ae
-            *value = g_renew(char, *value, capacity + length + 1);
Pablo Greco e6a3ae
-            strncpy(*value + capacity, p, length);
Pablo Greco e6a3ae
-            (*value)[capacity + length] = '\0';
Pablo Greco e6a3ae
-        }
Pablo Greco e6a3ae
+        *value = g_renew(char, *value, capacity + length + 1);
Pablo Greco e6a3ae
+        strncpy(*value + capacity, p, length);
Pablo Greco e6a3ae
+        (*value)[capacity + length] = '\0';
Pablo Greco e6a3ae
         capacity += length;
Pablo Greco e6a3ae
         if (*offset == '\0' ||
Pablo Greco e6a3ae
             *(offset + 1) != ',') {
Pablo Greco e6a3ae
-- 
Pablo Greco e6a3ae
1.8.3.1
Pablo Greco e6a3ae