(res == VIR_DRV_OPEN_DECLINED ? "DECLINED" :
(res == VIR_DRV_OPEN_ERROR ? "ERROR" : "unknown status")));
if (res == VIR_DRV_OPEN_ERROR) {
- if (0 && STREQ(virStorageDriverTab[i]->name, "remote")) {
+ if (STREQ(virStorageDriverTab[i]->name, "remote")) {
virLibConnWarning (NULL, VIR_WAR_NO_STORAGE,
"Is the daemon running ?");
}
#include "nodeinfo.h"
#include "virterror_internal.h"
#include "conf.h"
+#include "memory.h"
#include "logging.h"
/* Avoid error from non-existant or unreadable file. */
if (access (filename, R_OK) == -1)
- return 0;
+ goto done;
conf = virConfReadFile(filename, 0);
if (!conf)
- return 0;
+ goto done;
p = virConfGetValue(conf, "log_with_libvirtd");
if (p) {
}
virConfFree(conf);
+
+done:
+ VIR_FREE(filename);
return 0;
no_memory:
virReportSystemError(NULL, errno,
_("Failed to open tty %s"),
ttyPath);
+ VIR_FREE(ttyPath);
return -1;
}
VIR_FREE(ttyPath);
{
int rc = -1;
int control[2] = { -1, -1};
- int containerPty;
+ int containerPty = -1;
char *containerPtyPath;
pid_t container = -1;
virDomainFSDefPtr root;
goto cleanup;
}
- if (getuid() && 0) {
+ if (getuid() != 0) {
fprintf(stderr, "%s: must be run as the 'root' user\n", argv[0]);
goto cleanup;
}
{
char *bus_name = NULL;
virNodeDevCapsDefPtr caps = NULL;
- char **hal_cap_names;
+ char **hal_cap_names = NULL;
int rv, i;
if (STREQ(udi, "/org/freedesktop/Hal/devices/computer")) {
virNodeDeviceObjListFree(&driverState->devs);
if (hal_ctx)
(void)libhal_ctx_free(hal_ctx);
- if (udi) {
- for (i = 0; i < num_devs; i++)
- VIR_FREE(udi[i]);
- VIR_FREE(udi);
- }
nodeDeviceUnlock(driverState);
VIR_FREE(driverState);
const char* to) {
const char* offset = NULL;
const char* str_start = str;
- int to_len = strlen(to);
- int from_len = strlen(from);
+ int to_len;
+ int from_len;
virBuffer buf = VIR_BUFFER_INITIALIZER;
- if(!from)
+ if ((!from) || (!to))
return NULL;
+ from_len = strlen(from);
+ to_len = strlen(to);
while((offset = strstr(str_start, from)))
{
usleep(100*1000);
retries--;
}
- if (retries == 0)
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- _("Timed out while reading %s log output"), what);
+
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Timed out while reading %s log output"), what);
return -1;
}
newdisk->src = NULL;
origdisk->type = newdisk->type;
}
+ VIR_FREE(devname);
return ret;
}
if (priv->pid > 0) {
pid_t reap;
do {
+retry:
reap = waitpid(priv->pid, NULL, 0);
if (reap == -1 && errno == EINTR)
- continue;
+ goto retry;
} while (reap != -1 && reap != priv->pid);
}
#endif
if (priv->pid > 0) {
pid_t reap;
do {
+retry:
reap = waitpid(priv->pid, NULL, 0);
if (reap == -1 && errno == EINTR)
- continue;
+ goto retry;
} while (reap != -1 && reap != priv->pid);
}
#endif
* dir every time its run. Should figure out a more efficient
* way of doing this...
*/
- if ((vol->target.path = virStorageBackendStablePath(conn,
- pool,
- devpath)) == NULL)
- return -1;
-
+ vol->target.path = virStorageBackendStablePath(conn, pool, devpath);
VIR_FREE(devpath);
+ if (vol->target.path == NULL)
+ return -1;
}
if (vol->key == NULL) {
part_num = devname + strlen(srcname);
- if (!part_num) {
+ if (*part_num == 0) {
virStorageReportError(conn, VIR_ERR_INTERNAL_ERROR,
_("cannot parse partition number from target "
"'%s'"), devname);
backend->startPool(NULL, pool) < 0) {
virErrorPtr err = virGetLastError();
storageLog("Failed to autostart storage pool '%s': %s",
- pool->def->name, err ? err->message : NULL);
+ pool->def->name, err ? err->message :
+ "no error message found");
virStoragePoolObjUnlock(pool);
continue;
}
if (backend->stopPool)
backend->stopPool(NULL, pool);
storageLog("Failed to autostart storage pool '%s': %s",
- pool->def->name, err ? err->message : NULL);
+ pool->def->name, err ? err->message :
+ "no error message found");
virStoragePoolObjUnlock(pool);
continue;
}
}
mdup = strdup(match);
- if (dup == NULL) {
+ if (mdup == NULL) {
i = -1;
goto cleanup;
}
virLogLock();
if (VIR_REALLOC_N(virLogOutputs, virLogNbOutputs + 1)) {
+ VIR_FREE(ndup);
goto cleanup;
}
ret = virLogNbOutputs++;
for (token = strsep(&ptr, "/"); token; token = strsep(&ptr, "/")) {
const struct sexpr *i;
- if (token == NULL)
- continue;
-
sexpr = sexpr->u.s.cdr;
for (i = sexpr; i->kind != SEXPR_NIL; i = i->u.s.cdr) {
if (i->kind != SEXPR_CONS ||
goto no_memory;
}
- if (connectPort) {
- if (connectHost) {
- virBufferVSprintf(buf,
- " <source mode='connect' host='%s' service='%s'/>\n",
- connectHost, connectPort);
- } else {
- virBufferVSprintf(buf,
- " <source mode='connect' service='%s'/>\n",
- connectPort);
- }
+ if (connectHost) {
+ virBufferVSprintf(buf,
+ " <source mode='connect' host='%s' service='%s'/>\n",
+ connectHost, connectPort);
+ } else {
+ virBufferVSprintf(buf,
+ " <source mode='connect' service='%s'/>\n",
+ connectPort);
}
if (bindPort) {
if (bindHost) {
virHashRemoveSet(priv->configCache, xenXMConfigReaper, xenXMConfigFree, &args);
ret = 0;
- if (dh)
- closedir(dh);
+ closedir(dh);
return (ret);
}
if (xenXMConfigSetInt(conf, "vcpus", def->vcpus) < 0)
goto no_memory;
- if (def->cpumask &&
- !(cpus = virDomainCpuSetFormat(conn, def->cpumask, def->cpumasklen)) < 0)
+ if ((def->cpumask != NULL) &&
+ ((cpus = virDomainCpuSetFormat(conn, def->cpumask,
+ def->cpumasklen)) == NULL))
goto cleanup;
if (cpus &&