Skip to contentSkip to conversation

virtio/virtio.c: include virtio prefix in error message

PATCH In review Moteen Shah 2 participants 2 messages Apr 14, 2022 – Apr 15, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio/virtio.c: include virtio prefix in error message

From: Moteen Shah <[email protected]>

The error message in virtio_init_region_cache()
is given a prefix virtio.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/230

---
 hw/virtio/virtio.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/virtio/virtio.c +3 -3
index 9d637e043e..f31427bd41 100644
@@ -174,7 +174,7 @@ static void virtio_init_region_cache(VirtIODevice *vdev, int n)
     len = address_space_cache_init(&new->desc, vdev->dma_as,
                                    addr, size, packed);
     if (len < size) {
-        virtio_error(vdev, "Cannot map desc");
+        virtio_error(vdev, "Virtio cannot map desc");
         goto err_desc;
     }
 
@@ -182,7 +182,7 @@ static void virtio_init_region_cache(VirtIODevice *vdev, int n)
     len = address_space_cache_init(&new->used, vdev->dma_as,
                                    vq->vring.used, size, true);
     if (len < size) {
-        virtio_error(vdev, "Cannot map used");
+        virtio_error(vdev, "Virtio cannot map used");
         goto err_used;
     }
 
@@ -190,7 +190,7 @@ static void virtio_init_region_cache(VirtIODevice *vdev, int n)
     len = address_space_cache_init(&new->avail, vdev->dma_as,
                                    vq->vring.avail, size, false);
     if (len < size) {
-        virtio_error(vdev, "Cannot map avail");
+        virtio_error(vdev, "Virtio cannot map avail");
         goto err_avail;
     }
 
Signature · 1 line
2.35.1
#1 lore raw
Quoted 4 lines · Moteen Shah

From: Moteen Shah <[email protected]>

The error message in virtio_init_region_cache()
is given a prefix virtio.

It seems a shame considering we have a common virtio_error function that we couldn't do it in one place. One option would be to make virtio_error a macro that could insert __func__ in place:

  #define virtio_error(vdev, fmt, ...)                            \
      virtio_error_impl(vdev, "%s: " fmt, __func__, ## __VA_ARGS__);

  void virtio_error_impl(VirtIODevice *vdev, const char *fmt, ...) G_GNUC_PRINTF(2, 3);

and make rename the function in virtio.c. As the functions calling this all tend to have virtio in their names anyway. What do you think?

Quoted 39 lines

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/230

---
 hw/virtio/virtio.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
hw/virtio/virtio.c +3 -3
index 9d637e043e..f31427bd41 100644
@@ -174,7 +174,7 @@ static void virtio_init_region_cache(VirtIODevice *vdev, int n)
     len = address_space_cache_init(&new->desc, vdev->dma_as,
                                    addr, size, packed);
     if (len < size) {
-        virtio_error(vdev, "Cannot map desc");
+        virtio_error(vdev, "Virtio cannot map desc");
         goto err_desc;
     }
 
@@ -182,7 +182,7 @@ static void virtio_init_region_cache(VirtIODevice *vdev, int n)
     len = address_space_cache_init(&new->used, vdev->dma_as,
                                    vq->vring.used, size, true);
     if (len < size) {
-        virtio_error(vdev, "Cannot map used");
+        virtio_error(vdev, "Virtio cannot map used");
         goto err_used;
     }
 
@@ -190,7 +190,7 @@ static void virtio_init_region_cache(VirtIODevice *vdev, int n)
     len = address_space_cache_init(&new->avail, vdev->dma_as,
                                    vq->vring.avail, size, false);
     if (len < size) {
-        virtio_error(vdev, "Cannot map avail");
+        virtio_error(vdev, "Virtio cannot map avail");
         goto err_avail;
     }
Signature · 1 line
Alex Bennée