On 6/22/21 9:53 PM, Jonathon Jongsma wrote:
This macro will be utilized in the following patch. Since mdevctl
commands can fail with or without an error message, this macro makes it
easy to print a fallback error in the case that the error message is not
set.
Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
src/node_device/node_device_driver.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 43a8c1bf60..eb85cc0439 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -57,6 +57,9 @@ VIR_ENUM_IMPL(virMdevctlCommand,
);
+#define MDEVCTL_ERROR(msg) (msg && msg[0] != '\0' ? msg : _("Unknown error"))
+
+
virDrvOpenStatus
nodeConnectOpen(virConnectPtr conn,
virConnectAuthPtr auth G_GNUC_UNUSED,
@@ -1387,7 +1390,7 @@ nodeDeviceUndefine(virNodeDevice *device,
if (virMdevctlUndefine(def, &errmsg) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to undefine mediated device: %s"),
- errmsg && errmsg[0] ? errmsg : "Unknown Error");
+ MDEVCTL_ERROR(errmsg));
goto cleanup;
}
ret = 0;
@@ -1434,7 +1437,7 @@ nodeDeviceCreate(virNodeDevice *device,
if (virMdevctlStart(def, &errmsg) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to create mediated device: %s"),
- errmsg && errmsg[0] ? errmsg : "Unknown Error");
+ MDEVCTL_ERROR(errmsg));
goto cleanup;
}
ret = 0;
Reviewed-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxx>
--
Mit freundlichen Grüßen/Kind regards
Boris Fiuczynski
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294