[libvirt] [PATCH] conf: Remove unnecessary @ctxt check in virSecurityLabelDefsParseXML

John Ferlan posted 1 patch 5 years, 1 month ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20190307162518.9925-1-jferlan@redhat.com
src/conf/domain_conf.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[libvirt] [PATCH] conf: Remove unnecessary @ctxt check in virSecurityLabelDefsParseXML
Posted by John Ferlan 5 years, 1 month ago
Failure would have occurred before in callers other virXPath calls.

Found by Coverity due to commit 66a508d2 using VIR_XPATH_NODE_AUTORESTORE
to access @ctxt before the if condition.

Signed-off-by: John Ferlan <jferlan@redhat.com>
---
 src/conf/domain_conf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index eb660f5764..dc57b23084 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8516,8 +8516,7 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def,
     virCapsHostPtr host = &caps->host;
     VIR_AUTOFREE(xmlNodePtr *) list = NULL;
 
-    /* Check args and save context */
-    if (def == NULL || ctxt == NULL)
+    if (def == NULL)
         return 0;
 
     /* Allocate a security labels based on XML */
-- 
2.20.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] conf: Remove unnecessary @ctxt check in virSecurityLabelDefsParseXML
Posted by Ján Tomko 5 years, 1 month ago
s/@ctxt check/checks/

On Thu, Mar 07, 2019 at 11:25:18AM -0500, John Ferlan wrote:
>Failure would have occurred before in callers other virXPath calls.
>
>Found by Coverity due to commit 66a508d2 using VIR_XPATH_NODE_AUTORESTORE
>to access @ctxt before the if condition.
>
>Signed-off-by: John Ferlan <jferlan@redhat.com>
>---
> src/conf/domain_conf.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
>diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
>index eb660f5764..dc57b23084 100644
>--- a/src/conf/domain_conf.c
>+++ b/src/conf/domain_conf.c
>@@ -8516,8 +8516,7 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def,
>     virCapsHostPtr host = &caps->host;
>     VIR_AUTOFREE(xmlNodePtr *) list = NULL;
>
>-    /* Check args and save context */
>-    if (def == NULL || ctxt == NULL)
>+    if (def == NULL)
>         return 0;
>

Both now and at the point of its introduction in:
commit e9377dda367b847b5a15dac1403bcdf19f05438a
    Multiple security drivers in XML data

def is dereferenced right before its only caller
so you can delete the whole condition.

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list