]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: fix NULL pointer check position
authorJán Tomko <jtomko@redhat.com>
Sun, 2 Aug 2020 20:50:37 +0000 (22:50 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 11 Aug 2020 19:49:54 +0000 (21:49 +0200)
src/bhyve/bhyve_parse_command.c:437:9: warning: Either the condition
'!config' is redundant or there is possible null pointer dereference:
config. [nullPointerRedundantCheck]

src/bhyve/bhyve_parse_command.c:280:23: warning: Either the condition
'!separator' is redundant or there is pointer arithmetic
with NULL pointer. [nullPointerArithmeticRedundantCheck]

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
src/bhyve/bhyve_parse_command.c

index b2d228087275b588aebc02e2a97eb2955da2e86c..5e9cf7ba13be655517581abe79fb47d84774d595 100644 (file)
@@ -277,11 +277,11 @@ bhyveParseBhyveLPCArg(virDomainDefPtr def,
     char *type = NULL;
 
     separator = strchr(arg, ',');
-    param = separator + 1;
 
     if (!separator)
         goto error;
 
+    param = separator + 1;
     type = g_strndup(arg, separator - arg);
 
     /* Only support com%d */
@@ -434,14 +434,14 @@ bhyveParsePCIDisk(virDomainDefPtr def,
     disk->info.addr.pci.slot = pcislot;
     disk->info.addr.pci.function = function;
 
+    if (!config)
+        goto error;
+
     if (STRPREFIX(config, "/dev/"))
         disk->src->type = VIR_STORAGE_TYPE_BLOCK;
     else
         disk->src->type = VIR_STORAGE_TYPE_FILE;
 
-    if (!config)
-        goto error;
-
     separator = strchr(config, ',');
     if (separator)
         disk->src->path = g_strndup(config, separator - config);