Re: [PATCH] lib: Use virReportSystemError() more

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
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@xxxxxxxxxx>

Jano

        VIR_FREE(errstr);
        goto cleanup;
    }
--
2.35.1

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux