Use error_fatal to simplify obvious fatal errors
v2 cover Use error_fatal to simplify obvious fatal errors
v2:
* PATCH 1: Don't mess up formatting of zynq_init() [Paolo]
* PATCH 2: New [Paolo]
Markus Armbruster (2):
Use error_fatal to simplify obvious fatal errors
hw: Inline the qdev_prop_set_drive_nofail() wrapper
hw/arm/exynos4210.c | 13 ++---------- hw/arm/highbank.c | 7 +------ hw/arm/integratorcp.c | 13 ++---------- hw/arm/nseries.c | 4 ++-- hw/arm/realview.c | 20 ++++--------------- hw/arm/versatilepb.c | 13 ++---------- hw/arm/vexpress.c | 7 +------ hw/arm/xilinx_zynq.c | 28 ++++++-------------------- hw/block/fdc.c | 15 +++++++++----- hw/block/nand.c | 2 +- hw/char/serial.c | 14 ++----------- hw/core/qdev-properties-system.c | 12 ----------- hw/i386/pc.c | 14 ++----------- hw/ide/qdev.c | 3 ++- hw/isa/pc87312.c | 8 ++++---- hw/ppc/spapr.c | 3 ++- hw/smbios/smbios.c | 43 +++++++--------------------------------- include/hw/qdev-properties.h | 2 -- numa.c | 8 ++------ vl.c | 21 +++----------------- 20 files changed, 55 insertions(+), 195 deletions(-)
Signature · 1 line
2.4.3
PATCH v2 1/2 Use error_fatal to simplify obvious fatal errors
Done with this admittedly crude Coccinelle semantic patch:
@@
identifier FUN;
expression ERR, EC;
@@
- FUN(&ERR);
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
+ FUN(&error_fatal);
@@
identifier FUN;
expression ARG1, ERR, EC;
@@
- FUN(ARG1, &ERR);
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
+ FUN(ARG1, &error_fatal);
@@
identifier FUN;
expression ARG1, ARG2, ERR, EC;
@@
- FUN(ARG1, ARG2, &ERR);
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
+ FUN(ARG1, ARG2, &error_fatal);
@@
identifier FUN;
expression ARG1, ARG2, ARG3, ERR, EC; @@
- FUN(ARG1, ARG2, ARG3, &ERR);
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
+ FUN(ARG1, ARG2, ARG3, &error_fatal);
@@
identifier FUN;
expression RET, ERR, EC;
@@
- RET = FUN(&ERR);
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
+ RET = FUN(&error_fatal);
@@
identifier FUN;
expression RET, ARG1, ERR, EC;
@@
- RET = FUN(ARG1, &ERR);
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
+ RET = FUN(ARG1, &error_fatal);
@@
identifier FUN;
expression RET, ARG1, ARG2, ERR, EC; @@
- RET = FUN(ARG1, ARG2, &ERR);
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
+ RET = FUN(ARG1, ARG2, &error_fatal);
@@
identifier FUN;
expression RET, ARG1, ARG2, ARG3, ERR, EC; @@
- RET = FUN(ARG1, ARG2, ARG3, &ERR);
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
+ RET = FUN(ARG1, ARG2, ARG3, &error_fatal);
@@
type T;
identifier FUN, RET;
expression ERR, EC;
@@
- T RET = FUN(&ERR);
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
+ T RET = FUN(&error_fatal);
@@
type T;
identifier FUN, RET;
expression ARG1, ERR, EC;
@@
- T RET = FUN(ARG1, &ERR);
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
+ T RET = FUN(ARG1, &error_fatal);
@@
type T;
identifier FUN, RET;
expression ARG1, ARG2, ERR, EC;
@@
- T RET = FUN(ARG1, ARG2, &ERR);
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
+ T RET = FUN(ARG1, ARG2, &error_fatal);
@@
type T;
identifier FUN, RET;
expression ARG1, ARG2, ARG3, ERR, EC; @@
- T RET = FUN(ARG1, ARG2, ARG3, &ERR);
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
+ T RET = FUN(ARG1, ARG2, ARG3, &error_fatal);
This leaves dead Error * variables behind, cleaned up manually.
My version of spatch messes up formatting of zynq_init(), also cleaned up manually.
--- hw/arm/exynos4210.c | 13 ++---------- hw/arm/highbank.c | 7 +------ hw/arm/integratorcp.c | 13 ++---------- hw/arm/realview.c | 20 ++++--------------- hw/arm/versatilepb.c | 13 ++---------- hw/arm/vexpress.c | 7 +------ hw/arm/xilinx_zynq.c | 28 ++++++-------------------- hw/char/serial.c | 14 ++----------- hw/core/qdev-properties-system.c | 8 +------- hw/i386/pc.c | 14 ++----------- hw/smbios/smbios.c | 43 +++++++--------------------------------- numa.c | 8 ++------ vl.c | 21 +++----------------- 13 files changed, 35 insertions(+), 174 deletions(-)
hw/arm/exynos4210.c +2 -11
@@ -150,27 +150,18 @@ Exynos4210State *exynos4210_init(MemoryRegion *system_mem,for (n =0 ; n <EXYNOS4210_NCPUS ; n++) {Object *cpuobj =object_new (object_class_get_name (cpu_oc)); -Error *err =NULL ;/* By default A9 CPUs have EL3 enabled. This board does not currently * support EL3 so the CPU EL3 property is disabled before realization. */ if (object_property_find (cpuobj,"has_el3" ,NULL )) { -object_property_set_bool (cpuobj, false,"has_el3" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } +object_property_set_bool (cpuobj, false,"has_el3" , &error_fatal); } s->cpu[n] =ARM_CPU (cpuobj);object_property_set_int (cpuobj,EXYNOS4210_SMP_PRIVATE_BASE_ADDR ,"reset-cbar" , &error_abort); -object_property_set_bool (cpuobj, true,"realized" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } +object_property_set_bool (cpuobj, true,"realized" , &error_fatal); }/*** IRQs ***/
hw/arm/highbank.c +1 -6
@@ -279,7 +279,6 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)ObjectClass *oc =cpu_class_by_name (TYPE_ARM_CPU , cpu_model);Object *cpuobj;ARMCPU *cpu; -Error *err =NULL ; cpuobj =object_new (object_class_get_name (oc)); cpu =ARM_CPU (cpuobj);
@@ -297,11 +296,7 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)object_property_set_int (cpuobj,MPCORE_PERIPHBASE ,"reset-cbar" , &error_abort); } -object_property_set_bool (cpuobj, true,"realized" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } +object_property_set_bool (cpuobj, true,"realized" , &error_fatal); cpu_irq[n] =qdev_get_gpio_in (DEVICE (cpu),ARM_CPU_IRQ ); cpu_fiq[n] =qdev_get_gpio_in (DEVICE (cpu),ARM_CPU_FIQ ); }
hw/arm/integratorcp.c +2 -11
@@ -533,7 +533,6 @@ static void integratorcp_init(MachineState *machine)qemu_irq pic[32 ];DeviceState *dev, *sic, *icp;int i; -Error *err =NULL ;if (!cpu_model) { cpu_model ="arm926" ;
@@ -552,18 +551,10 @@ static void integratorcp_init(MachineState *machine)* realization. */ if (object_property_find (cpuobj,"has_el3" ,NULL )) { -object_property_set_bool (cpuobj, false,"has_el3" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } +object_property_set_bool (cpuobj, false,"has_el3" , &error_fatal); } -object_property_set_bool (cpuobj, true,"realized" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } +object_property_set_bool (cpuobj, true,"realized" , &error_fatal); cpu =ARM_CPU (cpuobj);
hw/arm/realview.c +4 -16
@@ -99,33 +99,21 @@ static void realview_init(MachineState *machine,for (n =0 ; n < smp_cpus; n++) {Object *cpuobj =object_new (object_class_get_name (cpu_oc)); -Error *err =NULL ;/* By default A9,A15 and ARM1176 CPUs have EL3 enabled. This board * does not currently support EL3 so the CPU EL3 property is disabled * before realization. */ if (object_property_find (cpuobj,"has_el3" ,NULL )) { -object_property_set_bool (cpuobj, false,"has_el3" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } +object_property_set_bool (cpuobj, false,"has_el3" , &error_fatal); }if (is_pb && is_mpcore) { -object_property_set_int (cpuobj, periphbase,"reset-cbar" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } +object_property_set_int (cpuobj, periphbase,"reset-cbar" , + &error_fatal); } -object_property_set_bool (cpuobj, true,"realized" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } +object_property_set_bool (cpuobj, true,"realized" , &error_fatal); cpu_irq[n] =qdev_get_gpio_in (DEVICE (cpuobj),ARM_CPU_IRQ ); }
hw/arm/versatilepb.c +2 -11
@@ -192,7 +192,6 @@ static void versatile_init(MachineState *machine, int board_id)int n;int done_smc =0 ;DriveInfo *dinfo; -Error *err =NULL ;if (!machine->cpu_model) { machine->cpu_model ="arm926" ;
@@ -211,18 +210,10 @@ static void versatile_init(MachineState *machine, int board_id)* realization. */ if (object_property_find (cpuobj,"has_el3" ,NULL )) { -object_property_set_bool (cpuobj, false,"has_el3" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } +object_property_set_bool (cpuobj, false,"has_el3" , &error_fatal); } -object_property_set_bool (cpuobj, true,"realized" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } +object_property_set_bool (cpuobj, true,"realized" , &error_fatal); cpu =ARM_CPU (cpuobj);
hw/arm/vexpress.c +1 -6
@@ -211,7 +211,6 @@ static void init_cpus(const char *cpu_model, const char *privdev,/* Create the actual CPUs */ for (n =0 ; n < smp_cpus; n++) {Object *cpuobj =object_new (object_class_get_name (cpu_oc)); -Error *err =NULL ;if (!secure) {object_property_set_bool (cpuobj, false,"has_el3" ,NULL );
@@ -221,11 +220,7 @@ static void init_cpus(const char *cpu_model, const char *privdev,object_property_set_int (cpuobj, periphbase,"reset-cbar" , &error_abort); } -object_property_set_bool (cpuobj, true,"realized" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } +object_property_set_bool (cpuobj, true,"realized" , &error_fatal); }/* Create the private peripheral devices (including the GIC);
hw/arm/xilinx_zynq.c +6 -22
@@ -156,7 +156,6 @@ static void zynq_init(MachineState *machine)DeviceState *dev;SysBusDevice *busdev;qemu_irq pic[64 ]; -Error *err =NULL ;int n;if (!cpu_model) {
@@ -171,29 +170,14 @@ static void zynq_init(MachineState *machine)* realization. */ if (object_property_find (OBJECT (cpu),"has_el3" ,NULL )) { -object_property_set_bool (OBJECT (cpu), false,"has_el3" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } +object_property_set_bool (OBJECT (cpu), false,"has_el3" , &error_fatal); } -object_property_set_int (OBJECT (cpu),ZYNQ_BOARD_MIDR ,"midr" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } - -object_property_set_int (OBJECT (cpu),MPCORE_PERIPHBASE ,"reset-cbar" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } -object_property_set_bool (OBJECT (cpu), true,"realized" , &err); -if (err) { -error_report_err (err); -exit (1 ); - } +object_property_set_int (OBJECT (cpu),ZYNQ_BOARD_MIDR ,"midr" , + &error_fatal); +object_property_set_int (OBJECT (cpu),MPCORE_PERIPHBASE ,"reset-cbar" , + &error_fatal); +object_property_set_bool (OBJECT (cpu), true,"realized" , &error_fatal);/* max 2GB ram */ if (ram_size >0x80000000 ) {
hw/char/serial.c +2 -12
@@ -888,18 +888,13 @@ SerialState *serial_init(int base, qemu_irq irq, int baudbase, CharDriverState *chr, MemoryRegion *system_io) {SerialState *s; -Error *err =NULL ; s =g_malloc0 (sizeof (SerialState)); s->irq = irq; s->baudbase = baudbase; s->chr = chr; -serial_realize_core (s, &err); -if (err !=NULL ) { -error_report_err (err); -exit (1 ); - } +serial_realize_core (s, &error_fatal);vmstate_register (NULL , base, &vmstate_serial, s);
@@ -949,7 +944,6 @@ SerialState *serial_mm_init(MemoryRegion *address_space, CharDriverState *chr, enum device_endian end) {SerialState *s; -Error *err =NULL ; s =g_malloc0 (sizeof (SerialState));
@@ -958,11 +952,7 @@ SerialState *serial_mm_init(MemoryRegion *address_space, s->baudbase = baudbase; s->chr = chr; -serial_realize_core (s, &err); -if (err !=NULL ) { -error_report_err (err); -exit (1 ); - } +serial_realize_core (s, &error_fatal);vmstate_register (NULL , base, &vmstate_serial, s); memory_region_init_io(&s->io, NULL, &serial_mm_ops[end], s,
hw/core/qdev-properties-system.c +1 -7
@@ -367,13 +367,7 @@ void qdev_prop_set_drive(DeviceState *dev, const char *name,void qdev_prop_set_drive_nofail (DeviceState *dev,const char *name,BlockBackend *value) { -Error *err =NULL ; - -qdev_prop_set_drive (dev, name, value, &err); -if (err) { -error_report_err (err); -exit (1 ); - } +qdev_prop_set_drive (dev, name, value, &error_fatal); } void qdev_prop_set_chr(DeviceState *dev, const char *name,
hw/i386/pc.c +2 -12
@@ -433,7 +433,6 @@ void pc_cmos_init(PCMachineState *pcms, {int val;static pc_cmos_init_late_arg arg; -Error *local_err =NULL ;/* various important CMOS locations needed by PC/Bochs bios */
@@ -481,11 +480,7 @@ void pc_cmos_init(PCMachineState *pcms,object_property_set_link (OBJECT (pcms),OBJECT (s),"rtc_state" , &error_abort); -set_boot_dev (s,MACHINE (pcms)->boot_order, &local_err); -if (local_err) { -error_report_err (local_err); -exit (1 ); - } +set_boot_dev (s,MACHINE (pcms)->boot_order, &error_fatal); val =0 ; val |=0x02 ;/* FPU is there */
@@ -1122,7 +1117,6 @@ void pc_cpus_init(PCMachineState *pcms)int i;X86CPU *cpu =NULL ;MachineState *machine =MACHINE (pcms); -Error *error =NULL ;unsigned long apic_id_limit;/* init CPUs */
@@ -1143,11 +1137,7 @@ void pc_cpus_init(PCMachineState *pcms)for (i =0 ; i < smp_cpus; i++) { cpu =pc_new_cpu (machine->cpu_model,x86_cpu_apic_id_from_index (i), - &error); -if (error) { -error_report_err (error); -exit (1 ); - } + &error_fatal);object_unref (OBJECT (cpu)); }
hw/smbios/smbios.c +7 -36
91 lines not on this page · raw message
numa.c +2 -6
@@ -450,17 +450,13 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,memory_region_init (mr, owner, name, ram_size);for (i =0 ; i <MAX_NODES ; i++) { -Error *local_err =NULL ;uint64_t size = numa_info[i].node_mem;HostMemoryBackend *backend = numa_info[i].node_memdev;if (!backend) {continue ; } -MemoryRegion *seg =host_memory_backend_get_memory (backend, &local_err); -if (local_err) { -error_report_err (local_err); -exit (1 ); - } +MemoryRegion *seg =host_memory_backend_get_memory (backend, + &error_fatal);if (memory_region_is_mapped (seg)) {char *path =object_get_canonical_path_component (OBJECT (backend));
vl.c +3 -18
@@ -4329,12 +4329,7 @@ int main(int argc, char **argv, char **envp)configure_accelerator (current_machine);if (qtest_chrdev) { -Error *local_err =NULL ; -qtest_init (qtest_chrdev, qtest_log, &local_err); -if (local_err) { -error_report_err (local_err); -exit (1 ); - } +qtest_init (qtest_chrdev, qtest_log, &error_fatal); } machine_opts =qemu_get_machine_opts ();
@@ -4345,24 +4340,14 @@ int main(int argc, char **argv, char **envp) opts =qemu_opts_find (qemu_find_opts ("boot-opts" ),NULL );if (opts) { -Error *local_err =NULL ; - boot_order =qemu_opt_get (opts,"order" );if (boot_order) { -validate_bootdevices (boot_order, &local_err); -if (local_err) { -error_report_err (local_err); -exit (1 ); - } +validate_bootdevices (boot_order, &error_fatal); } boot_once =qemu_opt_get (opts,"once" );if (boot_once) { -validate_bootdevices (boot_once, &local_err); -if (local_err) { -error_report_err (local_err); -exit (1 ); - } +validate_bootdevices (boot_once, &error_fatal); } boot_menu =qemu_opt_get_bool (opts,"menu" , boot_menu);
Signature · 1 line
2.4.3
Quoted 2 lines · Markus Armbruster
Done with this admittedly crude Coccinelle semantic patch:
You can rewrite the semantic patch as:
@@
type T;
identifier FUN, RET;
expression list ARGS;
expression ERR, EC;
@@
(
- T RET = FUN(ARGS, &ERR);
+ T RET = FUN(ARGS, &error_fatal);
|
- RET = FUN(ARGS, &ERR);
+ RET = FUN(ARGS, &error_fatal);
|
- FUN(ARGS, &ERR);
+ FUN(ARGS, &error_fatal);
)
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
Coccinelle seems to have some magic to make "LIST," also match with an empty list.
Quoted 127 lines
@@
identifier FUN;
expression ERR, EC;
@@
-FUN(&ERR);
- if (ERR != NULL) {
-error_report_err(ERR);
- exit(EC);
- }
+FUN(&error_fatal);
@@
identifier FUN;
expression ARG1, ERR, EC;
@@
-FUN(ARG1, &ERR);
- if (ERR != NULL) {
-error_report_err(ERR);
- exit(EC);
- }
+FUN(ARG1, &error_fatal);
@@
identifier FUN;
expression ARG1, ARG2, ERR, EC;
@@
-FUN(ARG1, ARG2, &ERR);
- if (ERR != NULL) {
-error_report_err(ERR);
- exit(EC);
- }
+FUN(ARG1, ARG2, &error_fatal);
@@
identifier FUN;
expression ARG1, ARG2, ARG3, ERR, EC;
@@
-FUN(ARG1, ARG2, ARG3, &ERR);
- if (ERR != NULL) {
-error_report_err(ERR);
- exit(EC);
- }
+FUN(ARG1, ARG2, ARG3, &error_fatal);
@@
identifier FUN;
expression RET, ERR, EC;
@@
- RET =FUN(&ERR);
- if (ERR != NULL) {
-error_report_err(ERR);
- exit(EC);
- }
+ RET =FUN(&error_fatal);
@@
identifier FUN;
expression RET, ARG1, ERR, EC;
@@
- RET =FUN(ARG1, &ERR);
- if (ERR != NULL) {
-error_report_err(ERR);
- exit(EC);
- }
+ RET =FUN(ARG1, &error_fatal);
@@
identifier FUN;
expression RET, ARG1, ARG2, ERR, EC;
@@
- RET =FUN(ARG1, ARG2, &ERR);
- if (ERR != NULL) {
-error_report_err(ERR);
- exit(EC);
- }
+ RET =FUN(ARG1, ARG2, &error_fatal);
@@
identifier FUN;
expression RET, ARG1, ARG2, ARG3, ERR, EC;
@@
- RET =FUN(ARG1, ARG2, ARG3, &ERR);
- if (ERR != NULL) {
-error_report_err(ERR);
- exit(EC);
- }
+ RET =FUN(ARG1, ARG2, ARG3, &error_fatal);
@@
type T;
identifier FUN, RET;
expression ERR, EC;
@@
- T RET =FUN(&ERR);
- if (ERR != NULL) {
-error_report_err(ERR);
- exit(EC);
- }
+ T RET =FUN(&error_fatal);
@@
type T;
identifier FUN, RET;
expression ARG1, ERR, EC;
@@
- T RET =FUN(ARG1, &ERR);
- if (ERR != NULL) {
-error_report_err(ERR);
- exit(EC);
- }
+ T RET =FUN(ARG1, &error_fatal);
@@
type T;
identifier FUN, RET;
expression ARG1, ARG2, ERR, EC;
@@
- T RET =FUN(ARG1, ARG2, &ERR);
- if (ERR != NULL) {
-error_report_err(ERR);
- exit(EC);
- }
+ T RET =FUN(ARG1, ARG2, &error_fatal);
@@
type T;
identifier FUN, RET;
expression ARG1, ARG2, ARG3, ERR, EC;
@@
- T RET =FUN(ARG1, ARG2, ARG3, &ERR);
- if (ERR != NULL) {
-error_report_err(ERR);
- exit(EC);
- }
+ T RET =FUN(ARG1, ARG2, ARG3, &error_fatal);This leaves dead Error * variables behind, cleaned up manually.
Signature · 1 line
Eduardo
Quoted 30 lines · Eduardo Habkost
Quoted 2 lines · Markus Armbruster
Done with this admittedly crude Coccinelle semantic patch:
Reviewed-by Eduardo Habkost <[email protected]>You can rewrite the semantic patch as:
@@
type T;
identifier FUN, RET;
expression list ARGS;
expression ERR, EC;
@@
(
- T RET =FUN(ARGS, &ERR);
+ T RET =FUN(ARGS, &error_fatal);
|
- RET =FUN(ARGS, &ERR);
+ RET =FUN(ARGS, &error_fatal);
|
-FUN(ARGS, &ERR);
+FUN(ARGS, &error_fatal);
)
- if (ERR != NULL) {
-error_report_err(ERR);
- exit(EC);
- }
Quoted 2 lines
Coccinelle seems to have some magic to make "LIST," also match with an empty list.
Same output as my script, except it doesn't mess up zynq_init(). Sold!
Quoted 9 lines · Markus Armbruster
Quoted 7 lines · Eduardo Habkost
Quoted 2 lines · Markus Armbruster
Done with this admittedly crude Coccinelle semantic patch:
Reviewed-by Eduardo Habkost <[email protected]>You can rewrite the semantic patch as:
[...]
Quoted 4 lines
Quoted 2 lines
Coccinelle seems to have some magic to make "LIST," also match with an empty list.
Same output as my script, except it doesn't mess up
zynq_init(). Sold!
Do you mean by this that you're planning to send a v3, or would you like me to apply v2 to target-arm.next?
thanks
-- PMM
Markus Armbruster
Reviewed-by Eduardo HabkostQuoted 10 lines · Peter Maydell
Quoted 9 lines · Markus Armbruster
Quoted 7 lines · Eduardo Habkost
Quoted 2 lines · Markus Armbruster
Done with this admittedly crude Coccinelle semantic patch:
Reviewed-by Eduardo Habkost <[email protected]>You can rewrite the semantic patch as:
Quoted 8 lines
[...]
Quoted 4 lines
Quoted 2 lines
Coccinelle seems to have some magic to make "LIST," also match with an empty list.
Same output as my script, except it doesn't mess up
zynq_init(). Sold!Do you mean by this that you're planning to send a v3, or would you like me to apply v2 to target-arm.next?
I only changed PATCH 1's commit message since v2 (current version appended). I plan to include the series in a pull request in my role as error reporting maintainer, but I don't mind "losing" patches to other maintainers on the way.
Use error_fatal to simplify obvious fatal errors
Done with this Coccinelle semantic patch:
@@
type T;
identifier FUN, RET;
expression list ARGS;
expression ERR, EC;
@@
(
- T RET = FUN(ARGS, &ERR);
+ T RET = FUN(ARGS, &error_fatal);
|
- RET = FUN(ARGS, &ERR);
+ RET = FUN(ARGS, &error_fatal);
|
- FUN(ARGS, &ERR);
+ FUN(ARGS, &error_fatal);
)
- if (ERR != NULL) {
- error_report_err(ERR);
- exit(EC);
- }
This is actually a more elegant version of my initial semantic patch by courtesy of Eduardo.
It leaves dead Error * variables behind, cleaned up manually.
Quoted 8 lines · Markus Armbruster
Quoted 2 lines · Peter Maydell
Do you mean by this that you're planning to send a v3, or would you like me to apply v2 to target-arm.next?
I only changed PATCH 1's commit message since v2 (current version appended). I plan to include the series in a pull request in my role as error reporting maintainer, but I don't mind "losing" patches to other maintainers on the way.
OK, I'm happy to let you take it via your tree.
thanks
-- PMM
PATCH v2 2/2 hw: Inline the qdev_prop_set_drive_nofail() wrapper
In reply to Markus Armbruster--- hw/arm/nseries.c | 4 ++-- hw/block/fdc.c | 15 ++++++++++----- hw/block/nand.c | 2 +- hw/core/qdev-properties-system.c | 6 ------ hw/ide/qdev.c | 3 ++- hw/isa/pc87312.c | 8 ++++---- hw/ppc/spapr.c | 3 ++- include/hw/qdev-properties.h | 2 -- 8 files changed, 21 insertions(+), 22 deletions(-)
hw/arm/nseries.c +2 -2
@@ -172,8 +172,8 @@ static void n8x0_nand_setup(struct n800_s *s)qdev_prop_set_int32 (s->nand,"shift" ,1 ); dinfo =drive_get (IF_MTD ,0 ,0 );if (dinfo) { -qdev_prop_set_drive_nofail (s->nand,"drive" , -blk_by_legacy_dinfo (dinfo)); +qdev_prop_set_drive (s->nand,"drive" ,blk_by_legacy_dinfo (dinfo), + &error_fatal); }qdev_init_nofail (s->nand); sysbus_connect_irq(SYS_BUS_DEVICE(s->nand), 0,
hw/block/fdc.c +10 -5
@@ -2245,10 +2245,12 @@ ISADevice *fdctrl_init_isa(ISABus *bus, DriveInfo **fds) dev =DEVICE (isadev);if (fds[0 ]) { -qdev_prop_set_drive_nofail (dev,"driveA" ,blk_by_legacy_dinfo (fds[0 ])); +qdev_prop_set_drive (dev,"driveA" ,blk_by_legacy_dinfo (fds[0 ]), + &error_fatal); }if (fds[1 ]) { -qdev_prop_set_drive_nofail (dev,"driveB" ,blk_by_legacy_dinfo (fds[1 ])); +qdev_prop_set_drive (dev,"driveB" ,blk_by_legacy_dinfo (fds[1 ]), + &error_fatal); }qdev_init_nofail (dev);
@@ -2268,10 +2270,12 @@ void fdctrl_init_sysbus(qemu_irq irq, int dma_chann, fdctrl = &sys->state; fdctrl->dma_chann = dma_chann;/* FIXME */ if (fds[0 ]) { -qdev_prop_set_drive_nofail (dev,"driveA" ,blk_by_legacy_dinfo (fds[0 ])); +qdev_prop_set_drive (dev,"driveA" ,blk_by_legacy_dinfo (fds[0 ]), + &error_fatal); }if (fds[1 ]) { -qdev_prop_set_drive_nofail (dev,"driveB" ,blk_by_legacy_dinfo (fds[1 ])); +qdev_prop_set_drive (dev,"driveB" ,blk_by_legacy_dinfo (fds[1 ]), + &error_fatal); }qdev_init_nofail (dev); sbd =SYS_BUS_DEVICE (dev);
@@ -2287,7 +2291,8 @@ void sun4m_fdctrl_init(qemu_irq irq, hwaddr io_base, dev =qdev_create (NULL ,"SUNW,fdtwo" );if (fds[0 ]) { -qdev_prop_set_drive_nofail (dev,"drive" ,blk_by_legacy_dinfo (fds[0 ])); +qdev_prop_set_drive (dev,"drive" ,blk_by_legacy_dinfo (fds[0 ]), + &error_fatal); }qdev_init_nofail (dev); sys =SYSBUS_FDC (dev);
hw/block/nand.c +1 -1
@@ -635,7 +635,7 @@ DeviceState *nand_init(BlockBackend *blk, int manf_id, int chip_id)qdev_prop_set_uint8 (dev,"manufacturer_id" , manf_id);qdev_prop_set_uint8 (dev,"chip_id" , chip_id);if (blk) { -qdev_prop_set_drive_nofail (dev,"drive" , blk); +qdev_prop_set_drive (dev,"drive" , blk, &error_fatal); }qdev_init_nofail (dev);
hw/core/qdev-properties-system.c +0 -6
@@ -364,12 +364,6 @@ void qdev_prop_set_drive(DeviceState *dev, const char *name, name, errp); } -void qdev_prop_set_drive_nofail (DeviceState *dev,const char *name, -BlockBackend *value) -{ -qdev_prop_set_drive (dev, name, value, &error_fatal); -} -void qdev_prop_set_chr (DeviceState *dev,const char *name,CharDriverState *value) {
hw/ide/qdev.c +2 -1
@@ -118,7 +118,8 @@ IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive) dev =qdev_create (&bus->qbus, drive->media_cd ?"ide-cd" :"ide-hd" );qdev_prop_set_uint32 (dev,"unit" , unit); -qdev_prop_set_drive_nofail (dev,"drive" ,blk_by_legacy_dinfo (drive)); +qdev_prop_set_drive (dev,"drive" ,blk_by_legacy_dinfo (drive), + &error_fatal);qdev_init_nofail (dev);return DO_UPCAST (IDEDevice, qdev, dev); }
hw/isa/pc87312.c +4 -4
@@ -324,14 +324,14 @@ static void pc87312_realize(DeviceState *dev, Error **errp)/* FIXME use a qdev drive property instead of drive_get() */ drive =drive_get (IF_FLOPPY ,0 ,0 );if (drive !=NULL ) { -qdev_prop_set_drive_nofail (d,"driveA" , -blk_by_legacy_dinfo (drive)); +qdev_prop_set_drive (d,"driveA" ,blk_by_legacy_dinfo (drive), + &error_fatal); }/* FIXME use a qdev drive property instead of drive_get() */ drive =drive_get (IF_FLOPPY ,0 ,1 );if (drive !=NULL ) { -qdev_prop_set_drive_nofail (d,"driveB" , -blk_by_legacy_dinfo (drive)); +qdev_prop_set_drive (d,"driveB" ,blk_by_legacy_dinfo (drive), + &error_fatal); }qdev_init_nofail (d); s->fdc.dev = isa;
hw/ppc/spapr.c +2 -1
@@ -1213,7 +1213,8 @@ static void spapr_create_nvram(sPAPRMachineState *spapr)DriveInfo *dinfo =drive_get (IF_PFLASH ,0 ,0 );if (dinfo) { -qdev_prop_set_drive_nofail (dev,"drive" ,blk_by_legacy_dinfo (dinfo)); +qdev_prop_set_drive (dev,"drive" ,blk_by_legacy_dinfo (dinfo), + &error_fatal); }qdev_init_nofail (dev);
include/hw/qdev-properties.h +0 -2
@@ -180,8 +180,6 @@ void qdev_prop_set_chr(DeviceState *dev, const char *name, CharDriverState *valuvoid qdev_prop_set_netdev (DeviceState *dev,const char *name,NetClientState *value);void qdev_prop_set_drive (DeviceState *dev,const char *name,BlockBackend *value,Error **errp); -void qdev_prop_set_drive_nofail (DeviceState *dev,const char *name, -BlockBackend *value);void qdev_prop_set_macaddr (DeviceState *dev,const char *name,uint8_t *value);void qdev_prop_set_enum (DeviceState *dev,const char *name,int value);/* FIXME: Remove opaque pointer properties. */
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH v2 2/2] hw: Inline the qdev_prop_set_drive_nofail() wrapper
Quoted 11 lines · Markus Armbruster
Signed-off-by Markus Armbruster <[email protected]>--- hw/arm/nseries.c | 4 ++-- hw/block/fdc.c | 15 ++++++++++----- hw/block/nand.c | 2 +- hw/core/qdev-properties-system.c | 6 ------ hw/ide/qdev.c | 3 ++- hw/isa/pc87312.c | 8 ++++---- hw/ppc/spapr.c | 3 ++- include/hw/qdev-properties.h | 2 -- 8 files changed, 21 insertions(+), 22 deletions(-)
thanks
-- PMM