This cannot ever return NULL Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- src/bhyve/bhyve_driver.c | 6 ++---- src/conf/domain_conf.c | 7 ++----- src/conf/virdomainobjlist.c | 9 +++------ src/libxl/libxl_driver.c | 6 ++---- src/lxc/lxc_controller.c | 4 +--- src/lxc/lxc_driver.c | 10 ++-------- src/qemu/qemu_driver.c | 22 ++++++---------------- 7 files changed, 18 insertions(+), 46 deletions(-) diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 2bd1e4c387..8f97ac032c 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -364,10 +364,8 @@ bhyveDomainSetAutostart(virDomainPtr domain, int autostart) autostart = (autostart != 0); if (vm->autostart != autostart) { - if ((configFile = virDomainConfigFile(BHYVE_CONFIG_DIR, vm->def->name)) == NULL) - goto cleanup; - if ((autostartLink = virDomainConfigFile(BHYVE_AUTOSTART_DIR, vm->def->name)) == NULL) - goto cleanup; + configFile = virDomainConfigFile(BHYVE_CONFIG_DIR, vm->def->name); + autostartLink = virDomainConfigFile(BHYVE_AUTOSTART_DIR, vm->def->name); if (autostart) { if (g_mkdir_with_parents(BHYVE_AUTOSTART_DIR, 0777) < 0) { diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4ad8289b89..cae5ba9df1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29060,11 +29060,8 @@ virDomainDeleteConfig(const char *configDir, g_autofree char *configFile = NULL; g_autofree char *autostartLink = NULL; - if ((configFile = virDomainConfigFile(configDir, dom->def->name)) == NULL) - return -1; - if ((autostartLink = virDomainConfigFile(autostartDir, - dom->def->name)) == NULL) - return -1; + configFile = virDomainConfigFile(configDir, dom->def->name); + autostartLink = virDomainConfigFile(autostartDir, dom->def->name); /* Not fatal if this doesn't work */ unlink(autostartLink); diff --git a/src/conf/virdomainobjlist.c b/src/conf/virdomainobjlist.c index 166bbc5cfd..72207450c5 100644 --- a/src/conf/virdomainobjlist.c +++ b/src/conf/virdomainobjlist.c @@ -492,16 +492,14 @@ virDomainObjListLoadConfig(virDomainObjList *doms, int autostart; g_autoptr(virDomainDef) oldDef = NULL; - if ((configFile = virDomainConfigFile(configDir, name)) == NULL) - return NULL; + configFile = virDomainConfigFile(configDir, name); if (!(def = virDomainDefParseFile(configFile, xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE | VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE | VIR_DOMAIN_DEF_PARSE_ALLOW_POST_PARSE_FAIL))) return NULL; - if ((autostartLink = virDomainConfigFile(autostartDir, name)) == NULL) - return NULL; + autostartLink = virDomainConfigFile(autostartDir, name); autostart = virFileLinkPointsTo(autostartLink, configFile); @@ -529,8 +527,7 @@ virDomainObjListLoadStatus(virDomainObjList *doms, virDomainObj *obj = NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; - if ((statusFile = virDomainConfigFile(statusDir, name)) == NULL) - goto error; + statusFile = virDomainConfigFile(statusDir, name); if (!(obj = virDomainObjParseFile(statusFile, xmlopt, VIR_DOMAIN_DEF_PARSE_STATUS | diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index e72553603d..b8f721351c 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -4651,10 +4651,8 @@ libxlDomainSetAutostart(virDomainPtr dom, int autostart) autostart = (autostart != 0); if (vm->autostart != autostart) { - if (!(configFile = virDomainConfigFile(cfg->configDir, vm->def->name))) - goto endjob; - if (!(autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name))) - goto endjob; + configFile = virDomainConfigFile(cfg->configDir, vm->def->name); + autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name); if (autostart) { if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) { diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 7b432a1160..fb7f8e0bc2 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -196,9 +196,7 @@ static virLXCController *virLXCControllerNew(const char *name) if (!(driver = virLXCControllerDriverNew())) goto error; - if ((configFile = virDomainConfigFile(LXC_STATE_DIR, - ctrl->name)) == NULL) - goto error; + configFile = virDomainConfigFile(LXC_STATE_DIR, ctrl->name); if ((ctrl->vm = virDomainObjParseFile(configFile, driver->xmlopt, diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 2488940feb..b1a355794c 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2430,14 +2430,8 @@ static int lxcDomainSetAutostart(virDomainPtr dom, goto endjob; } - configFile = virDomainConfigFile(cfg->configDir, - vm->def->name); - if (configFile == NULL) - goto endjob; - autostartLink = virDomainConfigFile(cfg->autostartDir, - vm->def->name); - if (autostartLink == NULL) - goto endjob; + configFile = virDomainConfigFile(cfg->configDir, vm->def->name); + autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name); if (autostart) { if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) { diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 672b42b44e..72d6b627f9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7784,12 +7784,8 @@ static int qemuDomainSetAutostart(virDomainPtr dom, if (virDomainObjBeginJob(vm, VIR_JOB_MODIFY) < 0) goto cleanup; - if (!(configFile = virDomainConfigFile(cfg->configDir, vm->def->name))) - goto endjob; - - if (!(autostartLink = virDomainConfigFile(cfg->autostartDir, - vm->def->name))) - goto endjob; + configFile = virDomainConfigFile(cfg->configDir, vm->def->name); + autostartLink = virDomainConfigFile(cfg->autostartDir, vm->def->name); if (autostart) { if (g_mkdir_with_parents(cfg->autostartDir, 0777) < 0) { @@ -18339,21 +18335,15 @@ qemuDomainRenameCallback(virDomainObj *vm, new_dom_name = g_strdup(new_name); - if (!(new_dom_cfg_file = virDomainConfigFile(cfg->configDir, - new_dom_name)) || - !(old_dom_cfg_file = virDomainConfigFile(cfg->configDir, - vm->def->name))) - return -1; + new_dom_cfg_file = virDomainConfigFile(cfg->configDir, new_dom_name); + old_dom_cfg_file = virDomainConfigFile(cfg->configDir, vm->def->name); if (qemuDomainNamePathsCleanup(cfg, new_name, false) < 0) goto cleanup; if (vm->autostart) { - if (!(new_dom_autostart_link = virDomainConfigFile(cfg->autostartDir, - new_dom_name)) || - !(old_dom_autostart_link = virDomainConfigFile(cfg->autostartDir, - vm->def->name))) - return -1; + new_dom_autostart_link = virDomainConfigFile(cfg->autostartDir, new_dom_name); + old_dom_autostart_link = virDomainConfigFile(cfg->autostartDir, vm->def->name); if (symlink(new_dom_cfg_file, new_dom_autostart_link) < 0) { virReportSystemError(errno, -- 2.46.0