[PATCH] lib: Use virReportSystemError() more
Ján Tomko
jtomko at redhat.com
Thu Apr 7 08:56:50 UTC 2022
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 at 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 at redhat.com>
Jano
> VIR_FREE(errstr);
> goto cleanup;
> }
>--
>2.35.1
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20220407/cdef361b/attachment-0001.sig>
More information about the libvir-list
mailing list