@@ -2254,8 +2254,8 @@ static int qcow2_create2(const char *filename, int64_t total_size,
goto out;
} else if (ret != 0) {
- error_report("Huh, first cluster in empty image is already in use?");
- abort();
+ error_report_abort("Huh, first cluster in empty image is "
+ "already in use?");
}
/* Create a full header (including things like feature table) */
@@ -372,9 +372,9 @@ static int pick_geometry(FDrive *drv)
/* No match of any kind found -- fd_format is misconfigured, abort. */
if (match == -1) {
- error_setg(&error_abort, "No candidate geometries present in table "
- " for floppy drive type '%s'",
- FloppyDriveType_lookup[drv->drive]);
+ error_report_abort("No candidate geometries present in table "
+ " for floppy drive type '%s'",
+ FloppyDriveType_lookup[drv->drive]);
}
parse = &(fd_formats[match]);
@@ -465,8 +465,8 @@ static void assigned_dev_register_regions(PCIRegion *io_regions,
* so should return EINVAL for a 3 byte read */
ret = pread(pci_dev->v_addrs[i].region->resource_fd, &val, 3, 0);
if (ret >= 0) {
- error_report("Unexpected return from I/O port read: %d", ret);
- abort();
+ error_report_abort("Unexpected return from I/O port read: %d",
+ ret);
} else if (errno != EINVAL) {
error_report("Kernel doesn't support ioport resource "
"access, hiding this region.");
@@ -84,9 +84,8 @@ void xics_cpu_setup(XICSState *xics, PowerPCCPU *cpu)
break;
default:
- error_report("XICS interrupt controller does not support this CPU "
- "bus model");
- abort();
+ error_report_abort("XICS interrupt controller does not support "
+ "this CPU bus model");
}
}
@@ -2606,8 +2606,7 @@ MSIMessage pci_get_msi_message(PCIDevice *dev, int vector)
msg = msi_get_message(dev, vector);
} else {
/* Should never happen */
- error_report("%s: unknown interrupt type", __func__);
- abort();
+ error_report_abort("%s: unknown interrupt type", __func__);
}
return msg;
}
@@ -327,7 +327,7 @@ static void prop_get_fdt(Object *obj, Visitor *v, const char *name,
break;
}
default:
- error_setg(&error_abort, "device FDT in unexpected state: %d", tag);
+ error_report_abort("device FDT in unexpected state: %d", tag);
}
fdt_offset = fdt_offset_next;
} while (fdt_depth != 0);
@@ -339,9 +339,8 @@ static void vfio_start_eventfd_injection(SysBusDevice *sbdev, qemu_irq irq)
ret = vfio_set_trigger_eventfd(intp, vfio_intp_interrupt);
if (ret) {
- error_report("vfio: failed to start eventfd signaling for IRQ %d: %m",
- intp->pin);
- abort();
+ error_report_abort("vfio: failed to start eventfd signaling "
+ "for IRQ %d: %m", intp->pin);
}
}
@@ -431,9 +430,8 @@ static void vfio_start_irqfd_injection(SysBusDevice *sbdev, qemu_irq irq)
return;
fail_vfio:
kvm_irqchip_remove_irqfd_notifier(kvm_state, intp->interrupt, irq);
- error_report("vfio: failed to start eventfd signaling for IRQ %d: %m",
- intp->pin);
- abort();
+ error_report_abort("vfio: failed to start eventfd signaling for IRQ %d: %m",
+ intp->pin);
fail_irqfd:
vfio_start_eventfd_injection(sbdev, irq);
return;
@@ -352,9 +352,8 @@ static bool netmap_has_vnet_hdr_len(NetClientState *nc, int len)
/* Restore the previous length. */
if (netmap_fd_set_vnet_hdr_len(s, prev_len)) {
- error_report("Failed to restore vnet-hdr length %d on %s: %s",
- prev_len, s->ifname, strerror(errno));
- abort();
+ error_report_abort("Failed to restore vnet-hdr length %d on %s: %s",
+ prev_len, s->ifname, strerror(errno));
}
return true;
@@ -213,8 +213,9 @@ int tap_fd_set_vnet_le(int fd, int is_le)
return -errno;
}
- error_report("TUNSETVNETLE ioctl() failed: %s.", strerror(errno));
- abort();
+ error_report_abort("TUNSETVNETLE ioctl() failed: %s.", strerror(errno));
+ /* Not reach here. */
+ return -1;
}
int tap_fd_set_vnet_be(int fd, int is_be)
@@ -230,8 +231,9 @@ int tap_fd_set_vnet_be(int fd, int is_be)
return -errno;
}
- error_report("TUNSETVNETBE ioctl() failed: %s.", strerror(errno));
- abort();
+ error_report_abort("TUNSETVNETBE ioctl() failed: %s.", strerror(errno));
+ /* Not reach here. */
+ return -1;
}
void tap_fd_set_offload(int fd, int csum, int tso4,
new file mode 100644
@@ -0,0 +1,14 @@
+@@
+expression list X;
+@@
+
+-error_report(X);
+-abort();
++error_report_abort(X);
+
+@@
+expression list X;
+@@
+
+-error_setg(&error_abort, X);
++error_report_abort(X);
@@ -8446,8 +8446,7 @@ static void powerpc_get_compat(Object *obj, Visitor *v, const char *name,
case 0:
break;
default:
- error_report("Internal error: compat is set to %x", *max_compat);
- abort();
+ error_report_abort("Internal error: compat is set to %x", *max_compat);
break;
}
@@ -676,10 +676,9 @@ void runstate_set(RunState new_state)
}
if (!runstate_valid_transitions[current_run_state][new_state]) {
- error_report("invalid runstate transition: '%s' -> '%s'",
- RunState_lookup[current_run_state],
- RunState_lookup[new_state]);
- abort();
+ error_report_abort("invalid runstate transition: '%s' -> '%s'",
+ RunState_lookup[current_run_state],
+ RunState_lookup[new_state]);
}
trace_runstate_set(new_state);
current_run_state = new_state;
Two cases that can leverage error_report_abort(): Case 1: error_report(...); abort(); Case 2: error_setg(&error_abort, ...); This patch converts these cases to use error_report_abort(). Script error_report_abort.cocci is added to automate the convertion. Signed-off-by: Peter Xu <peterx@redhat.com> --- block/qcow2.c | 4 ++-- hw/block/fdc.c | 6 +++--- hw/i386/kvm/pci-assign.c | 4 ++-- hw/intc/xics.c | 5 ++--- hw/pci/pci.c | 3 +-- hw/ppc/spapr_drc.c | 2 +- hw/vfio/platform.c | 10 ++++------ net/netmap.c | 5 ++--- net/tap-linux.c | 10 ++++++---- scripts/coccinelle/error_report_abort.cocci | 14 ++++++++++++++ target-ppc/translate_init.c | 3 +-- vl.c | 7 +++---- 12 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 scripts/coccinelle/error_report_abort.cocci