From 3ba5d77f3c817cfe8029dba8212d96d3a98a5ff9 Mon Sep 17 00:00:00 2001 From: Matthias Bolte Date: Sun, 24 Apr 2011 11:48:00 +0200 Subject: [PATCH] Move call to virReportOOMError into virFileBuildPath Suggested by Daniel P. Berrange --- src/conf/nwfilter_conf.c | 5 +---- src/conf/storage_conf.c | 7 +------ src/util/util.c | 2 ++ src/xen/xen_inotify.c | 1 - src/xen/xm_internal.c | 5 +---- 5 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 327fab3134..09dc32b377 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2588,10 +2588,8 @@ virNWFilterLoadAllConfigs(virConnectPtr conn, if (!virFileHasSuffix(entry->d_name, ".xml")) continue; - if (!(path = virFileBuildPath(configDir, entry->d_name, NULL))) { - virReportOOMError(); + if (!(path = virFileBuildPath(configDir, entry->d_name, NULL))) continue; - } nwfilter = virNWFilterObjLoad(conn, nwfilters, entry->d_name, path); if (nwfilter) @@ -2627,7 +2625,6 @@ virNWFilterObjSaveDef(virNWFilterDriverStatePtr driver, if (!(nwfilter->configFile = virFileBuildPath(driver->configDir, def->name, ".xml"))) { - virReportOOMError(); return -1; } } diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 5a069f5404..116898d854 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1483,14 +1483,11 @@ virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools, if (!virFileHasSuffix(entry->d_name, ".xml")) continue; - if (!(path = virFileBuildPath(configDir, entry->d_name, NULL))) { - virReportOOMError(); + if (!(path = virFileBuildPath(configDir, entry->d_name, NULL))) continue; - } if (!(autostartLink = virFileBuildPath(autostartDir, entry->d_name, NULL))) { - virReportOOMError(); VIR_FREE(path); continue; } @@ -1529,13 +1526,11 @@ virStoragePoolObjSaveDef(virStorageDriverStatePtr driver, if (!(pool->configFile = virFileBuildPath(driver->configDir, def->name, ".xml"))) { - virReportOOMError(); return -1; } if (!(pool->autostartLink = virFileBuildPath(driver->autostartDir, def->name, ".xml"))) { - virReportOOMError(); VIR_FREE(pool->configFile); return -1; } diff --git a/src/util/util.c b/src/util/util.c index de4e3b33f7..1bb032824b 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -1829,10 +1829,12 @@ virFileBuildPath(const char *dir, const char *name, const char *ext) if (ext == NULL) { if (virAsprintf(&path, "%s/%s", dir, name) < 0) { + virReportOOMError(); return NULL; } } else { if (virAsprintf(&path, "%s/%s%s", dir, name, ext) < 0) { + virReportOOMError(); return NULL; } } diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c index d809c45489..9dde72cc22 100644 --- a/src/xen/xen_inotify.c +++ b/src/xen/xen_inotify.c @@ -415,7 +415,6 @@ xenInotifyOpen(virConnectPtr conn, /* Build the full file path */ if (!(path = virFileBuildPath(priv->configDir, ent->d_name, NULL))) { - virReportOOMError(); closedir(dh); return -1; } diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index db47a0206f..f9f52b5823 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -388,7 +388,6 @@ int xenXMConfigCacheRefresh (virConnectPtr conn) { /* Build the full file path */ if (!(path = virFileBuildPath(priv->configDir, ent->d_name, NULL))) { - virReportOOMError(); closedir(dh); return -1; } @@ -1134,10 +1133,8 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) entry = NULL; } - if (!(filename = virFileBuildPath(priv->configDir, def->name, NULL))) { - virReportOOMError(); + if (!(filename = virFileBuildPath(priv->configDir, def->name, NULL))) goto error; - } if (xenXMConfigSaveFile(conn, filename, def) < 0) goto error; -- GitLab