From a16871fef7fd342ab5164dddec820a8b9c645b5e Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Tue, 4 Aug 2015 06:50:29 -0400 Subject: [PATCH] conf: Resolve Coverity FORWARD_NULL The recent changes to perform SCSI device address checks during the post parse callbacks ran afoul of the Coverity checker since the changes assumed that the 'xmlopt' parameter to virDomainDeviceDefPostParse would be non NULL (commit id 'ca2cf74e87'); however, what was missed is there was an "if (xmlopt &&" check being made, so Coverity believed that it could be possible for a NULL 'xmlopt'. Checking the various calling paths seemingly disproves that. If called from virDomainDeviceDefParse, there were two other possible calls that would end up dereffing, so that path could not be NULL. If called via virDomainDefPostParseDeviceIterator via virDomainDefPostParse there are two callers (virDomainDefParseXML and qemuParseCommandLine) which deref xmlopt either directly or through another call. So I'm removing the check for non-NULL xmlopt. --- src/conf/domain_conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ab96354edc..5eaeb21806 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4145,7 +4145,7 @@ virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, { int ret; - if (xmlopt && xmlopt->config.devicesPostParseCallback) { + if (xmlopt->config.devicesPostParseCallback) { ret = xmlopt->config.devicesPostParseCallback(dev, def, caps, xmlopt->config.priv); if (ret < 0) @@ -4190,7 +4190,7 @@ virDomainDefPostParse(virDomainDefPtr def, }; /* call the domain config callback */ - if (xmlopt && xmlopt->config.domainPostParseCallback) { + if (xmlopt->config.domainPostParseCallback) { ret = xmlopt->config.domainPostParseCallback(def, caps, xmlopt->config.priv); if (ret < 0)