memcpy(&(ret->uuid[0]), uuid, VIR_UUID_BUFLEN);
ret->usageType = usageType;
- if (VIR_STRDUP(ret->usageID, usageID ? usageID : "") < 0)
+ if (VIR_STRDUP(ret->usageID, NULLSTR_EMPTY(usageID)) < 0)
goto error;
ret->conn = virObjectRef(conn);
virReportError(netcf_to_vir_err(errcode),
_("couldn't find interface named '%s': %s%s%s"),
ifinfo->name, errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
} else {
virReportError(VIR_ERR_NO_INTERFACE,
_("couldn't find interface named '%s'"),
virReportError(netcf_to_vir_err(errcode),
_("failed to get status of interface %s: %s%s%s"),
ncf_if_name(iface), errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
goto cleanup;
}
virReportError(netcf_to_vir_err(errcode),
_("failed to get number of host interfaces: %s%s%s"),
errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
goto cleanup;
}
virReportError(netcf_to_vir_err(errcode),
_("failed to list host interfaces: %s%s%s"),
errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
goto cleanup;
}
virReportError(netcf_to_vir_err(errcode),
_("couldn't find interface named '%s': %s%s%s"),
names[i], errmsg,
- details ? " - " : "", details ? details : "");
+ details ? " - " : "", NULLSTR_EMPTY(details));
goto cleanup;
} else {
/* Ignore the NETCF_NOERROR, as the interface is very likely
virReportError(netcf_to_vir_err(errcode),
_("failed to get number of host interfaces: %s%s%s"),
errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
goto cleanup;
}
virReportError(netcf_to_vir_err(errcode),
_("failed to list host interfaces: %s%s%s"),
errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
goto cleanup;
}
virReportError(netcf_to_vir_err(errcode),
_("couldn't find interface named '%s': %s%s%s"),
allnames[i], errmsg,
- details ? " - " : "", details ? details : "");
+ details ? " - " : "", NULLSTR_EMPTY(details));
goto cleanup;
} else {
/* Ignore the NETCF_NOERROR, as the interface is very likely
virReportError(netcf_to_vir_err(errcode),
_("failed to get number of host interfaces: %s%s%s"),
errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
goto cleanup;
}
virReportError(netcf_to_vir_err(errcode),
_("failed to list host interfaces: %s%s%s"),
errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
goto cleanup;
}
virReportError(netcf_to_vir_err(errcode),
_("couldn't find interface named '%s': %s%s%s"),
names[i], errmsg,
- details ? " - " : "", details ? details : "");
+ details ? " - " : "", NULLSTR_EMPTY(details));
goto cleanup;
} else {
/* Ignore the NETCF_NOERROR, as the interface is very likely
virReportError(netcf_to_vir_err(errcode),
_("couldn't find interface named '%s': %s%s%s"),
name, errmsg,
- details ? " - " : "", details ? details : "");
+ details ? " - " : "", NULLSTR_EMPTY(details));
} else {
virReportError(VIR_ERR_NO_INTERFACE,
_("couldn't find interface named '%s'"), name);
virReportError(netcf_to_vir_err(errcode),
_("couldn't find interface with MAC address '%s': %s%s%s"),
macstr, errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
goto cleanup;
}
if (niface == 0) {
virReportError(netcf_to_vir_err(errcode),
_("could not get interface XML description: %s%s%s"),
errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
goto cleanup;
}
virReportError(netcf_to_vir_err(errcode),
_("could not get interface XML description: %s%s%s"),
errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
goto cleanup;
}
virReportError(netcf_to_vir_err(errcode),
_("failed to undefine interface %s: %s%s%s"),
ifinfo->name, errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
goto cleanup;
}
virReportError(netcf_to_vir_err(errcode),
_("failed to create (start) interface %s: %s%s%s"),
ifinfo->name, errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
goto cleanup;
}
virReportError(netcf_to_vir_err(errcode),
_("failed to destroy (stop) interface %s: %s%s%s"),
ifinfo->name, errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
goto cleanup;
}
virReportError(netcf_to_vir_err(errcode),
_("failed to begin transaction: %s%s%s"),
errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
}
virObjectUnlock(driver);
virReportError(netcf_to_vir_err(errcode),
_("failed to commit transaction: %s%s%s"),
errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
}
virObjectUnlock(driver);
virReportError(netcf_to_vir_err(errcode),
_("failed to rollback transaction: %s%s%s"),
errmsg, details ? " - " : "",
- details ? details : "");
+ NULLSTR_EMPTY(details));
}
virObjectUnlock(driver);
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Invalid URI path '%s', try '/system'"),
- uri->path ? uri->path : "");
+ NULLSTR_EMPTY(uri->path));
goto error;
}
}
goto failed;
VIR_DEBUG("%s driver URI probe returned '%s'",
virConnectDriverTab[i]->hypervisorDriver->name,
- uristr ? uristr : "");
+ NULLSTR_EMPTY(uristr));
}
}
}
/* XXX should we support gid=X for X!=5 for distros which use
* a different gid for tty? */
if (virAsprintf(&opts, "newinstance,ptmxmode=0666,mode=0620,gid=%u%s",
- ptsgid, (mount_options ? mount_options : "")) < 0)
+ ptsgid, NULLSTR_EMPTY(mount_options)) < 0)
goto cleanup;
VIR_DEBUG("Mount devpts on %s type=tmpfs flags=0x%x, opts=%s",
virReportError(VIR_ERR_INTERNAL_ERROR,
_("virNWFilterSnoopReqNew called with invalid "
"key \"%s\" (%zu)"),
- ifkey ? ifkey : "",
+ NULLSTR_EMPTY(ifkey),
ifkey ? strlen(ifkey) : 0);
return NULL;
}
virMacAddrFormat(&net->mac, macaddr),
net->info.alias,
(net->model ? ",model=" : ""),
- (net->model ? net->model : ""),
+ NULLSTR_EMPTY(net->model),
(net->info.alias ? ",id=" : ""),
- (net->info.alias ? net->info.alias : "")));
+ NULLSTR_EMPTY(net->info.alias)));
return str;
}
case VIR_DOMAIN_NET_TYPE_SERVER:
virBufferAsprintf(&buf, "socket,listen=%s:%d,",
- net->data.socket.address ? net->data.socket.address
- : "",
+ NULLSTR_EMPTY(net->data.socket.address),
net->data.socket.port);
break;
if (cpu) {
virCommandAddArg(cmd, "-cpu");
- virCommandAddArgFormat(cmd, "%s%s", cpu, cpu_flags ? cpu_flags : "");
+ virCommandAddArgFormat(cmd, "%s%s", cpu, NULLSTR_EMPTY(cpu_flags));
}
ret = 0;
virCommandAddArg(cmd, qemucmd->args[i]);
for (i = 0; i < qemucmd->num_env; i++)
virCommandAddEnvPair(cmd, qemucmd->env_name[i],
- qemucmd->env_value[i]
- ? qemucmd->env_value[i] : "");
+ NULLSTR_EMPTY(qemucmd->env_value[i]));
}
if (qemuBuildSeccompSandboxCommandLine(cmd, cfg, qemuCaps) < 0)
virReportError(VIR_ERR_INTERNAL_ERROR,
_("%s: failed to communicate with bridge helper: %s%s"),
cmdstr, virStrerror(errno, ebuf, sizeof(ebuf)),
- errstr ? errstr : "");
+ NULLSTR_EMPTY(errstr));
VIR_FREE(errstr);
goto cleanup;
}
*tlsAlias) < 0 ||
qemuMigrationParamsSetString(migParams,
QEMU_MIGRATION_PARAM_TLS_HOSTNAME,
- hostname ? hostname : "") < 0)
+ NULLSTR_EMPTY(hostname)) < 0)
goto error;
ret = 0;
const char *data;
data = virJSONValueGetString(obj);
- if (VIR_STRDUP(*reply_str, data ? data : "") < 0)
+ if (VIR_STRDUP(*reply_str, NULLSTR_EMPTY(data)) < 0)
goto cleanup;
}
(qemuVersion / 1000000) % 1000,
(qemuVersion / 1000) % 1000,
qemuVersion % 1000,
- package ? package : "",
+ NULLSTR_EMPTY(package),
uts.release,
- hostname ? hostname : "") < 0)
+ NULLSTR_EMPTY(hostname)) < 0)
goto cleanup;
if (cmd) {
if (virAsprintf(path, "%s%s/%s",
group->legacy[controller].mountPoint,
group->legacy[controller].placement,
- key ? key : "") < 0)
+ NULLSTR_EMPTY(key)) < 0)
return -1;
return 0;
if (virAsprintf(path, "%s%s/%s",
group->unified.mountPoint,
group->unified.placement,
- key ? key : "") < 0)
+ NULLSTR_EMPTY(key)) < 0)
return -1;
return 0;
VIR_DEBUG("profile:'%p' vmOp: %s device: %s@%s mac: %s uuid: %s",
virtPort, virNetDevVPortProfileOpTypeToString(vmOp),
- (macvtap_ifname ? macvtap_ifname : ""), linkdev,
+ NULLSTR_EMPTY(macvtap_ifname), linkdev,
(macvtap_macaddr
? virMacAddrFormat(macvtap_macaddr, macStr)
: "(unspecified)"),
VIR_DEBUG("profile:'%p' vmOp: %s device: %s@%s mac: %s",
virtPort, virNetDevVPortProfileOpTypeToString(vmOp),
- (macvtap_ifname ? macvtap_ifname : ""), linkdev,
+ NULLSTR_EMPTY(macvtap_ifname), linkdev,
(macvtap_macaddr
? virMacAddrFormat(macvtap_macaddr, macStr)
: "(unspecified)"));
/* We are aiming at overall system info */
ret = virAsprintf(path,
HUGEPAGES_SYSTEM_PREFIX HUGEPAGES_PREFIX "%ukB/%s",
- page_size, suffix ? suffix : "");
+ page_size, NULLSTR_EMPTY(suffix));
} else {
/* We are aiming on specific NUMA node */
ret = virAsprintf(path,
HUGEPAGES_NUMA_PREFIX "node%d/hugepages/"
HUGEPAGES_PREFIX "%ukB/%s",
- node, page_size, suffix ? suffix : "");
+ node, page_size, NULLSTR_EMPTY(suffix));
}
if (ret >= 0 && !virFileExists(*path)) {
{
char *ret;
- if (VIR_STRDUP(ret, path ? path : "") < 0)
+ if (VIR_STRDUP(ret, NULLSTR_EMPTY(path)) < 0)
return NULL;
virFileRemoveLastComponent(ret);
creatorname,
iscontainer ? "container" : "vm",
(unsigned int)pidleader,
- rootdir ? rootdir : "",
+ NULLSTR_EMPTY(rootdir),
nnicindexes, nicindexes,
3,
"Slice", "s", slicename,
creatorname,
iscontainer ? "container" : "vm",
(unsigned int)pidleader,
- rootdir ? rootdir : "",
+ NULLSTR_EMPTY(rootdir),
3,
"Slice", "s", slicename,
"After", "as", 1, "libvirtd.service",
}
/* Append to the parameter set. */
- if (virURIParamAppend(uri, name, value ? value : "") < 0) {
+ if (virURIParamAppend(uri, name, NULLSTR_EMPTY(value)) < 0) {
VIR_FREE(name);
VIR_FREE(value);
return -1;
(def->source->data.tcp.protocol
== VIR_DOMAIN_CHR_TCP_PROTOCOL_RAW ?
"tcp" : "telnet"),
- (def->source->data.tcp.host ?
- def->source->data.tcp.host : ""),
- (def->source->data.tcp.service ?
- def->source->data.tcp.service : ""),
+ NULLSTR_EMPTY(def->source->data.tcp.host),
+ NULLSTR_EMPTY(def->source->data.tcp.service),
(def->source->data.tcp.listen ?
",server,nowait" : ""));
break;
case VIR_DOMAIN_CHR_TYPE_UDP:
virBufferAsprintf(buf, "%s:%s:%s@%s:%s", type,
- (def->source->data.udp.connectHost ?
- def->source->data.udp.connectHost : ""),
- (def->source->data.udp.connectService ?
- def->source->data.udp.connectService : ""),
- (def->source->data.udp.bindHost ?
- def->source->data.udp.bindHost : ""),
- (def->source->data.udp.bindService ?
- def->source->data.udp.bindService : ""));
+ NULLSTR_EMPTY(def->source->data.udp.connectHost),
+ NULLSTR_EMPTY(def->source->data.udp.connectService),
+ NULLSTR_EMPTY(def->source->data.udp.bindHost),
+ NULLSTR_EMPTY(def->source->data.udp.bindService));
break;
case VIR_DOMAIN_CHR_TYPE_UNIX:
if (full || !j)
vshPrint(ctl, " %-10s %-17s %s\n",
iface->name,
- iface->hwaddr ? iface->hwaddr : "", ip_addr_str);
+ NULLSTR_EMPTY(iface->hwaddr), ip_addr_str);
else
vshPrint(ctl, " %-10s %-17s %s\n",
"-", "-", ip_addr_str);
strftime(timestr, sizeof(timestr), "%Y-%m-%d-%H:%M:%S", &time_info);
if (virAsprintf(&ret, "%s-%s%s", virDomainGetName(dom),
- timestr, ext ? ext : "") < 0) {
+ timestr, NULLSTR_EMPTY(ext)) < 0) {
vshError(ctl, "%s", _("Out of memory"));
return NULL;
}
}
vshPrintExtra(ctl, " %-15s", _("Logging filters: "));
- vshPrint(ctl, "%s\n", filters ? filters : "");
+ vshPrint(ctl, "%s\n", NULLSTR_EMPTY(filters));
}
return true;
}
vshPrintExtra(ctl, " %-15s", _("Logging outputs: "));
- vshPrint(ctl, "%s\n", outputs ? outputs : "");
+ vshPrint(ctl, "%s\n", NULLSTR_EMPTY(outputs));
}
return true;