On a Monday in 2022, Michal Privoznik wrote:
Instead of reporting virReportError(..., g_strerror(), ...) let's
use proper virReportSystemError(). Generated with help of cocci:
@@
expression c;
@@
<...
- virReportError(c,
+ virReportSystemError(errno,
...,
- g_strerror(errno),
...);
...>
But then I had to hand fix format strings, because I'm not sure
if cocci even knows how to do that. And even if it did, I surely
don't.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/libxl/libxl_conf.c | 7 +++----
src/libxl/libxl_driver.c | 35 +++++++++++++++--------------------
src/qemu/qemu_interface.c | 8 ++++----
3 files changed, 22 insertions(+), 28 deletions(-)
diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c
index 676bc896d6..d0dcce5690 100644
--- a/src/qemu/qemu_interface.c
+++ b/src/qemu/qemu_interface.c
@@ -370,10 +370,10 @@ qemuCreateInBridgePortWithHelper(virQEMUDriverConfig *cfg,
if (errbuf && *errbuf)
errstr = g_strdup_printf("\nstderr=%s", errbuf);
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("%s: failed to communicate with bridge helper: %s%s"),
- cmdstr, g_strerror(errno),
- NULLSTR_EMPTY(errstr));
+ virReportSystemError(errno,
+ _("%s: failed to communicate with bridge helper:
%s"),
+ cmdstr,
+ NULLSTR_EMPTY(errstr));
So, before we had:
helper: <errno>\n<errbuf>
now we'll get:
helper: \n<errbuf>: <errno>
I'd rather leave the code as-is, or at least remove the newline from the
g_strdup_printf call above.
Either way:
Reviewed-by: Ján Tomko <jtomko(a)redhat.com>
Jano
VIR_FREE(errstr);
goto cleanup;
}
--
2.35.1