Skip to contentSkip to conversation

error: Mechanical fixes & cleanups

PATCH In review Markus Armbruster 6 participants 15 messages Jul 22, 2020 – Jul 24, 2020 Coccinelle/Semantic Patches (SmPL)

lore
Share & tools
lore
#0 lore raw

cover error: Mechanical fixes & cleanups

Markus Armbruster (4):
coccinelle/err-bad-newline: Fix for Python 3, and add patterns
error: Strip trailing '\n' from error string arguments (again)
error: Remove NULL checks on error_propagate() calls (again)
error: Use error_fatal to simplify obvious fatal errors (again)

 scripts/coccinelle/err-bad-newline.cocci | 24 ++++++++++++++++++++++--
 exec.c                                   | 11 +++--------
 hw/i386/intel_iommu.c                    |  6 +++---
 hw/net/virtio-net.c                      |  8 ++------
 hw/s390x/s390-virtio-ccw.c               |  6 +-----
 hw/virtio/vhost.c                        | 10 +++-------
 migration/colo.c                         |  4 +---
 migration/migration.c                    |  8 ++------
 target/ppc/mmu-hash64.c                  |  2 +-
 9 files changed, 38 insertions(+), 41 deletions(-)
Signature · 1 line
2.26.2
#1 lore raw

PATCH 1/4 coccinelle/err-bad-newline: Fix for Python 3, and add patterns

---
 scripts/coccinelle/err-bad-newline.cocci | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
scripts/coccinelle/err-bad-newline.cocci +22 -2
index 1316cc86a6..5394421873 100644
@@ -1,22 +1,42 @@
 // Error messages should not contain newlines.  This script finds
 // messages that do.  Fixing them is manual.
 @r@
-expression errp, eno, cls, fmt;
+expression errp, err, eno, cls, fmt, ap;
 position p;
 @@
 (
+error_vreport(fmt, ap)@p
+|
+warn_vreport(fmt, ap)@p
+|
+info_vreport(fmt, ap)@p
+|
 error_report(fmt, ...)@p
 |
+warn_report(fmt, ...)@p
+|
+info_report(fmt, ...)@p
+|
+error_report_once(fmt, ...)@p
+|
+warn_report_once(fmt, ...)@p
+|
 error_setg(errp, fmt, ...)@p
 |
 error_setg_errno(errp, eno, fmt, ...)@p
 |
 error_setg_win32(errp, eno, cls, fmt, ...)@p
 |
+error_propagate_prepend(errp, err, fmt, ...)@p
+|
+error_vprepend(errp, fmt, ap)@p
+|
 error_prepend(errp, fmt, ...)@p
 |
 error_setg_file_open(errp, eno, cls, fmt, ...)@p
 |
+warn_reportf_err(errp, fmt, ...)@p
+|
 error_reportf_err(errp, fmt, ...)@p
 |
 error_set(errp, cls, fmt, ...)@p
@@ -26,4 +46,4 @@ fmt << r.fmt;
 p << r.p;
 @@
 if "\\n" in str(fmt):
-    print "%s:%s:%s:%s" % (p[0].file, p[0].line, p[0].column, fmt)
+    print("%s:%s:%s:%s" % (p[0].file, p[0].line, p[0].column, fmt))
Signature · 1 line
2.26.2
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] coccinelle/err-bad-newline: Fix for Python 3, and add patterns

Quoted 5 lines · Markus Armbruster
---
  scripts/coccinelle/err-bad-newline.cocci | 24 ++++++++++++++++++++++--
  1 file changed, 22 insertions(+), 2 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#3 lore raw

PATCH 2/4 error: Strip trailing '\n' from error string arguments (again)

In reply to Markus Armbruster

Tracked down with scripts/coccinelle/err-bad-newline.cocci.

---
 hw/i386/intel_iommu.c   | 6 +++---
 target/ppc/mmu-hash64.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
hw/i386/intel_iommu.c +3 -3
index c56398e991..8cd9ed8d3b 100644
@@ -2356,7 +2356,7 @@ static bool vtd_process_iotlb_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc)
     if ((inv_desc->lo & VTD_INV_DESC_IOTLB_RSVD_LO) ||
         (inv_desc->hi & VTD_INV_DESC_IOTLB_RSVD_HI)) {
         error_report_once("%s: invalid iotlb inv desc: hi=0x%"PRIx64
-                          ", lo=0x%"PRIx64" (reserved bits unzero)\n",
+                          ", lo=0x%"PRIx64" (reserved bits unzero)",
                           __func__, inv_desc->hi, inv_desc->lo);
         return false;
     }
@@ -2377,7 +2377,7 @@ static bool vtd_process_iotlb_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc)
         am = VTD_INV_DESC_IOTLB_AM(inv_desc->hi);
         if (am > VTD_MAMV) {
             error_report_once("%s: invalid iotlb inv desc: hi=0x%"PRIx64
-                              ", lo=0x%"PRIx64" (am=%u > VTD_MAMV=%u)\n",
+                              ", lo=0x%"PRIx64" (am=%u > VTD_MAMV=%u)",
                               __func__, inv_desc->hi, inv_desc->lo,
                               am, (unsigned)VTD_MAMV);
             return false;
@@ -2387,7 +2387,7 @@ static bool vtd_process_iotlb_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc)
 
     default:
         error_report_once("%s: invalid iotlb inv desc: hi=0x%"PRIx64
-                          ", lo=0x%"PRIx64" (type mismatch: 0x%llx)\n",
+                          ", lo=0x%"PRIx64" (type mismatch: 0x%llx)",
                           __func__, inv_desc->hi, inv_desc->lo,
                           inv_desc->lo & VTD_INV_DESC_IOTLB_G);
         return false;
target/ppc/mmu-hash64.c +1 -1
index e5baabf0e1..c31d21e6a9 100644
@@ -859,7 +859,7 @@ static int build_vrma_slbe(PowerPCCPU *cpu, ppc_slb_t *slb)
     }
 
     error_report("Bad page size encoding in LPCR[VRMASD]; LPCR=0x"
-                 TARGET_FMT_lx"\n", lpcr);
+                 TARGET_FMT_lx, lpcr);
 
     return -1;
 }
Signature · 1 line
2.26.2
Reviewed-by on v1 2/4
#4 lore raw

Re: [PATCH 2/4] error: Strip trailing '\n' from error string arguments (again)

Quoted 9 lines · Markus Armbruster

Tracked down with scripts/coccinelle/err-bad-newline.cocci.

---
 hw/i386/intel_iommu.c   | 6 +++---
 target/ppc/mmu-hash64.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
Acked-by on v1 2/4
#5 lore raw

Re: [PATCH 2/4] error: Strip trailing '\n' from error string arguments (again)

In reply to Markus Armbruster
Quoted 5 lines · Markus Armbruster

Tracked down with scripts/coccinelle/err-bad-newline.cocci.

ppc part

Quoted 49 lines
---
 hw/i386/intel_iommu.c   | 6 +++---
 target/ppc/mmu-hash64.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
hw/i386/intel_iommu.c +3 -3
index c56398e991..8cd9ed8d3b 100644
@@ -2356,7 +2356,7 @@ static bool vtd_process_iotlb_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc)
     if ((inv_desc->lo & VTD_INV_DESC_IOTLB_RSVD_LO) ||
         (inv_desc->hi & VTD_INV_DESC_IOTLB_RSVD_HI)) {
         error_report_once("%s: invalid iotlb inv desc: hi=0x%"PRIx64
-                          ", lo=0x%"PRIx64" (reserved bits unzero)\n",
+                          ", lo=0x%"PRIx64" (reserved bits unzero)",
                           __func__, inv_desc->hi, inv_desc->lo);
         return false;
     }
@@ -2377,7 +2377,7 @@ static bool vtd_process_iotlb_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc)
         am = VTD_INV_DESC_IOTLB_AM(inv_desc->hi);
         if (am > VTD_MAMV) {
             error_report_once("%s: invalid iotlb inv desc: hi=0x%"PRIx64
-                              ", lo=0x%"PRIx64" (am=%u > VTD_MAMV=%u)\n",
+                              ", lo=0x%"PRIx64" (am=%u > VTD_MAMV=%u)",
                               __func__, inv_desc->hi, inv_desc->lo,
                               am, (unsigned)VTD_MAMV);
             return false;
@@ -2387,7 +2387,7 @@ static bool vtd_process_iotlb_desc(IntelIOMMUState *s, VTDInvDesc *inv_desc)
 
     default:
         error_report_once("%s: invalid iotlb inv desc: hi=0x%"PRIx64
-                          ", lo=0x%"PRIx64" (type mismatch: 0x%llx)\n",
+                          ", lo=0x%"PRIx64" (type mismatch: 0x%llx)",
                           __func__, inv_desc->hi, inv_desc->lo,
                           inv_desc->lo & VTD_INV_DESC_IOTLB_G);
         return false;
target/ppc/mmu-hash64.c +1 -1
index e5baabf0e1..c31d21e6a9 100644
@@ -859,7 +859,7 @@ static int build_vrma_slbe(PowerPCCPU *cpu, ppc_slb_t *slb)
     }
 
     error_report("Bad page size encoding in LPCR[VRMASD]; LPCR=0x"
-                 TARGET_FMT_lx"\n", lpcr);
+                 TARGET_FMT_lx, lpcr);
 
     return -1;
 }
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#7 lore raw

PATCH 3/4 error: Remove NULL checks on error_propagate() calls (again)

In reply to Markus Armbruster

Patch created mechanically by rerunning:

    $ spatch --sp-file scripts/coccinelle/error_propagate_null.cocci \
             --macro-file scripts/cocci-macro-file.h \
             --use-gitgrep .
Cc Jens Freimann <[email protected]>
Cc Hailiang Zhang <[email protected]>
Cc Juan Quintela <[email protected]>
---
 hw/net/virtio-net.c   | 8 ++------
 migration/colo.c      | 4 +---
 migration/migration.c | 8 ++------
 3 files changed, 5 insertions(+), 15 deletions(-)
hw/net/virtio-net.c +2 -6
index 4895af1cbe..21b9a315ed 100644
@@ -809,9 +809,7 @@ static void failover_add_primary(VirtIONet *n, Error **errp)
             "sure primary device has parameter"
             " failover_pair_id=<virtio-net-id>\n");
 }
-    if (err) {
-        error_propagate(errp, err);
-    }
+    error_propagate(errp, err);
 }
 
 static int is_my_primary(void *opaque, QemuOpts *opts, Error **errp)
@@ -865,9 +863,7 @@ static DeviceState *virtio_connect_failover_devices(VirtIONet *n,
         n->primary_device_id = g_strdup(prim_dev->id);
         n->primary_device_opts = prim_dev->opts;
     } else {
-        if (err) {
-            error_propagate(errp, err);
-        }
+        error_propagate(errp, err);
     }
 
     return prim_dev;
migration/colo.c +1 -3
index ea7d1e9d4e..c6848c829b 100644
@@ -798,9 +798,7 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
 
     colo_send_message(mis->to_src_file, COLO_MESSAGE_VMSTATE_LOADED,
                  &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-    }
+    error_propagate(errp, local_err);
 }
 
 static void colo_wait_handle_message(MigrationIncomingState *mis,
migration/migration.c +2 -6
index 2ed9923227..6a458b8fe5 100644
@@ -601,9 +601,7 @@ void migration_fd_process_incoming(QEMUFile *f, Error **errp)
     }
 
     if (migration_incoming_setup(f, &local_err)) {
-        if (local_err) {
-            error_propagate(errp, local_err);
-        }
+        error_propagate(errp, local_err);
         return;
     }
     migration_incoming_process();
@@ -625,9 +623,7 @@ void migration_ioc_process_incoming(QIOChannel *ioc, Error **errp)
         }
 
         if (migration_incoming_setup(f, &local_err)) {
-            if (local_err) {
-                error_propagate(errp, local_err);
-            }
+            error_propagate(errp, local_err);
             return;
         }
 
Signature · 1 line
2.26.2
Reviewed-by on v1 3/4
#8 lore raw

Re: [PATCH 3/4] error: Remove NULL checks on error_propagate() calls (again)

Quoted 14 lines · Markus Armbruster

Patch created mechanically by rerunning:

     $ spatch --sp-file scripts/coccinelle/error_propagate_null.cocci \
              --macro-file scripts/cocci-macro-file.h \
              --use-gitgrep .
Cc Jens Freimann <[email protected]>
Cc Hailiang Zhang <[email protected]>
Cc Juan Quintela <[email protected]>

---

+++ b/migration/colo.c

migration/colo.c static void colo_incoming_process_checkpoint(MigrationIncomingState *mis, · line 802

Quoted 8 lines
migration/colo.c +1 -3
@@ -798,9 +798,7 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
 
      colo_send_message(mis->to_src_file, COLO_MESSAGE_VMSTATE_LOADED,
                   &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-    }
+    error_propagate(errp, local_err);
  }

As this is mechanical, it is fine. But there is now a further cleanup possible of passing errp directly to colo_send_message, and possibly dropping local_err altogether.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#9 lore raw

Re: [PATCH 3/4] error: Remove NULL checks on error_propagate() calls (again)

Quoted 13 lines · Eric Blake
Quoted 11 lines · Markus Armbruster

Patch created mechanically by rerunning:

     $ spatch --sp-file scripts/coccinelle/error_propagate_null.cocci \
              --macro-file scripts/cocci-macro-file.h \
              --use-gitgrep .
Cc Jens Freimann <[email protected]>
Cc Hailiang Zhang <[email protected]>
Cc Juan Quintela <[email protected]>

---

Quoted 14 lines

migration/colo.c static void colo_incoming_process_checkpoint(MigrationIncomingState *mis, · line 802

Quoted 10 lines

+++ b/migration/colo.c

migration/colo.c +1 -3
@@ -798,9 +798,7 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
        colo_send_message(mis->to_src_file,
 COLO_MESSAGE_VMSTATE_LOADED,
                   &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-    }
+    error_propagate(errp, local_err);
  }

As this is mechanical, it is fine. But there is now a further cleanup possible of passing errp directly to colo_send_message, and possibly dropping local_err altogether.

True.

The patch is small and simple enough for squashing in further manual cleanups. I'd like to first check whether a followup patch created with the machinery I used for eliminating error_propagate() comes out better.

Quoted 1 line

Thanks!

#10 lore raw

Re: [PATCH 3/4] error: Remove NULL checks on error_propagate() calls (again)

Quoted 30 lines · Markus Armbruster
Quoted 13 lines · Eric Blake
Quoted 11 lines · Markus Armbruster

Patch created mechanically by rerunning:

     $ spatch --sp-file scripts/coccinelle/error_propagate_null.cocci \
              --macro-file scripts/cocci-macro-file.h \
              --use-gitgrep .
Cc Jens Freimann <[email protected]>
Cc Hailiang Zhang <[email protected]>
Cc Juan Quintela <[email protected]>

---

Quoted 14 lines

migration/colo.c static void colo_incoming_process_checkpoint(MigrationIncomingState *mis, · line 802

Quoted 10 lines

+++ b/migration/colo.c

migration/colo.c +1 -3
@@ -798,9 +798,7 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
        colo_send_message(mis->to_src_file,
 COLO_MESSAGE_VMSTATE_LOADED,
                   &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-    }
+    error_propagate(errp, local_err);
  }

As this is mechanical, it is fine. But there is now a further cleanup possible of passing errp directly to colo_send_message, and possibly dropping local_err altogether.

Quoted 5 lines

True.

The patch is small and simple enough for squashing in further manual cleanups. I'd like to first check whether a followup patch created with the machinery I used for eliminating error_propagate() comes out better.

Vladimir's scripts/coccinelle/errp-guard.cocci will take care of it.

Eliminating error propagation altogether would be even better, but it's also more work: several void functions need to return bool instead.

Quoted 3 lines
Quoted 1 line

Thanks!

#11 lore raw

Re: [PATCH 3/4] error: Remove NULL checks on error_propagate() calls (again)

Quoted 15 lines · Markus Armbruster
Quoted 15 lines
Quoted 14 lines

migration/colo.c static void colo_incoming_process_checkpoint(MigrationIncomingState *mis, · line 802

Quoted 10 lines

+++ b/migration/colo.c

migration/colo.c +1 -3
@@ -798,9 +798,7 @@ static void colo_incoming_process_checkpoint(MigrationIncomingState *mis,
         colo_send_message(mis->to_src_file,
 COLO_MESSAGE_VMSTATE_LOADED,
                    &local_err);
-    if (local_err) {
-        error_propagate(errp, local_err);
-    }
+    error_propagate(errp, local_err);
   }

As this is mechanical, it is fine. But there is now a further cleanup possible of passing errp directly to colo_send_message, and possibly dropping local_err altogether.

Quoted 7 lines
Quoted 5 lines

True.

The patch is small and simple enough for squashing in further manual cleanups. I'd like to first check whether a followup patch created with the machinery I used for eliminating error_propagate() comes out better.

Vladimir's scripts/coccinelle/errp-guard.cocci will take care of it.

Good to know. Then I'm fine deferring those cleanups to the mechanical patches down the road, rather than a manual effort now.

Quoted 3 lines

Eliminating error propagation altogether would be even better, but it's also more work: several void functions need to return bool instead.

Correct, but also doesn't change the fact that this patch is ready to go regardless of how much further cleanup we plan on doing.

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

Thanks!

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#12 lore raw

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

In reply to Markus Armbruster

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 <[email protected]>
Cc David Hildenbrand <[email protected]>
---
 exec.c                     | 11 +++--------
 hw/s390x/s390-virtio-ccw.c |  6 +-----
 hw/virtio/vhost.c          | 10 +++-------
 3 files changed, 7 insertions(+), 20 deletions(-)
exec.c +3 -8
index 6f381f98e2..61b46a62f8 100644
@@ -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) {
hw/s390x/s390-virtio-ccw.c +1 -5
index 8cc2f25d8a..4fc92559fb 100644
@@ -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 */
hw/virtio/vhost.c +3 -7
index 1a1384e7a6..cc8c1f89d5 100644
@@ -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? */
 }
Signature · 1 line
2.26.2
Reviewed-by on v1 4/4
#13 lore raw

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

Quoted 82 lines · Markus Armbruster

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 <[email protected]>
Cc David Hildenbrand <[email protected]>
---
 exec.c                     | 11 +++--------
 hw/s390x/s390-virtio-ccw.c |  6 +-----
 hw/virtio/vhost.c          | 10 +++-------
 3 files changed, 7 insertions(+), 20 deletions(-)
exec.c +3 -8
index 6f381f98e2..61b46a62f8 100644
@@ -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) {
hw/s390x/s390-virtio-ccw.c +1 -5
index 8cc2f25d8a..4fc92559fb 100644
@@ -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 */
hw/virtio/vhost.c +1 -2
index 1a1384e7a6..cc8c1f89d5 100644
@@ -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;

hw/virtio/vhost.c static void vhost_iommu_region_add(MemoryListener *listener, · line 743

Quoted 10 lines
hw/virtio/vhost.c +2 -5
-    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? */
 }
Signature · 3 lines
Thanks,

David / dhildenb
#14 lore raw
In reply to Markus Armbruster
Quoted 5 lines · Markus Armbruster

Markus Armbruster (4):
coccinelle/err-bad-newline: Fix for Python 3, and add patterns
error: Strip trailing '\n' from error string arguments (again)
error: Remove NULL checks on error_propagate() calls (again)
error: Use error_fatal to simplify obvious fatal errors (again)

PATCH 1+2 queued for 5.1, PATCH 3+4 queued for 5.2.