[PATCH] virtio: Prepend "virtio" prefix in virtio_error

Maxim Kostin posted 1 patch 11 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/HE1P193MB00580265AE8BA41151B8E203A37A9@HE1P193MB0058.EURP193.PROD.OUTLOOK.COM
Maintainers: "Michael S. Tsirkin" <mst@redhat.com>
hw/virtio/virtio.c         | 10 +++++-----
include/hw/virtio/virtio.h |  6 +++++-
2 files changed, 10 insertions(+), 6 deletions(-)
[PATCH] virtio: Prepend "virtio" prefix in virtio_error
Posted by Maxim Kostin 11 months, 3 weeks ago
Rename virtio_error function to virtio_error_impl and wrap it with
virtio_error macro, it adds the "virtio" prefix to the error message.

Remove redundant "virtio" prefixes in virtio_error calls.

Signed-off-by: Maxim Kostin <ttxinee@outlook.com>
---
 hw/virtio/virtio.c         | 10 +++++-----
 include/hw/virtio/virtio.h |  6 +++++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 272d930721..efdc425063 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1375,15 +1375,14 @@ static bool virtqueue_map_desc(VirtIODevice *vdev, unsigned int *p_num_sg,
     assert(num_sg <= max_num_sg);
 
     if (!sz) {
-        virtio_error(vdev, "virtio: zero sized buffers are not allowed");
+        virtio_error(vdev, "zero sized buffers are not allowed");
         goto out;
     }
 
     while (sz) {
         hwaddr len = sz;
-
         if (num_sg == max_num_sg) {
-            virtio_error(vdev, "virtio: too many write descriptors in "
+            virtio_error(vdev, "too many write descriptors in "
                                "indirect table");
             goto out;
         }
@@ -1394,7 +1393,7 @@ static bool virtqueue_map_desc(VirtIODevice *vdev, unsigned int *p_num_sg,
                                               DMA_DIRECTION_TO_DEVICE,
                                               MEMTXATTRS_UNSPECIFIED);
         if (!iov[num_sg].iov_base) {
-            virtio_error(vdev, "virtio: bogus descriptor or out of resources");
+            virtio_error(vdev, "bogus descriptor or out of resources");
             goto out;
         }
 
@@ -3563,7 +3562,8 @@ void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name)
     vdev->bus_name = g_strdup(bus_name);
 }
 
-void G_GNUC_PRINTF(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, ...)
+G_GNUC_PRINTF(2, 3)
+void virtio_error_impl(VirtIODevice *vdev, const char *fmt, ...)
 {
     va_list ap;
 
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index f6b38f7e9c..7022b67c72 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -221,7 +221,11 @@ void virtio_init(VirtIODevice *vdev, uint16_t device_id, size_t config_size);
 
 void virtio_cleanup(VirtIODevice *vdev);
 
-void virtio_error(VirtIODevice *vdev, const char *fmt, ...) G_GNUC_PRINTF(2, 3);
+#define virtio_error(vdev, fmt, ...) \
+    virtio_error_impl(vdev, "%s: " fmt, "virtio", ## __VA_ARGS__)
+
+void virtio_error_impl(VirtIODevice *vdev, const char *fmt, ...)
+    G_GNUC_PRINTF(2, 3);
 
 /* Set the child bus name. */
 void virtio_device_set_child_bus_name(VirtIODevice *vdev, char *bus_name);
-- 
2.25.1
Re: [PATCH] virtio: Prepend "virtio" prefix in virtio_error
Posted by Alex Bennée 11 months, 3 weeks ago
Maxim Kostin <ttxinee@outlook.com> writes:

> Rename virtio_error function to virtio_error_impl and wrap it with
> virtio_error macro, it adds the "virtio" prefix to the error message.
>
> Remove redundant "virtio" prefixes in virtio_error calls.
>
> Signed-off-by: Maxim Kostin <ttxinee@outlook.com>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro