{
virStoragePoolPtr pool;
const char *from = NULL;
- bool ret = true;
g_autofree char *buffer = NULL;
bool build;
bool overwrite;
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
return false;
- pool = virStoragePoolCreateXML(priv->conn, buffer, flags);
-
- if (pool != NULL) {
- vshPrintExtra(ctl, _("Pool %s created from %s\n"),
- virStoragePoolGetName(pool), from);
- virStoragePoolFree(pool);
- } else {
+ if (!(pool = virStoragePoolCreateXML(priv->conn, buffer, flags))) {
vshError(ctl, _("Failed to create pool from %s"), from);
- ret = false;
+ return false;
}
- return ret;
+
+ vshPrintExtra(ctl, _("Pool %s created from %s\n"),
+ virStoragePoolGetName(pool), from);
+ virStoragePoolFree(pool);
+ return true;
}
static const vshCmdOptDef opts_pool_define_as[] = {
if (printXML) {
vshPrint(ctl, "%s", xml);
- } else {
- pool = virStoragePoolCreateXML(priv->conn, xml, flags);
+ return true;
+ }
- if (pool != NULL) {
- vshPrintExtra(ctl, _("Pool %s created\n"), name);
- virStoragePoolFree(pool);
- } else {
- vshError(ctl, _("Failed to create pool %s"), name);
- return false;
- }
+ if (!(pool = virStoragePoolCreateXML(priv->conn, xml, flags))) {
+ vshError(ctl, _("Failed to create pool %s"), name);
+ return false;
}
+
+ vshPrintExtra(ctl, _("Pool %s created\n"), name);
+ virStoragePoolFree(pool);
return true;
}
{
virStoragePoolPtr pool;
const char *from = NULL;
- bool ret = true;
g_autofree char *buffer = NULL;
unsigned int flags = 0;
virshControl *priv = ctl->privData;
if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0)
return false;
- pool = virStoragePoolDefineXML(priv->conn, buffer, flags);
-
- if (pool != NULL) {
- vshPrintExtra(ctl, _("Pool %s defined from %s\n"),
- virStoragePoolGetName(pool), from);
- virStoragePoolFree(pool);
- } else {
+ if (!(pool = virStoragePoolDefineXML(priv->conn, buffer, flags))) {
vshError(ctl, _("Failed to define pool from %s"), from);
- ret = false;
+ return false;
}
- return ret;
+
+ vshPrintExtra(ctl, _("Pool %s defined from %s\n"),
+ virStoragePoolGetName(pool), from);
+ virStoragePoolFree(pool);
+ return true;
}
/*
if (printXML) {
vshPrint(ctl, "%s", xml);
- } else {
- pool = virStoragePoolDefineXML(priv->conn, xml, 0);
+ return true;
+ }
- if (pool != NULL) {
- vshPrintExtra(ctl, _("Pool %s defined\n"), name);
- virStoragePoolFree(pool);
- } else {
- vshError(ctl, _("Failed to define pool %s"), name);
- return false;
- }
+ if (!(pool = virStoragePoolDefineXML(priv->conn, xml, 0))) {
+ vshError(ctl, _("Failed to define pool %s"), name);
+ return false;
}
+
+ vshPrintExtra(ctl, _("Pool %s defined\n"), name);
+ virStoragePoolFree(pool);
return true;
}