mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
lib: Use NULLSTR family of macros more
There is a family of convenient macros: NULLSTR, NULLSTR_EMPTY,
NULLSTR_STAR, NULLSTR_MINUS which hides ternary operator.
Generated using the following spatch (and its obvious variants):
@@
expression s;
@@
<+...
- s ? s : "<null>"
+ NULLSTR(s)
...+>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
@@ -455,7 +455,7 @@ cmdCheckpointInfo(vshControl *ctl,
|
||||
_("unexpected problem querying checkpoint state"));
|
||||
return false;
|
||||
}
|
||||
vshPrint(ctl, "%-15s %s\n", _("Parent:"), parent ? parent : "-");
|
||||
vshPrint(ctl, "%-15s %s\n", _("Parent:"), NULLSTR_MINUS(parent));
|
||||
|
||||
/* Children, Descendants. */
|
||||
flags = 0;
|
||||
|
||||
@@ -712,11 +712,11 @@ cmdDomiflist(vshControl *ctl, const vshCmd *cmd)
|
||||
mac = virXPathString("string(./mac/@address)", ctxt);
|
||||
|
||||
if (vshTableRowAppend(table,
|
||||
target ? target : "-",
|
||||
NULLSTR_MINUS(target),
|
||||
type,
|
||||
source ? source : "-",
|
||||
model ? model : "-",
|
||||
mac ? mac : "-",
|
||||
NULLSTR_MINUS(source),
|
||||
NULLSTR_MINUS(model),
|
||||
NULLSTR_MINUS(mac),
|
||||
NULL) < 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1233,7 +1233,7 @@ cmdNodeDeviceInfo(vshControl *ctl, const vshCmd *cmd)
|
||||
|
||||
parent = virNodeDeviceGetParent(device);
|
||||
vshPrint(ctl, "%-15s %s\n", _("Name:"), virNodeDeviceGetName(device));
|
||||
vshPrint(ctl, "%-15s %s\n", _("Parent:"), parent ? parent : "");
|
||||
vshPrint(ctl, "%-15s %s\n", _("Parent:"), NULLSTR_EMPTY(parent));
|
||||
vshPrint(ctl, "%-15s %s\n", _("Active:"), virNodeDeviceIsActive(device) ?
|
||||
_("yes") : _("no"));
|
||||
vshPrint(ctl, "%-15s %s\n", _("Persistent:"),
|
||||
|
||||
Reference in New Issue
Block a user