[PATCH 4/4] error: Use error_fatal to simplify obvious fatal errors (again)

Markus Armbruster posted 4 patches 5 years, 3 months ago
Maintainers: Christian Borntraeger <borntraeger@de.ibm.com>, Halil Pasic <pasic@linux.ibm.com>, Juan Quintela <quintela@redhat.com>, Thomas Huth <thuth@redhat.com>, David Hildenbrand <david@redhat.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Paolo Bonzini <pbonzini@redhat.com>, Jason Wang <jasowang@redhat.com>, Cornelia Huck <cohuck@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, Richard Henderson <rth@twiddle.net>, David Gibson <david@gibson.dropbear.id.au>, Markus Armbruster <armbru@redhat.com>, Hailiang Zhang <zhang.zhanghailiang@huawei.com>, Peter Xu <peterx@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>
[PATCH 4/4] error: Use error_fatal to simplify obvious fatal errors (again)
Posted by Markus Armbruster 5 years, 3 months ago
Patch created mechanically by rerunning:

    $ spatch --in-place --sp-file scripts/coccinelle/use-error_fatal.cocci \
	     --macro-file scripts/cocci-macro-file.h --use-gitgrep .

Variables now unused dropped manually.

Cc: Eric Auger <eric.auger@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 exec.c                     | 11 +++--------
 hw/s390x/s390-virtio-ccw.c |  6 +-----
 hw/virtio/vhost.c          | 10 +++-------
 3 files changed, 7 insertions(+), 20 deletions(-)

diff --git a/exec.c b/exec.c
index 6f381f98e2..61b46a62f8 100644
--- a/exec.c
+++ b/exec.c
@@ -627,8 +627,7 @@ static void tcg_register_iommu_notifier(CPUState *cpu,
      */
     MemoryRegion *mr = MEMORY_REGION(iommu_mr);
     TCGIOMMUNotifier *notifier;
-    Error *err = NULL;
-    int i, ret;
+    int i;
 
     for (i = 0; i < cpu->iommu_notifiers->len; i++) {
         notifier = g_array_index(cpu->iommu_notifiers, TCGIOMMUNotifier *, i);
@@ -657,12 +656,8 @@ static void tcg_register_iommu_notifier(CPUState *cpu,
                             0,
                             HWADDR_MAX,
                             iommu_idx);
-        ret = memory_region_register_iommu_notifier(notifier->mr, &notifier->n,
-                                                    &err);
-        if (ret) {
-            error_report_err(err);
-            exit(1);
-        }
+        memory_region_register_iommu_notifier(notifier->mr, &notifier->n,
+                                              &error_fatal);
     }
 
     if (!notifier->active) {
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 8cc2f25d8a..4fc92559fb 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -170,11 +170,7 @@ static void s390_memory_init(MemoryRegion *ram)
      * Configure the maximum page size. As no memory devices were created
      * yet, this is the page size of initial memory only.
      */
-    s390_set_max_pagesize(qemu_maxrampagesize(), &local_err);
-    if (local_err) {
-        error_report_err(local_err);
-        exit(EXIT_FAILURE);
-    }
+    s390_set_max_pagesize(qemu_maxrampagesize(), &error_fatal);
     /* Initialize storage key device */
     s390_skeys_init();
     /* Initialize storage attributes device */
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 1a1384e7a6..cc8c1f89d5 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -712,9 +712,8 @@ static void vhost_iommu_region_add(MemoryListener *listener,
                                          iommu_listener);
     struct vhost_iommu *iommu;
     Int128 end;
-    int iommu_idx, ret;
+    int iommu_idx;
     IOMMUMemoryRegion *iommu_mr;
-    Error *err = NULL;
 
     if (!memory_region_is_iommu(section->mr)) {
         return;
@@ -737,11 +736,8 @@ static void vhost_iommu_region_add(MemoryListener *listener,
     iommu->iommu_offset = section->offset_within_address_space -
                           section->offset_within_region;
     iommu->hdev = dev;
-    ret = memory_region_register_iommu_notifier(section->mr, &iommu->n, &err);
-    if (ret) {
-        error_report_err(err);
-        exit(1);
-    }
+    memory_region_register_iommu_notifier(section->mr, &iommu->n,
+                                          &error_fatal);
     QLIST_INSERT_HEAD(&dev->iommu_list, iommu, iommu_next);
     /* TODO: can replay help performance here? */
 }
-- 
2.26.2


Re: [PATCH 4/4] error: Use error_fatal to simplify obvious fatal errors (again)
Posted by David Hildenbrand 5 years, 3 months ago
On 22.07.20 10:40, Markus Armbruster wrote:
> Patch created mechanically by rerunning:
> 
>     $ spatch --in-place --sp-file scripts/coccinelle/use-error_fatal.cocci \
> 	     --macro-file scripts/cocci-macro-file.h --use-gitgrep .
> 
> Variables now unused dropped manually.
> 
> Cc: Eric Auger <eric.auger@redhat.com>
> Cc: David Hildenbrand <david@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  exec.c                     | 11 +++--------
>  hw/s390x/s390-virtio-ccw.c |  6 +-----
>  hw/virtio/vhost.c          | 10 +++-------
>  3 files changed, 7 insertions(+), 20 deletions(-)
> 
> diff --git a/exec.c b/exec.c
> index 6f381f98e2..61b46a62f8 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -627,8 +627,7 @@ static void tcg_register_iommu_notifier(CPUState *cpu,
>       */
>      MemoryRegion *mr = MEMORY_REGION(iommu_mr);
>      TCGIOMMUNotifier *notifier;
> -    Error *err = NULL;
> -    int i, ret;
> +    int i;
>  
>      for (i = 0; i < cpu->iommu_notifiers->len; i++) {
>          notifier = g_array_index(cpu->iommu_notifiers, TCGIOMMUNotifier *, i);
> @@ -657,12 +656,8 @@ static void tcg_register_iommu_notifier(CPUState *cpu,
>                              0,
>                              HWADDR_MAX,
>                              iommu_idx);
> -        ret = memory_region_register_iommu_notifier(notifier->mr, &notifier->n,
> -                                                    &err);
> -        if (ret) {
> -            error_report_err(err);
> -            exit(1);
> -        }
> +        memory_region_register_iommu_notifier(notifier->mr, &notifier->n,
> +                                              &error_fatal);
>      }
>  
>      if (!notifier->active) {
> diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
> index 8cc2f25d8a..4fc92559fb 100644
> --- a/hw/s390x/s390-virtio-ccw.c
> +++ b/hw/s390x/s390-virtio-ccw.c
> @@ -170,11 +170,7 @@ static void s390_memory_init(MemoryRegion *ram)
>       * Configure the maximum page size. As no memory devices were created
>       * yet, this is the page size of initial memory only.
>       */
> -    s390_set_max_pagesize(qemu_maxrampagesize(), &local_err);
> -    if (local_err) {
> -        error_report_err(local_err);
> -        exit(EXIT_FAILURE);
> -    }
> +    s390_set_max_pagesize(qemu_maxrampagesize(), &error_fatal);
>      /* Initialize storage key device */
>      s390_skeys_init();
>      /* Initialize storage attributes device */
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index 1a1384e7a6..cc8c1f89d5 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -712,9 +712,8 @@ static void vhost_iommu_region_add(MemoryListener *listener,
>                                           iommu_listener);
>      struct vhost_iommu *iommu;
>      Int128 end;
> -    int iommu_idx, ret;
> +    int iommu_idx;
>      IOMMUMemoryRegion *iommu_mr;
> -    Error *err = NULL;
>  
>      if (!memory_region_is_iommu(section->mr)) {
>          return;
> @@ -737,11 +736,8 @@ static void vhost_iommu_region_add(MemoryListener *listener,
>      iommu->iommu_offset = section->offset_within_address_space -
>                            section->offset_within_region;
>      iommu->hdev = dev;
> -    ret = memory_region_register_iommu_notifier(section->mr, &iommu->n, &err);
> -    if (ret) {
> -        error_report_err(err);
> -        exit(1);
> -    }
> +    memory_region_register_iommu_notifier(section->mr, &iommu->n,
> +                                          &error_fatal);
>      QLIST_INSERT_HEAD(&dev->iommu_list, iommu, iommu_next);
>      /* TODO: can replay help performance here? */
>  }
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb