All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
@ 2016-09-16 13:55 Laurent Vivier
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 01/26] coccinelle: " Laurent Vivier
                   ` (28 more replies)
  0 siblings, 29 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:55 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier

This series is the result of coccinelle patch
scripts/coccinelle/exit.cocci
provided by the first patch of the series.

It replaces exit(0) by exit(EXIT_SUCCESS)
and exit(1) by exit(EXIT_FAILURE).

All other exit() are not modified as we don't want
to change the behavior.

In some cases, I've added manually a line break to comply
with the maximum line length.

Laurent Vivier (26):
  coccinelle: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  arm: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  cris: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  block: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  ppc: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  graphics: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  tests: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  replay: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  qemu-user: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  m68k: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  pci,virtio: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  sparc: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  sh4: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  x86: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  mips: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  s390: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  tcg: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  posix: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  alpha: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  common: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  misc machine: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  blockdev: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  core: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  error,trace: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  hw: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  net: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)

 accel.c                                     |   2 +-
 arch_init.c                                 |   6 +-
 bootdevice.c                                |   2 +-
 bsd-user/main.c                             |  20 +--
 contrib/ivshmem-server/main.c               |  12 +-
 cpus.c                                      |  16 +-
 cputlb.c                                    |   2 +-
 device_tree.c                               |  18 +-
 exec.c                                      |   2 +-
 gdbstub.c                                   |   2 +-
 hw/9pfs/9p.c                                |   2 +-
 hw/alpha/dp264.c                            |   8 +-
 hw/arm/armv7m.c                             |   6 +-
 hw/arm/boot.c                               |  16 +-
 hw/arm/cubieboard.c                         |   8 +-
 hw/arm/digic_boards.c                       |   6 +-
 hw/arm/fsl-imx6.c                           |   2 +-
 hw/arm/gumstix.c                            |   8 +-
 hw/arm/highbank.c                           |   4 +-
 hw/arm/integratorcp.c                       |   2 +-
 hw/arm/mainstone.c                          |   4 +-
 hw/arm/musicpal.c                           |   4 +-
 hw/arm/omap1.c                              |   4 +-
 hw/arm/omap2.c                              |   4 +-
 hw/arm/omap_sx1.c                           |   2 +-
 hw/arm/palm.c                               |   2 +-
 hw/arm/pxa2xx.c                             |  10 +-
 hw/arm/raspi.c                              |   4 +-
 hw/arm/realview.c                           |   2 +-
 hw/arm/sabrelite.c                          |   4 +-
 hw/arm/strongarm.c                          |   4 +-
 hw/arm/sysbus-fdt.c                         |   2 +-
 hw/arm/versatilepb.c                        |   2 +-
 hw/arm/vexpress.c                           |  16 +-
 hw/arm/virt.c                               |  24 +--
 hw/arm/xlnx-ep108.c                         |   4 +-
 hw/arm/z2.c                                 |   4 +-
 hw/block/pflash_cfi01.c                     |   2 +-
 hw/block/tc58128.c                          |   2 +-
 hw/block/virtio-blk.c                       |   6 +-
 hw/char/exynos4210_uart.c                   |   4 +-
 hw/core/machine.c                           |   2 +-
 hw/core/platform-bus.c                      |   4 +-
 hw/core/qdev.c                              |   2 +-
 hw/cris/axis_dev88.c                        |   2 +-
 hw/cris/boot.c                              |   4 +-
 hw/display/pl110.c                          |   2 +-
 hw/display/pxa2xx_lcd.c                     |   2 +-
 hw/display/ssd0303.c                        |   3 +-
 hw/gpio/pl061.c                             |   3 +-
 hw/i2c/smbus.c                              |   3 +-
 hw/i386/intel_iommu.c                       |   2 +-
 hw/i386/multiboot.c                         |  10 +-
 hw/i386/pc.c                                |  24 +--
 hw/i386/pc_piix.c                           |   2 +-
 hw/i386/pc_sysfw.c                          |   6 +-
 hw/i386/x86-iommu.c                         |   2 +-
 hw/ide/core.c                               |   2 +-
 hw/intc/ioapic.c                            |   2 +-
 hw/intc/xics_kvm.c                          |   6 +-
 hw/lm32/lm32_boards.c                       |   8 +-
 hw/lm32/milkymist.c                         |   6 +-
 hw/m68k/an5206.c                            |   6 +-
 hw/m68k/dummy_m68k.c                        |   4 +-
 hw/m68k/mcf5208.c                           |   8 +-
 hw/mips/mips_fulong2e.c                     |  12 +-
 hw/mips/mips_jazz.c                         |  10 +-
 hw/mips/mips_malta.c                        |  20 +--
 hw/mips/mips_mipssim.c                      |  10 +-
 hw/mips/mips_r4k.c                          |  10 +-
 hw/moxie/moxiesim.c                         |   8 +-
 hw/net/stellaris_enet.c                     |   3 +-
 hw/net/virtio-net.c                         |  10 +-
 hw/nvram/eeprom93xx.c                       |   2 +-
 hw/nvram/fw_cfg.c                           |   2 +-
 hw/openrisc/openrisc_sim.c                  |   4 +-
 hw/pci-host/bonito.c                        |   2 +-
 hw/pci/pci.c                                |  12 +-
 hw/ppc/e500.c                               |  14 +-
 hw/ppc/mac_newworld.c                       |  12 +-
 hw/ppc/mac_oldworld.c                       |  16 +-
 hw/ppc/mpc8544ds.c                          |   2 +-
 hw/ppc/ppc.c                                |   4 +-
 hw/ppc/ppc405_boards.c                      |  16 +-
 hw/ppc/ppc440_bamboo.c                      |  10 +-
 hw/ppc/ppc4xx_devs.c                        |   2 +-
 hw/ppc/prep.c                               |  12 +-
 hw/ppc/spapr.c                              |  52 +++---
 hw/ppc/virtex_ml507.c                       |   4 +-
 hw/scsi/lsi53c895a.c                        |   7 +-
 hw/scsi/vhost-scsi.c                        |   4 +-
 hw/scsi/virtio-scsi-dataplane.c             |   2 +-
 hw/scsi/virtio-scsi.c                       |   6 +-
 hw/sd/omap_mmc.c                            |   4 +-
 hw/sd/ssi-sd.c                              |   3 +-
 hw/sh4/r2d.c                                |   6 +-
 hw/sh4/shix.c                               |   4 +-
 hw/smbios/smbios.c                          |  22 +--
 hw/sparc/leon3.c                            |  12 +-
 hw/sparc/sun4m.c                            |  22 +--
 hw/sparc64/sun4u.c                          |   8 +-
 hw/ssi/pl022.c                              |   3 +-
 hw/tricore/tricore_testboard.c              |   4 +-
 hw/unicore32/puv3.c                         |   6 +-
 hw/virtio/virtio.c                          |  28 +--
 hw/watchdog/watchdog.c                      |   2 +-
 hw/xenpv/xen_machine_pv.c                   |   8 +-
 kvm-all.c                                   |   8 +-
 linux-user/main.c                           |   4 +-
 linux-user/syscall.c                        |   2 +-
 net/net.c                                   |   4 +-
 numa.c                                      |  12 +-
 os-posix.c                                  |  34 ++--
 qemu-char.c                                 |   6 +-
 qemu-img.c                                  |   4 +-
 qemu-io.c                                   |  24 +--
 qemu-nbd.c                                  |   6 +-
 replay/replay-char.c                        |   6 +-
 replay/replay-events.c                      |   6 +-
 replay/replay-internal.c                    |   2 +-
 replay/replay-time.c                        |   2 +-
 replay/replay.c                             |  14 +-
 scripts/coccinelle/exit.cocci               |  12 ++
 slirp/misc.c                                |   2 +-
 target-arm/kvm.c                            |   2 +-
 target-arm/machine.c                        |   2 +-
 target-i386/kvm.c                           |   8 +-
 target-i386/machine.c                       |   2 +-
 target-ppc/kvm.c                            |   6 +-
 target-ppc/translate.c                      |   2 +-
 target-ppc/translate_init.c                 |  28 +--
 target-s390x/cpu.c                          |   2 +-
 target-s390x/kvm.c                          |  18 +-
 target-s390x/mmu_helper.c                   |   2 +-
 tcg/ppc/tcg-target.inc.c                    |   6 +-
 tcg/tcg.c                                   |   2 +-
 tests/ipmi-bt-test.c                        |   6 +-
 tests/libqtest.c                            |   8 +-
 tests/migration/stress.c                    |   4 +-
 tests/qht-bench.c                           |   2 +-
 tests/rcutorture.c                          |   4 +-
 tests/tcg/cris/check_gcctorture_pr28634-1.c |   2 +-
 tests/tcg/cris/check_gcctorture_pr28634.c   |   2 +-
 tests/tcg/cris/check_glibc_kernelversion.c  |   2 +-
 tests/tcg/cris/check_hello.c                |   2 +-
 tests/tcg/cris/check_lz.c                   |   2 +-
 tests/tcg/cris/check_mapbrk.c               |   6 +-
 tests/tcg/cris/check_mmap1.c                |   2 +-
 tests/tcg/cris/check_mmap2.c                |   2 +-
 tests/tcg/cris/check_mmap3.c                |   2 +-
 tests/tcg/cris/check_openpf5.c              |   2 +-
 tests/tcg/cris/check_stat1.c                |   2 +-
 tests/tcg/cris/check_stat2.c                |   2 +-
 tests/tcg/cris/check_stat3.c                |   2 +-
 tests/tcg/cris/check_stat4.c                |   2 +-
 tests/tcg/cris/check_time1.c                |   2 +-
 tests/tcg/cris/check_time2.c                |   2 +-
 tests/tcg/cris/sys.c                        |   2 +-
 tests/tcg/hello-i386.c                      |   2 +-
 tests/tcg/linux-test.c                      |   4 +-
 tests/tcg/runcom.c                          |  12 +-
 tests/tcg/test_path.c                       |   2 +-
 tests/test-aio.c                            |   2 +-
 tests/test-iov.c                            |   8 +-
 tests/test-thread-pool.c                    |   2 +-
 tests/vhost-user-bridge.c                   |  18 +-
 trace/control.c                             |  10 +-
 translate-all.c                             |   2 +-
 ui/console-gl.c                             |   2 +-
 ui/console.c                                |   2 +-
 ui/curses.c                                 |   4 +-
 ui/gtk.c                                    |   2 +-
 ui/sdl.c                                    |   8 +-
 ui/sdl2.c                                   |   2 +-
 ui/spice-core.c                             |  22 +--
 ui/vnc.c                                    |   4 +-
 util/error.c                                |   2 +-
 util/oslib-posix.c                          |   2 +-
 util/qemu-timer-common.c                    |   2 +-
 vl.c                                        | 270 ++++++++++++++--------------
 xen-common.c                                |   4 +-
 xen-hvm.c                                   |   2 +-
 182 files changed, 734 insertions(+), 715 deletions(-)
 create mode 100644 scripts/coccinelle/exit.cocci

-- 
2.5.5

^ permalink raw reply	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 01/26] coccinelle: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
@ 2016-09-16 13:55 ` Laurent Vivier
  2016-09-16 15:35   ` Eric Blake
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 02/26] arm: " Laurent Vivier
                   ` (27 subsequent siblings)
  28 siblings, 1 reply; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:55 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 scripts/coccinelle/exit.cocci | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 scripts/coccinelle/exit.cocci

diff --git a/scripts/coccinelle/exit.cocci b/scripts/coccinelle/exit.cocci
new file mode 100644
index 0000000..73386c0
--- /dev/null
+++ b/scripts/coccinelle/exit.cocci
@@ -0,0 +1,12 @@
+// replace exit(0) by exit(EXIT_SUCCESS)
+//         exit(1) by exit(EXIT_FAILURE)
+
+@@
+@@
+(
+- exit(0)
++ exit(EXIT_SUCCESS)
+|
+- exit(1)
++ exit(EXIT_FAILURE)
+)
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 02/26] arm: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 01/26] coccinelle: " Laurent Vivier
@ 2016-09-16 13:55 ` Laurent Vivier
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 03/26] cris: " Laurent Vivier
                   ` (26 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:55 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Peter Maydell

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/armv7m.c           |  6 +++---
 hw/arm/boot.c             | 16 ++++++++--------
 hw/arm/cubieboard.c       |  8 ++++----
 hw/arm/digic_boards.c     |  6 +++---
 hw/arm/fsl-imx6.c         |  2 +-
 hw/arm/gumstix.c          |  8 ++++----
 hw/arm/highbank.c         |  4 ++--
 hw/arm/integratorcp.c     |  2 +-
 hw/arm/mainstone.c        |  4 ++--
 hw/arm/musicpal.c         |  4 ++--
 hw/arm/omap1.c            |  4 ++--
 hw/arm/omap2.c            |  4 ++--
 hw/arm/omap_sx1.c         |  2 +-
 hw/arm/palm.c             |  2 +-
 hw/arm/pxa2xx.c           | 10 +++++-----
 hw/arm/raspi.c            |  4 ++--
 hw/arm/realview.c         |  2 +-
 hw/arm/sabrelite.c        |  4 ++--
 hw/arm/strongarm.c        |  4 ++--
 hw/arm/sysbus-fdt.c       |  2 +-
 hw/arm/versatilepb.c      |  2 +-
 hw/arm/vexpress.c         | 16 ++++++++--------
 hw/arm/virt.c             | 24 ++++++++++++------------
 hw/arm/xlnx-ep108.c       |  4 ++--
 hw/arm/z2.c               |  4 ++--
 hw/char/exynos4210_uart.c |  4 ++--
 hw/display/pl110.c        |  2 +-
 hw/display/pxa2xx_lcd.c   |  2 +-
 hw/gpio/pl061.c           |  3 ++-
 hw/net/stellaris_enet.c   |  3 ++-
 hw/sd/omap_mmc.c          |  4 ++--
 hw/ssi/pl022.c            |  3 ++-
 target-arm/kvm.c          |  2 +-
 target-arm/machine.c      |  2 +-
 34 files changed, 88 insertions(+), 85 deletions(-)

diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index 49d3078..a86a1f0 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -188,7 +188,7 @@ DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
     cpu = cpu_arm_init(cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
@@ -209,7 +209,7 @@ DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
 
     if (!kernel_filename && !qtest_enabled()) {
         fprintf(stderr, "Guest image must be specified (using -kernel)\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (kernel_filename) {
@@ -221,7 +221,7 @@ DeviceState *armv7m_init(MemoryRegion *system_memory, int mem_size, int num_irq,
         }
         if (image_size < 0) {
             error_report("Could not load kernel '%s'", kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 1b913a4..3c9aaac 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -671,7 +671,7 @@ static void load_image_to_fw_cfg(FWCfgState *fw_cfg, uint16_t size_key,
 
         if (!g_file_get_contents(image_name, &contents, &length, NULL)) {
             fprintf(stderr, "failed to load \"%s\"\n", image_name);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         size = length;
         data = (uint8_t *)contents;
@@ -745,7 +745,7 @@ static uint64_t arm_load_elf(struct arm_boot_info *info, uint64_t *pentry,
                    1, data_swab);
     if (ret <= 0) {
         /* The header loaded but the image didn't */
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     return ret;
@@ -782,7 +782,7 @@ static void arm_load_kernel_notify(Notifier *notifier, void *data)
              * DTB to the base of RAM for the bootloader to pick up.
              */
             if (load_dtb(info->loader_start, info, 0) < 0) {
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         }
 
@@ -874,7 +874,7 @@ static void arm_load_kernel_notify(Notifier *notifier, void *data)
                 elf_low_addr = 0;
             }
             if (load_dtb(info->loader_start, info, elf_low_addr) < 0) {
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         }
     }
@@ -899,7 +899,7 @@ static void arm_load_kernel_notify(Notifier *notifier, void *data)
     if (kernel_size < 0) {
         fprintf(stderr, "qemu: could not load kernel '%s'\n",
                 info->kernel_filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     info->entry = entry;
     if (is_linux) {
@@ -919,7 +919,7 @@ static void arm_load_kernel_notify(Notifier *notifier, void *data)
             if (initrd_size < 0) {
                 fprintf(stderr, "qemu: could not load initrd '%s'\n",
                         info->initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         } else {
             initrd_size = 0;
@@ -956,7 +956,7 @@ static void arm_load_kernel_notify(Notifier *notifier, void *data)
             /* Place the DTB after the initrd in memory with alignment. */
             dtb_start = QEMU_ALIGN_UP(info->initrd_start + initrd_size, align);
             if (load_dtb(dtb_start, info, 0) < 0) {
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             fixupcontext[FIXUP_ARGPTR] = dtb_start;
         } else {
@@ -965,7 +965,7 @@ static void arm_load_kernel_notify(Notifier *notifier, void *data)
                 fprintf(stderr, "qemu: RAM size must be less than 4GB to boot"
                         " Linux kernel using ATAGS (try passing a device tree"
                         " using -dtb)\n");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         }
         fixupcontext[FIXUP_ENTRYPOINT] = entry;
diff --git a/hw/arm/cubieboard.c b/hw/arm/cubieboard.c
index fbd78ed..e193baf 100644
--- a/hw/arm/cubieboard.c
+++ b/hw/arm/cubieboard.c
@@ -44,26 +44,26 @@ static void cubieboard_init(MachineState *machine)
     object_property_set_int(OBJECT(&s->a10->emac), 1, "phy-addr", &err);
     if (err != NULL) {
         error_reportf_err(err, "Couldn't set phy address: ");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     object_property_set_int(OBJECT(&s->a10->timer), 32768, "clk0-freq", &err);
     if (err != NULL) {
         error_reportf_err(err, "Couldn't set clk0 frequency: ");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     object_property_set_int(OBJECT(&s->a10->timer), 24000000, "clk1-freq",
                             &err);
     if (err != NULL) {
         error_reportf_err(err, "Couldn't set clk1 frequency: ");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     object_property_set_bool(OBJECT(s->a10), true, "realized", &err);
     if (err != NULL) {
         error_reportf_err(err, "Couldn't realize Allwinner A10: ");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     memory_region_allocate_system_memory(&s->sdram, NULL, "cubieboard.ram",
diff --git a/hw/arm/digic_boards.c b/hw/arm/digic_boards.c
index 520c8e9..20f3cd6 100644
--- a/hw/arm/digic_boards.c
+++ b/hw/arm/digic_boards.c
@@ -69,7 +69,7 @@ static void digic4_board_init(DigicBoard *board)
     object_property_set_bool(OBJECT(s->digic), true, "realized", &err);
     if (err != NULL) {
         error_reportf_err(err, "Couldn't realize DIGIC SoC: ");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     digic4_board_setup_ram(s, board->ram_size);
@@ -107,13 +107,13 @@ static void digic_load_rom(DigicBoardState *s, hwaddr addr,
 
         if (!fn) {
             error_report("Couldn't find rom image '%s'.", filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         rom_size = load_image_targphys(fn, addr, max_size);
         if (rom_size < 0 || rom_size > max_size) {
             error_report("Couldn't load rom image '%s'.", filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         g_free(fn);
     }
diff --git a/hw/arm/fsl-imx6.c b/hw/arm/fsl-imx6.c
index 6a1bf26..b2cdbc1 100644
--- a/hw/arm/fsl-imx6.c
+++ b/hw/arm/fsl-imx6.c
@@ -38,7 +38,7 @@ static void fsl_imx6_init(Object *obj)
     if (smp_cpus > FSL_IMX6_NUM_CPUS) {
         error_report("%s: Only %d CPUs are supported (%d requested)",
                      TYPE_FSL_IMX6, FSL_IMX6_NUM_CPUS, smp_cpus);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     for (i = 0; i < smp_cpus; i++) {
diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
index d59d9ba..95e2219 100644
--- a/hw/arm/gumstix.c
+++ b/hw/arm/gumstix.c
@@ -63,7 +63,7 @@ static void connex_init(MachineState *machine)
     if (!dinfo && !qtest_enabled()) {
         fprintf(stderr, "A flash image must be given with the "
                 "'pflash' parameter\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
 #ifdef TARGET_WORDS_BIGENDIAN
@@ -76,7 +76,7 @@ static void connex_init(MachineState *machine)
                                sector_len, connex_rom / sector_len,
                                2, 0, 0, 0, 0, be)) {
         fprintf(stderr, "qemu: Error registering flash memory.\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Interrupt line of NIC is connected to GPIO line 36 */
@@ -101,7 +101,7 @@ static void verdex_init(MachineState *machine)
     if (!dinfo && !qtest_enabled()) {
         fprintf(stderr, "A flash image must be given with the "
                 "'pflash' parameter\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
 #ifdef TARGET_WORDS_BIGENDIAN
@@ -114,7 +114,7 @@ static void verdex_init(MachineState *machine)
                                sector_len, verdex_rom / sector_len,
                                2, 0, 0, 0, 0, be)) {
         fprintf(stderr, "qemu: Error registering flash memory.\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Interrupt line of NIC is connected to GPIO line 99 */
diff --git a/hw/arm/highbank.c b/hw/arm/highbank.c
index 80e5fd4..a7ca470 100644
--- a/hw/arm/highbank.c
+++ b/hw/arm/highbank.c
@@ -284,12 +284,12 @@ static void calxeda_init(MachineState *machine, enum cxmachines machine_id)
         if (sysboot_filename != NULL) {
             if (load_image_targphys(sysboot_filename, 0xfff88000, 0x8000) < 0) {
                 error_report("Unable to load %s", bios_name);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             g_free(sysboot_filename);
         } else {
             error_report("Unable to find %s", bios_name);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c
index 96dc150..7c21beb 100644
--- a/hw/arm/integratorcp.c
+++ b/hw/arm/integratorcp.c
@@ -546,7 +546,7 @@ static void integratorcp_init(MachineState *machine)
     cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, cpu_model);
     if (!cpu_oc) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     cpuobj = object_new(object_class_get_name(cpu_oc));
diff --git a/hw/arm/mainstone.c b/hw/arm/mainstone.c
index 454acc5..12f5a1b 100644
--- a/hw/arm/mainstone.c
+++ b/hw/arm/mainstone.c
@@ -145,7 +145,7 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
             }
             fprintf(stderr, "Two flash images must be given with the "
                     "'pflash' parameter\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         if (!pflash_cfi01_register(mainstone_flash_base[i], NULL,
@@ -155,7 +155,7 @@ static void mainstone_common_init(MemoryRegion *address_space_mem,
                                    sector_len, MAINSTONE_FLASH / sector_len,
                                    4, 0, 0, 0, 0, be)) {
             fprintf(stderr, "qemu: Error registering flash memory.\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
diff --git a/hw/arm/musicpal.c b/hw/arm/musicpal.c
index cc50ace..0b7b1b2 100644
--- a/hw/arm/musicpal.c
+++ b/hw/arm/musicpal.c
@@ -1594,7 +1594,7 @@ static void musicpal_init(MachineState *machine)
     cpu = cpu_arm_init(cpu_model);
     if (!cpu) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* For now we use a fixed - the original - RAM size */
@@ -1634,7 +1634,7 @@ static void musicpal_init(MachineState *machine)
         if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 &&
             flash_size != 32*1024*1024) {
             fprintf(stderr, "Invalid flash image size\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         /*
diff --git a/hw/arm/omap1.c b/hw/arm/omap1.c
index b3cf0ec..3c5382a 100644
--- a/hw/arm/omap1.c
+++ b/hw/arm/omap1.c
@@ -3864,7 +3864,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,
     s->cpu = cpu_arm_init(core);
     if (s->cpu == NULL) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     s->sdram_size = sdram_size;
     s->sram_size = OMAP15XX_SRAM_SIZE;
@@ -3996,7 +3996,7 @@ struct omap_mpu_state_s *omap310_mpu_init(MemoryRegion *system_memory,
     dinfo = drive_get(IF_SD, 0, 0);
     if (!dinfo) {
         fprintf(stderr, "qemu: missing SecureDigital device\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     s->mmc = omap_mmc_init(0xfffb7800, system_memory,
                            blk_by_legacy_dinfo(dinfo),
diff --git a/hw/arm/omap2.c b/hw/arm/omap2.c
index 7e11c65..4e9207f 100644
--- a/hw/arm/omap2.c
+++ b/hw/arm/omap2.c
@@ -2262,7 +2262,7 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,
     s->cpu = cpu_arm_init(core ?: "arm1136-r2");
     if (s->cpu == NULL) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     s->sdram_size = sdram_size;
     s->sram_size = OMAP242X_SRAM_SIZE;
@@ -2465,7 +2465,7 @@ struct omap_mpu_state_s *omap2420_mpu_init(MemoryRegion *sysmem,
     dinfo = drive_get(IF_SD, 0, 0);
     if (!dinfo) {
         fprintf(stderr, "qemu: missing SecureDigital device\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     s->mmc = omap2_mmc_init(omap_l4tao(s->l4, 9),
                     blk_by_legacy_dinfo(dinfo),
diff --git a/hw/arm/omap_sx1.c b/hw/arm/omap_sx1.c
index 5d74026..a66fb65 100644
--- a/hw/arm/omap_sx1.c
+++ b/hw/arm/omap_sx1.c
@@ -196,7 +196,7 @@ static void sx1_init(MachineState *machine, const int version)
 
     if (!machine->kernel_filename && !fl_idx && !qtest_enabled()) {
         fprintf(stderr, "Kernel or Flash image must be specified\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Load the kernel.  */
diff --git a/hw/arm/palm.c b/hw/arm/palm.c
index 7f46073..9e27aa8 100644
--- a/hw/arm/palm.c
+++ b/hw/arm/palm.c
@@ -261,7 +261,7 @@ static void palmte_init(MachineState *machine)
 
     if (!rom_loaded && !kernel_filename && !qtest_enabled()) {
         fprintf(stderr, "Kernel or ROM image must be specified\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Load the kernel.  */
diff --git a/hw/arm/pxa2xx.c b/hw/arm/pxa2xx.c
index 0241e07..5b20358 100644
--- a/hw/arm/pxa2xx.c
+++ b/hw/arm/pxa2xx.c
@@ -2067,7 +2067,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
 
     if (revision && strncmp(revision, "pxa27", 5)) {
         fprintf(stderr, "Machine requires a PXA27x processor.\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (!revision)
         revision = "pxa270";
@@ -2075,7 +2075,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
     s->cpu = cpu_arm_init(revision);
     if (s->cpu == NULL) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     s->reset = qemu_allocate_irq(pxa2xx_reset, s, 0);
 
@@ -2108,7 +2108,7 @@ PXA2xxState *pxa270_init(MemoryRegion *address_space,
     dinfo = drive_get(IF_SD, 0, 0);
     if (!dinfo) {
         fprintf(stderr, "qemu: missing SecureDigital device\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     s->mmc = pxa2xx_mmci_init(address_space, 0x41100000,
                     blk_by_legacy_dinfo(dinfo),
@@ -2207,7 +2207,7 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size)
     s->cpu = cpu_arm_init("pxa255");
     if (s->cpu == NULL) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     s->reset = qemu_allocate_irq(pxa2xx_reset, s, 0);
 
@@ -2239,7 +2239,7 @@ PXA2xxState *pxa255_init(MemoryRegion *address_space, unsigned int sdram_size)
     dinfo = drive_get(IF_SD, 0, 0);
     if (!dinfo) {
         fprintf(stderr, "qemu: missing SecureDigital device\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     s->mmc = pxa2xx_mmci_init(address_space, 0x41100000,
                     blk_by_legacy_dinfo(dinfo),
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 2b295f1..dc60b0a 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -99,7 +99,7 @@ static void setup_boot(MachineState *machine, int version, size_t ram_size)
                                 ram_size - FIRMWARE_ADDR);
         if (r < 0) {
             error_report("Failed to load firmware from %s", machine->firmware);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         binfo.entry = FIRMWARE_ADDR;
@@ -147,7 +147,7 @@ static void raspi2_init(MachineState *machine)
     bus = qdev_get_child_bus(DEVICE(&s->soc), "sd-bus");
     if (bus == NULL) {
         error_report("No SD bus found in SOC object");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     carddev = qdev_create(bus, TYPE_SD_CARD);
     qdev_prop_set_drive(carddev, "drive", blk, &error_fatal);
diff --git a/hw/arm/realview.c b/hw/arm/realview.c
index 8eafcca..a25dea5 100644
--- a/hw/arm/realview.c
+++ b/hw/arm/realview.c
@@ -99,7 +99,7 @@ static void realview_init(MachineState *machine,
     cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, machine->cpu_model);
     if (!cpu_oc) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     for (n = 0; n < smp_cpus; n++) {
diff --git a/hw/arm/sabrelite.c b/hw/arm/sabrelite.c
index 4e7ac8c..a6ba376 100644
--- a/hw/arm/sabrelite.c
+++ b/hw/arm/sabrelite.c
@@ -52,7 +52,7 @@ static void sabrelite_init(MachineState *machine)
     if (machine->ram_size > FSL_IMX6_MMDC_SIZE) {
         error_report("RAM size " RAM_ADDR_FMT " above max supported (%08x)",
                      machine->ram_size, FSL_IMX6_MMDC_SIZE);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     object_initialize(&s->soc, sizeof(s->soc), TYPE_FSL_IMX6);
@@ -62,7 +62,7 @@ static void sabrelite_init(MachineState *machine)
     object_property_set_bool(OBJECT(&s->soc), true, "realized", &err);
     if (err != NULL) {
         error_report("%s", error_get_pretty(err));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     memory_region_allocate_system_memory(&s->ram, NULL, "sabrelite.ram",
diff --git a/hw/arm/strongarm.c b/hw/arm/strongarm.c
index 021cbf9..40912f8 100644
--- a/hw/arm/strongarm.c
+++ b/hw/arm/strongarm.c
@@ -1592,14 +1592,14 @@ StrongARMState *sa1110_init(MemoryRegion *sysmem,
 
     if (strncmp(rev, "sa1110", 6)) {
         error_report("Machine requires a SA1110 processor.");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     s->cpu = cpu_arm_init(rev);
 
     if (!s->cpu) {
         error_report("Unable to find CPU definition");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     memory_region_allocate_system_memory(&s->sdram, NULL, "strongarm.sdram",
diff --git a/hw/arm/sysbus-fdt.c b/hw/arm/sysbus-fdt.c
index 5debb33..72935d2 100644
--- a/hw/arm/sysbus-fdt.c
+++ b/hw/arm/sysbus-fdt.c
@@ -450,7 +450,7 @@ static int add_fdt_node(SysBusDevice *sbdev, void *opaque)
     }
     error_report("Device %s can not be dynamically instantiated",
                      qdev_fw_name(DEVICE(sbdev)));
-    exit(1);
+    exit(EXIT_FAILURE);
 }
 
 /**
diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c
index 8ae5392..bc7c7fb 100644
--- a/hw/arm/versatilepb.c
+++ b/hw/arm/versatilepb.c
@@ -205,7 +205,7 @@ static void versatile_init(MachineState *machine, int board_id)
     cpu_oc = cpu_class_by_name(TYPE_ARM_CPU, machine->cpu_model);
     if (!cpu_oc) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     cpuobj = object_new(object_class_get_name(cpu_oc));
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index 58760f4..b087e14 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -210,7 +210,7 @@ static void init_cpus(const char *cpu_model, const char *privdev,
 
     if (!cpu_oc) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Create the actual CPUs */
@@ -275,7 +275,7 @@ static void a9_daughterboard_init(const VexpressMachineState *vms,
     if (ram_size > 0x40000000) {
         /* 1GB is the maximum the address space permits */
         fprintf(stderr, "vexpress-a9: cannot model more than 1GB RAM\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     memory_region_allocate_system_memory(ram, NULL, "vexpress.highmem",
@@ -368,7 +368,7 @@ static void a15_daughterboard_init(const VexpressMachineState *vms,
         uint64_t rsz = ram_size;
         if (rsz > (30ULL * 1024 * 1024 * 1024)) {
             fprintf(stderr, "vexpress-a15: cannot model more than 30GB RAM\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -571,19 +571,19 @@ static void vexpress_common_init(MachineState *machine)
             error_report("The contents of the first flash device may be "
                          "specified with -bios or with -drive if=pflash... "
                          "but you cannot use both options at once");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
         if (!fn) {
             error_report("Could not find ROM image '%s'", bios_name);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         image_size = load_image_targphys(fn, map[VE_NORFLASH0],
                                          VEXPRESS_FLASH_SIZE);
         g_free(fn);
         if (image_size < 0) {
             error_report("Could not load ROM image '%s'", bios_name);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -653,7 +653,7 @@ static void vexpress_common_init(MachineState *machine)
                                        dinfo);
     if (!pflash0) {
         fprintf(stderr, "vexpress: error registering flash 0.\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (map[VE_NORFLASHALIAS] != -1) {
@@ -668,7 +668,7 @@ static void vexpress_common_init(MachineState *machine)
     if (!ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1",
                                   dinfo)) {
         fprintf(stderr, "vexpress: error registering flash 1.\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     sram_size = 0x2000000;
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index a193b5a..ffca55c 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -241,7 +241,7 @@ static void create_fdt(VirtBoardInfo *vbi)
 
     if (!fdt) {
         error_report("create_device_tree() failed");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     vbi->fdt = fdt;
@@ -817,18 +817,18 @@ static void create_one_flash(const char *name, hwaddr flashbase,
             error_report("The contents of the first flash device may be "
                          "specified with -bios or with -drive if=pflash... "
                          "but you cannot use both options at once");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, file);
         if (!fn) {
             error_report("Could not find ROM image '%s'", file);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         image_size = load_image_mr(fn, sysbus_mmio_get_region(sbd, 0));
         g_free(fn);
         if (image_size < 0) {
             error_report("Could not load ROM image '%s'", file);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 }
@@ -1196,13 +1196,13 @@ static void machvirt_init(MachineState *machine)
     if (!gic_version) {
         if (!kvm_enabled()) {
             error_report("gic-version=host requires KVM");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         gic_version = kvm_arm_vgic_probe();
         if (!gic_version) {
             error_report("Unable to determine GIC version supported by host");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -1213,7 +1213,7 @@ static void machvirt_init(MachineState *machine)
 
     if (!vbi) {
         error_report("mach-virt: CPU %s not supported", cpustr[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* If we have an EL3 boot ROM then the assumption is that it will
@@ -1240,20 +1240,20 @@ static void machvirt_init(MachineState *machine)
         error_report("Number of SMP CPUs requested (%d) exceeds max CPUs "
                      "supported by machine 'mach-virt' (%d)",
                      max_cpus, virt_max_cpus);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     vbi->smp_cpus = smp_cpus;
 
     if (machine->ram_size > vbi->memmap[VIRT_MEM].size) {
         error_report("mach-virt: cannot model more than %dGB RAM", RAMLIMIT_GB);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (vms->secure) {
         if (kvm_enabled()) {
             error_report("mach-virt: KVM does not support Security extensions");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         /* The Secure view of the world is the same as the NonSecure,
@@ -1272,7 +1272,7 @@ static void machvirt_init(MachineState *machine)
     oc = cpu_class_by_name(TYPE_ARM_CPU, cpustr[0]);
     if (!oc) {
         error_report("Unable to find CPU definition");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     typename = object_class_get_name(oc);
 
@@ -1282,7 +1282,7 @@ static void machvirt_init(MachineState *machine)
     g_strfreev(cpustr);
     if (err) {
         error_report_err(err);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     for (n = 0; n < smp_cpus; n++) {
diff --git a/hw/arm/xlnx-ep108.c b/hw/arm/xlnx-ep108.c
index 4ec590a..091d7a5 100644
--- a/hw/arm/xlnx-ep108.c
+++ b/hw/arm/xlnx-ep108.c
@@ -43,7 +43,7 @@ static void xlnx_ep108_init(MachineState *machine)
         error_report("ERROR: RAM size 0x%" PRIx64 " above max supported of "
                      "0x%llx", ram_size,
                      XLNX_ZYNQMP_MAX_RAM_SIZE);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (ram_size < 0x08000000) {
@@ -76,7 +76,7 @@ static void xlnx_ep108_init(MachineState *machine)
         g_free(bus_name);
         if (!bus) {
             error_report("No SD bus found for SD card %d", i);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         carddev = qdev_create(bus, TYPE_SD_CARD);
         qdev_prop_set_drive(carddev, "drive", blk, &error_fatal);
diff --git a/hw/arm/z2.c b/hw/arm/z2.c
index 68a92f3..1f135af 100644
--- a/hw/arm/z2.c
+++ b/hw/arm/z2.c
@@ -330,7 +330,7 @@ static void z2_init(MachineState *machine)
     if (!dinfo && !qtest_enabled()) {
         fprintf(stderr, "Flash image must be given with the "
                 "'pflash' parameter\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (!pflash_cfi01_register(Z2_FLASH_BASE,
@@ -339,7 +339,7 @@ static void z2_init(MachineState *machine)
                                sector_len, Z2_FLASH_SIZE / sector_len,
                                4, 0, 0, 0, 0, be)) {
         fprintf(stderr, "qemu: Error registering flash memory.\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* setup keypad */
diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c
index 1107578..861fbde 100644
--- a/hw/char/exynos4210_uart.c
+++ b/hw/char/exynos4210_uart.c
@@ -601,7 +601,7 @@ DeviceState *exynos4210_uart_create(hwaddr addr,
         if (channel >= MAX_SERIAL_PORTS) {
             error_report("Only %d serial ports are supported by QEMU",
                          MAX_SERIAL_PORTS);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         chr = serial_hds[channel];
         if (!chr) {
@@ -609,7 +609,7 @@ DeviceState *exynos4210_uart_create(hwaddr addr,
             chr = qemu_chr_new(label, "null", NULL);
             if (!(chr)) {
                 error_report("Can't assign serial port to UART%d", channel);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         }
     }
diff --git a/hw/display/pl110.c b/hw/display/pl110.c
index c069c0b..1d624cb 100644
--- a/hw/display/pl110.c
+++ b/hw/display/pl110.c
@@ -175,7 +175,7 @@ static void pl110_update_display(void *opaque)
         break;
     default:
         fprintf(stderr, "pl110: Bad color depth\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (s->cr & PL110_CR_BGR)
         bpp_offset = 0;
diff --git a/hw/display/pxa2xx_lcd.c b/hw/display/pxa2xx_lcd.c
index 845521c..022d6fd 100644
--- a/hw/display/pxa2xx_lcd.c
+++ b/hw/display/pxa2xx_lcd.c
@@ -1051,7 +1051,7 @@ PXA2xxLCDState *pxa2xx_lcdc_init(MemoryRegion *sysmem,
         break;
     default:
         fprintf(stderr, "%s: Bad color depth\n", __FUNCTION__);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     vmstate_register(NULL, 0, &vmstate_pxa2xx_lcdc, s);
diff --git a/hw/gpio/pl061.c b/hw/gpio/pl061.c
index 4ae2aa1..2dff326 100644
--- a/hw/gpio/pl061.c
+++ b/hw/gpio/pl061.c
@@ -18,7 +18,8 @@
 #define DPRINTF(fmt, ...) \
 do { printf("pl061: " fmt , ## __VA_ARGS__); } while (0)
 #define BADF(fmt, ...) \
-do { fprintf(stderr, "pl061: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
+do { fprintf(stderr, "pl061: error: " fmt , ## __VA_ARGS__); \
+     exit(EXIT_FAILURE); } while (0)
 #else
 #define DPRINTF(fmt, ...) do {} while(0)
 #define BADF(fmt, ...) \
diff --git a/hw/net/stellaris_enet.c b/hw/net/stellaris_enet.c
index 957730e..7c8b879 100644
--- a/hw/net/stellaris_enet.c
+++ b/hw/net/stellaris_enet.c
@@ -17,7 +17,8 @@
 #define DPRINTF(fmt, ...) \
 do { printf("stellaris_enet: " fmt , ## __VA_ARGS__); } while (0)
 #define BADF(fmt, ...) \
-do { fprintf(stderr, "stellaris_enet: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
+do { fprintf(stderr, "stellaris_enet: error: " fmt , ## __VA_ARGS__); \
+     exit(EXIT_FAILURE); } while (0)
 #else
 #define DPRINTF(fmt, ...) do {} while(0)
 #define BADF(fmt, ...) \
diff --git a/hw/sd/omap_mmc.c b/hw/sd/omap_mmc.c
index e934cd3..a7c7da0 100644
--- a/hw/sd/omap_mmc.c
+++ b/hw/sd/omap_mmc.c
@@ -595,7 +595,7 @@ struct omap_mmc_s *omap_mmc_init(hwaddr base,
     /* Instantiate the storage */
     s->card = sd_init(blk, false);
     if (s->card == NULL) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     return s;
@@ -622,7 +622,7 @@ struct omap_mmc_s *omap2_mmc_init(struct omap_target_agent_s *ta,
     /* Instantiate the storage */
     s->card = sd_init(blk, false);
     if (s->card == NULL) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     s->cdet = qemu_allocate_irq(omap_mmc_cover_cb, s, 0);
diff --git a/hw/ssi/pl022.c b/hw/ssi/pl022.c
index c136801..f262610 100644
--- a/hw/ssi/pl022.c
+++ b/hw/ssi/pl022.c
@@ -18,7 +18,8 @@
 #define DPRINTF(fmt, ...) \
 do { printf("pl022: " fmt , ## __VA_ARGS__); } while (0)
 #define BADF(fmt, ...) \
-do { fprintf(stderr, "pl022: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
+do { fprintf(stderr, "pl022: error: " fmt , ## __VA_ARGS__); \
+     exit(EXIT_FAILURE); } while (0)
 #else
 #define DPRINTF(fmt, ...) do {} while(0)
 #define BADF(fmt, ...) \
diff --git a/target-arm/kvm.c b/target-arm/kvm.c
index dbe393c..c37c457 100644
--- a/target-arm/kvm.c
+++ b/target-arm/kvm.c
@@ -594,7 +594,7 @@ int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
 {
      if (machine_kernel_irqchip_split(ms)) {
          perror("-machine kernel_irqchip=split is not supported on ARM.");
-         exit(1);
+         exit(EXIT_FAILURE);
     }
 
     /* If we can create the VGIC using the newer device control API, we
diff --git a/target-arm/machine.c b/target-arm/machine.c
index 7a6ca31..4e85a9a 100644
--- a/target-arm/machine.c
+++ b/target-arm/machine.c
@@ -340,7 +340,7 @@ const char *gicv3_class_name(void)
 #else
         error_report("KVM GICv3 acceleration is not supported on this "
                      "platform");
-        exit(1);
+        exit(EXIT_FAILURE);
 #endif
     } else {
         return "arm-gicv3";
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 03/26] cris: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 01/26] coccinelle: " Laurent Vivier
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 02/26] arm: " Laurent Vivier
@ 2016-09-16 13:55 ` Laurent Vivier
  2016-09-16 14:41   ` Edgar E. Iglesias
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 04/26] block: " Laurent Vivier
                   ` (25 subsequent siblings)
  28 siblings, 1 reply; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:55 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Edgar E. Iglesias

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Edgar E. Iglesias <edgar.iglesias@gmail.com>
---
 hw/cris/boot.c                              | 4 ++--
 tests/tcg/cris/check_gcctorture_pr28634-1.c | 2 +-
 tests/tcg/cris/check_gcctorture_pr28634.c   | 2 +-
 tests/tcg/cris/check_glibc_kernelversion.c  | 2 +-
 tests/tcg/cris/check_hello.c                | 2 +-
 tests/tcg/cris/check_lz.c                   | 2 +-
 tests/tcg/cris/check_mapbrk.c               | 6 +++---
 tests/tcg/cris/check_mmap1.c                | 2 +-
 tests/tcg/cris/check_mmap2.c                | 2 +-
 tests/tcg/cris/check_mmap3.c                | 2 +-
 tests/tcg/cris/check_openpf5.c              | 2 +-
 tests/tcg/cris/check_stat1.c                | 2 +-
 tests/tcg/cris/check_stat2.c                | 2 +-
 tests/tcg/cris/check_stat3.c                | 2 +-
 tests/tcg/cris/check_stat4.c                | 2 +-
 tests/tcg/cris/check_time1.c                | 2 +-
 tests/tcg/cris/check_time2.c                | 2 +-
 tests/tcg/cris/sys.c                        | 2 +-
 18 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/hw/cris/boot.c b/hw/cris/boot.c
index f896ed7..85ab8c4 100644
--- a/hw/cris/boot.c
+++ b/hw/cris/boot.c
@@ -88,13 +88,13 @@ void cris_load_image(CRISCPU *cpu, struct cris_load_info *li)
     if (image_size < 0) {
         fprintf(stderr, "qemu: could not load kernel '%s'\n",
                 li->image_filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (li->cmdline && (kcmdline_len = strlen(li->cmdline))) {
         if (kcmdline_len > 256) {
             fprintf(stderr, "Too long CRIS kernel cmdline (max 256)\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         pstrcpy_targphys("cmdline", 0x40000000, 256, li->cmdline);
     }
diff --git a/tests/tcg/cris/check_gcctorture_pr28634-1.c b/tests/tcg/cris/check_gcctorture_pr28634-1.c
index 45ecd15..ebe3f6f 100644
--- a/tests/tcg/cris/check_gcctorture_pr28634-1.c
+++ b/tests/tcg/cris/check_gcctorture_pr28634-1.c
@@ -11,5 +11,5 @@ main (void)
     y += x;
   if (y != x + 1)
     abort ();
-  exit (0);
+  exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_gcctorture_pr28634.c b/tests/tcg/cris/check_gcctorture_pr28634.c
index a0c5254..52e5ef3 100644
--- a/tests/tcg/cris/check_gcctorture_pr28634.c
+++ b/tests/tcg/cris/check_gcctorture_pr28634.c
@@ -11,5 +11,5 @@ main (void)
     y += x;
   if (y != x + 1)
     abort ();
-  exit (0);
+  exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_glibc_kernelversion.c b/tests/tcg/cris/check_glibc_kernelversion.c
index 0744872..ebc4959 100644
--- a/tests/tcg/cris/check_glibc_kernelversion.c
+++ b/tests/tcg/cris/check_glibc_kernelversion.c
@@ -112,5 +112,5 @@ int main(void)
 	if (version < __LINUX_KERNEL_VERSION)
 		err();
 	pass();
-	exit(0);
+	exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_hello.c b/tests/tcg/cris/check_hello.c
index fb403ba..14b6fff 100644
--- a/tests/tcg/cris/check_hello.c
+++ b/tests/tcg/cris/check_hello.c
@@ -3,5 +3,5 @@
 int main ()
 {
   printf ("pass\n");
-  exit (0);
+  exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_lz.c b/tests/tcg/cris/check_lz.c
index 69c2e6d..603aeac 100644
--- a/tests/tcg/cris/check_lz.c
+++ b/tests/tcg/cris/check_lz.c
@@ -45,5 +45,5 @@ int main(void)
 {
 	check_lz();
 	pass();
-	exit(0);
+	exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_mapbrk.c b/tests/tcg/cris/check_mapbrk.c
index 1aff762..8d5ec3f 100644
--- a/tests/tcg/cris/check_mapbrk.c
+++ b/tests/tcg/cris/check_mapbrk.c
@@ -16,7 +16,7 @@ int main ()
       || (p6 = malloc (8191*1024)) == NULL)
   {
     printf ("fail\n");
-    exit (1);
+    exit(EXIT_FAILURE);
   }
 
   free (p1);
@@ -30,10 +30,10 @@ int main ()
   if (p1 == NULL)
   {
     printf ("fail\n");
-    exit (1);
+    exit(EXIT_FAILURE);
   }
   free (p1);
 
   printf ("pass\n");
-  exit (0);
+  exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_mmap1.c b/tests/tcg/cris/check_mmap1.c
index b803f0c..12a7fb5 100644
--- a/tests/tcg/cris/check_mmap1.c
+++ b/tests/tcg/cris/check_mmap1.c
@@ -44,5 +44,5 @@ int main (int argc, char *argv[])
     abort ();
 
   printf ("pass\n");
-  exit (0);
+  exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_mmap2.c b/tests/tcg/cris/check_mmap2.c
index 35139a0..6c04db3 100644
--- a/tests/tcg/cris/check_mmap2.c
+++ b/tests/tcg/cris/check_mmap2.c
@@ -44,5 +44,5 @@ int main (int argc, char *argv[])
     abort ();
 
   printf ("pass\n");
-  exit (0);
+  exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_mmap3.c b/tests/tcg/cris/check_mmap3.c
index 34401fa..9430177 100644
--- a/tests/tcg/cris/check_mmap3.c
+++ b/tests/tcg/cris/check_mmap3.c
@@ -29,5 +29,5 @@ int main (int argc, char *argv[])
     abort ();
 
   printf ("pass\n");
-  exit (0);
+  exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_openpf5.c b/tests/tcg/cris/check_openpf5.c
index 1f86ea2..29c9ad3 100644
--- a/tests/tcg/cris/check_openpf5.c
+++ b/tests/tcg/cris/check_openpf5.c
@@ -52,5 +52,5 @@ int main (int argc, char *argv[])
 
 ok:
   printf ("pass\n");
-  exit (0);
+  exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_stat1.c b/tests/tcg/cris/check_stat1.c
index 2e2cae5..bf17527 100644
--- a/tests/tcg/cris/check_stat1.c
+++ b/tests/tcg/cris/check_stat1.c
@@ -12,5 +12,5 @@ int main (void)
       || !S_ISDIR (buf.st_mode))
     abort ();
   printf ("pass\n");
-  exit (0);
+  exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_stat2.c b/tests/tcg/cris/check_stat2.c
index e36172e..e9ca81a 100644
--- a/tests/tcg/cris/check_stat2.c
+++ b/tests/tcg/cris/check_stat2.c
@@ -16,5 +16,5 @@ int main (void)
       || !S_ISDIR (buf.st_mode))
     abort ();
   printf ("pass\n");
-  exit (0);
+  exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_stat3.c b/tests/tcg/cris/check_stat3.c
index 36a9d5d..3696f0d 100644
--- a/tests/tcg/cris/check_stat3.c
+++ b/tests/tcg/cris/check_stat3.c
@@ -21,5 +21,5 @@ int main (int argc, char *argv[])
       || !S_ISREG (buf.st_mode))
     abort ();
   printf ("pass\n");
-  exit (0);
+  exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_stat4.c b/tests/tcg/cris/check_stat4.c
index 04f21fe..bc28b98 100644
--- a/tests/tcg/cris/check_stat4.c
+++ b/tests/tcg/cris/check_stat4.c
@@ -23,5 +23,5 @@ int main (int argc, char *argv[])
       || !S_ISREG (buf.st_mode))
     abort ();
   printf ("pass\n");
-  exit (0);
+  exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_time1.c b/tests/tcg/cris/check_time1.c
index 3fcf0e1..92c00a3 100644
--- a/tests/tcg/cris/check_time1.c
+++ b/tests/tcg/cris/check_time1.c
@@ -42,5 +42,5 @@ main (void)
     }
 
   printf ("pass\n");
-  exit (0);
+  exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/check_time2.c b/tests/tcg/cris/check_time2.c
index 20b69b4..9960866 100644
--- a/tests/tcg/cris/check_time2.c
+++ b/tests/tcg/cris/check_time2.c
@@ -14,5 +14,5 @@ main (void)
   if (t == (time_t) -1 || t != x)
     abort ();
   printf ("pass\n");
-  exit (0);
+  exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/cris/sys.c b/tests/tcg/cris/sys.c
index 551c5dd..ace397e 100644
--- a/tests/tcg/cris/sys.c
+++ b/tests/tcg/cris/sys.c
@@ -12,7 +12,7 @@ static inline int mystrlen(char *s) {
 void pass(void) {
 	char s[] = "passed.\n";
 	write (1, s, sizeof (s) - 1);
-	exit (0);
+	exit(EXIT_SUCCESS);
 }
 
 void _fail(char *reason) {
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 04/26] block: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (2 preceding siblings ...)
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 03/26] cris: " Laurent Vivier
@ 2016-09-16 13:55 ` Laurent Vivier
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 05/26] ppc: " Laurent Vivier
                   ` (24 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:55 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Max Reitz

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
---
 hw/block/pflash_cfi01.c |  2 +-
 hw/block/tc58128.c      |  2 +-
 qemu-img.c              |  4 ++--
 qemu-io.c               | 24 ++++++++++++------------
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/hw/block/pflash_cfi01.c b/hw/block/pflash_cfi01.c
index 62d7a56..f6a7909 100644
--- a/hw/block/pflash_cfi01.c
+++ b/hw/block/pflash_cfi01.c
@@ -52,7 +52,7 @@
 #define PFLASH_BUG(fmt, ...) \
 do { \
     fprintf(stderr, "PFLASH: Possible BUG - " fmt, ## __VA_ARGS__); \
-    exit(1); \
+    exit(EXIT_FAILURE); \
 } while(0)
 
 /* #define PFLASH_DEBUG */
diff --git a/hw/block/tc58128.c b/hw/block/tc58128.c
index 1d9f7ee..8d7b489 100644
--- a/hw/block/tc58128.c
+++ b/hw/block/tc58128.c
@@ -41,7 +41,7 @@ static void init_dev(tc58128_dev * dev, const char *filename)
 	if (ret < 0) {
             if (!qtest_enabled()) {
                 error_report("Could not load flash image %s", filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
 	} else {
 	    /* Build first block with number of blocks */
diff --git a/qemu-img.c b/qemu-img.c
index ea52486..ed90a21 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2418,7 +2418,7 @@ static void dump_map_entry(OutputFormat output_format, MapEntry *e,
     case OFORMAT_HUMAN:
         if (e->data && !e->has_offset) {
             error_report("File contains external, encrypted or compressed clusters.");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         if (e->data && !e->zero) {
             printf("%#-16"PRIx64"%#-16"PRIx64"%#-16"PRIx64"%s\n",
@@ -3870,7 +3870,7 @@ int main(int argc, char **argv)
     optind = 0;
 
     if (!trace_init_backends()) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     trace_init_file(trace_file);
     qemu_set_log(LOG_TRACE);
diff --git a/qemu-io.c b/qemu-io.c
index db129ea..5b08adf 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -489,7 +489,7 @@ int main(int argc, char **argv)
         case 'd':
             if (bdrv_parse_discard_flags(optarg, &flags) < 0) {
                 error_report("Invalid discard option: %s", optarg);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             break;
         case 'f':
@@ -510,7 +510,7 @@ int main(int argc, char **argv)
         case 't':
             if (bdrv_parse_cache_mode(optarg, &flags, &writethrough) < 0) {
                 error_report("Invalid cache option: %s", optarg);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             break;
         case 'T':
@@ -519,16 +519,16 @@ int main(int argc, char **argv)
             break;
         case 'V':
             printf("%s version %s\n", progname, QEMU_VERSION);
-            exit(0);
+            exit(EXIT_SUCCESS);
         case 'h':
             usage(progname);
-            exit(0);
+            exit(EXIT_SUCCESS);
         case OPTION_OBJECT: {
             QemuOpts *qopts;
             qopts = qemu_opts_parse_noisily(&qemu_object_opts,
                                             optarg, true);
             if (!qopts) {
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         }   break;
         case OPTION_IMAGE_OPTS:
@@ -536,33 +536,33 @@ int main(int argc, char **argv)
             break;
         default:
             usage(progname);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
     if ((argc - optind) > 1) {
         usage(progname);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (format && imageOpts) {
         error_report("--image-opts and -f are mutually exclusive");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (qemu_init_main_loop(&local_error)) {
         error_report_err(local_error);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (qemu_opts_foreach(&qemu_object_opts,
                           user_creatable_add_opts_foreach,
                           NULL, NULL)) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (!trace_init_backends()) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     trace_init_file(trace_file);
     qemu_set_log(LOG_TRACE);
@@ -591,7 +591,7 @@ int main(int argc, char **argv)
             QemuOpts *qopts = NULL;
             qopts = qemu_opts_parse_noisily(&file_opts, argv[optind], false);
             if (!qopts) {
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             opts = qemu_opts_to_qdict(qopts, NULL);
             openfile(NULL, flags, writethrough, opts);
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 05/26] ppc: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (3 preceding siblings ...)
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 04/26] block: " Laurent Vivier
@ 2016-09-16 13:55 ` Laurent Vivier
  2016-09-19  5:22   ` David Gibson
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 06/26] graphics: " Laurent Vivier
                   ` (23 subsequent siblings)
  28 siblings, 1 reply; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:55 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, David Gibson

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: David Gibson <david@gibson.dropbear.id.au>
---
 device_tree.c               | 18 ++++++++--------
 hw/intc/xics_kvm.c          |  6 +++---
 hw/ppc/e500.c               | 14 ++++++------
 hw/ppc/mac_newworld.c       | 12 +++++------
 hw/ppc/mac_oldworld.c       | 16 +++++++-------
 hw/ppc/mpc8544ds.c          |  2 +-
 hw/ppc/ppc.c                |  4 ++--
 hw/ppc/ppc405_boards.c      | 16 +++++++-------
 hw/ppc/ppc440_bamboo.c      | 10 ++++-----
 hw/ppc/ppc4xx_devs.c        |  2 +-
 hw/ppc/prep.c               | 12 +++++------
 hw/ppc/spapr.c              | 52 ++++++++++++++++++++++-----------------------
 hw/ppc/virtex_ml507.c       |  4 ++--
 target-ppc/kvm.c            |  6 +++---
 target-ppc/translate.c      |  2 +-
 target-ppc/translate_init.c | 28 ++++++++++++------------
 tcg/ppc/tcg-target.inc.c    |  6 +++---
 17 files changed, 105 insertions(+), 105 deletions(-)

diff --git a/device_tree.c b/device_tree.c
index 6e06320..202cee8 100644
--- a/device_tree.c
+++ b/device_tree.c
@@ -61,13 +61,13 @@ void *create_device_tree(int *sizep)
     ret = fdt_open_into(fdt, fdt, *sizep);
     if (ret) {
         error_report("Unable to copy device tree in memory");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     return fdt;
 fail:
     error_report("%s Couldn't create dt: %s", __func__, fdt_strerror(ret));
-    exit(1);
+    exit(EXIT_FAILURE);
 }
 
 void *load_device_tree(const char *filename_path, int *sizep)
@@ -222,7 +222,7 @@ static int findnode_nofail(void *fdt, const char *node_path)
     if (offset < 0) {
         error_report("%s Couldn't find node %s: %s", __func__, node_path,
                      fdt_strerror(offset));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     return offset;
@@ -291,7 +291,7 @@ int qemu_fdt_setprop(void *fdt, const char *node_path,
     if (r < 0) {
         error_report("%s: Couldn't set %s/%s: %s", __func__, node_path,
                      property, fdt_strerror(r));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     return r;
@@ -306,7 +306,7 @@ int qemu_fdt_setprop_cell(void *fdt, const char *node_path,
     if (r < 0) {
         error_report("%s: Couldn't set %s/%s = %#08x: %s", __func__,
                      node_path, property, val, fdt_strerror(r));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     return r;
@@ -328,7 +328,7 @@ int qemu_fdt_setprop_string(void *fdt, const char *node_path,
     if (r < 0) {
         error_report("%s: Couldn't set %s/%s = %s: %s", __func__,
                      node_path, property, string, fdt_strerror(r));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     return r;
@@ -380,7 +380,7 @@ uint32_t qemu_fdt_get_phandle(void *fdt, const char *path)
     if (r == 0) {
         error_report("%s: Couldn't get phandle for %s: %s", __func__,
                      path, fdt_strerror(r));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     return r;
@@ -425,7 +425,7 @@ int qemu_fdt_nop_node(void *fdt, const char *node_path)
     if (r < 0) {
         error_report("%s: Couldn't nop node %s: %s", __func__, node_path,
                      fdt_strerror(r));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     return r;
@@ -454,7 +454,7 @@ int qemu_fdt_add_subnode(void *fdt, const char *name)
     if (retval < 0) {
         error_report("FDT: Failed to create subnode %s: %s", name,
                      fdt_strerror(retval));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     g_free(dupname);
diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
index c9caefc..82c65e8 100644
--- a/hw/intc/xics_kvm.c
+++ b/hw/intc/xics_kvm.c
@@ -67,7 +67,7 @@ static void icp_get_kvm_state(ICPState *ss)
     if (ret != 0) {
         error_report("Unable to retrieve KVM interrupt controller state"
                 " for CPU %ld: %s", kvm_arch_vcpu_id(ss->cs), strerror(errno));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     ss->xirr = state >> KVM_REG_PPC_ICP_XISR_SHIFT;
@@ -164,7 +164,7 @@ static void ics_get_kvm_state(ICSState *ics)
         if (ret != 0) {
             error_report("Unable to retrieve KVM interrupt controller state"
                     " for IRQ %d: %s", i + ics->offset, strerror(errno));
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         irq->server = state & KVM_XICS_DESTINATION_MASK;
@@ -353,7 +353,7 @@ static void xics_kvm_cpu_setup(XICSState *xics, PowerPCCPU *cpu)
     if (ret < 0) {
         error_report("Unable to connect CPU%ld to kernel XICS: %s",
                      kvm_arch_vcpu_id(cs), strerror(errno));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     ss->cap_irq_xics_enabled = true;
 }
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index 0cd534d..5b4dc56 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -209,7 +209,7 @@ static int sysbus_device_create_devtree(SysBusDevice *sbdev, void *opaque)
     if (!matched) {
         error_report("Device %s is not supported by this machine yet.",
                      qdev_fw_name(DEVICE(sbdev)));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     return 0;
@@ -754,7 +754,7 @@ static qemu_irq *ppce500_init_mpic(MachineState *machine, PPCE500Params *params,
         if (machine_kernel_irqchip_required(machine) && !dev) {
             error_reportf_err(err,
                               "kernel_irqchip requested but unavailable: ");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -824,7 +824,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
         cpu = cpu_ppc_init(machine->cpu_model);
         if (cpu == NULL) {
             fprintf(stderr, "Unable to initialize CPU!\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         env = &cpu->env;
         cs = CPU(cpu);
@@ -972,7 +972,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
         if (kernel_size < 0) {
             fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     machine->kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         cur_base += kernel_size;
@@ -987,7 +987,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
         if (initrd_size < 0) {
             fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
                     machine->initrd_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         cur_base = initrd_base + initrd_size;
@@ -1028,7 +1028,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
                                   NULL, NULL);
         if (kernel_size < 0) {
             fprintf(stderr, "qemu: could not load firmware '%s'\n", filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
     g_free(filename);
@@ -1041,7 +1041,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
                                        kernel_base, kernel_size);
     if (dt_size < 0) {
         fprintf(stderr, "couldn't load device tree\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     assert(dt_size < DTB_MAX_SIZE);
 
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index 7d25106..72ff9ad 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -196,7 +196,7 @@ static void ppc_core99_init(MachineState *machine)
         cpu = cpu_ppc_init(machine->cpu_model);
         if (cpu == NULL) {
             fprintf(stderr, "Unable to find PowerPC CPU definition\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         env = &cpu->env;
 
@@ -231,7 +231,7 @@ static void ppc_core99_init(MachineState *machine)
     }
     if (bios_size < 0 || bios_size > BIOS_SIZE) {
         error_report("could not load PowerPC bios '%s'", bios_name);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (linux_boot) {
@@ -258,7 +258,7 @@ static void ppc_core99_init(MachineState *machine)
                                               ram_size - kernel_base);
         if (kernel_size < 0) {
             error_report("could not load kernel '%s'", kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         /* load initrd */
         if (initrd_filename) {
@@ -268,7 +268,7 @@ static void ppc_core99_init(MachineState *machine)
             if (initrd_size < 0) {
                 error_report("could not load initial ram disk '%s'",
                              initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             cmdline_base = round_page(initrd_base + initrd_size);
         } else {
@@ -294,7 +294,7 @@ static void ppc_core99_init(MachineState *machine)
         }
         if (ppc_boot_device == '\0') {
             fprintf(stderr, "No valid boot device for Mac99 machine\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -350,7 +350,7 @@ static void ppc_core99_init(MachineState *machine)
 #endif /* defined(TARGET_PPC64) */
         default:
             error_report("Bus model not supported on mac99 machine");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index 4479487..01196fe 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -116,7 +116,7 @@ static void ppc_heathrow_init(MachineState *machine)
         cpu = cpu_ppc_init(machine->cpu_model);
         if (cpu == NULL) {
             fprintf(stderr, "Unable to find PowerPC CPU definition\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         env = &cpu->env;
 
@@ -130,7 +130,7 @@ static void ppc_heathrow_init(MachineState *machine)
         fprintf(stderr,
                 "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n",
                 ((unsigned int)ram_size / (1 << 20)));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     memory_region_allocate_system_memory(ram, NULL, "ppc_heathrow.ram",
@@ -158,7 +158,7 @@ static void ppc_heathrow_init(MachineState *machine)
     }
     if (bios_size < 0 || bios_size > BIOS_SIZE) {
         error_report("could not load PowerPC bios '%s'", bios_name);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (linux_boot) {
@@ -184,7 +184,7 @@ static void ppc_heathrow_init(MachineState *machine)
                                               ram_size - kernel_base);
         if (kernel_size < 0) {
             error_report("could not load kernel '%s'", kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         /* load initrd */
         if (initrd_filename) {
@@ -194,7 +194,7 @@ static void ppc_heathrow_init(MachineState *machine)
             if (initrd_size < 0) {
                 error_report("could not load initial ram disk '%s'",
                              initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             cmdline_base = round_page(initrd_base + initrd_size);
         } else {
@@ -228,7 +228,7 @@ static void ppc_heathrow_init(MachineState *machine)
         }
         if (ppc_boot_device == '\0') {
             fprintf(stderr, "No valid boot device for G3 Beige machine\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -251,7 +251,7 @@ static void ppc_heathrow_init(MachineState *machine)
             break;
         default:
             error_report("Bus model not supported on OldWorld Mac machine");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -265,7 +265,7 @@ static void ppc_heathrow_init(MachineState *machine)
     /* init basic PC hardware */
     if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
         error_report("Only 6xx bus is supported on heathrow machine");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     pic = heathrow_pic_init(&pic_mem, 1, heathrow_irqs);
     pci_bus = pci_grackle_init(0xfec00000, pic,
diff --git a/hw/ppc/mpc8544ds.c b/hw/ppc/mpc8544ds.c
index 27b8289..8d646bb 100644
--- a/hw/ppc/mpc8544ds.c
+++ b/hw/ppc/mpc8544ds.c
@@ -43,7 +43,7 @@ static void mpc8544ds_init(MachineState *machine)
 
     if (machine->ram_size > 0xc0000000) {
         error_report("The MPC8544DS board only supports up to 3GB of RAM");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     ppce500_init(machine, &params);
diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index 8945869..478b848 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -1362,13 +1362,13 @@ void ppc_cpu_parse_features(const char *cpu_model)
     model_pieces = g_strsplit(cpu_model, ",", 2);
     if (!model_pieces[0]) {
         error_report("Invalid/empty CPU model name");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     oc = cpu_class_by_name(TYPE_POWERPC_CPU, model_pieces[0]);
     if (oc == NULL) {
         error_report("Unable to find CPU definition: %s", model_pieces[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     typename = object_class_get_name(oc);
diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
index 4b2f07a..53d4c73 100644
--- a/hw/ppc/ppc405_boards.c
+++ b/hw/ppc/ppc405_boards.c
@@ -266,13 +266,13 @@ static void ref405ep_init(MachineState *machine)
             g_free(filename);
             if (bios_size < 0 || bios_size > BIOS_SIZE) {
                 error_report("Could not load PowerPC BIOS '%s'", bios_name);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             bios_size = (bios_size + 0xfff) & ~0xfff;
             memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios);
         } else if (!qtest_enabled() || kernel_filename != NULL) {
             error_report("Could not load PowerPC BIOS '%s'", bios_name);
-            exit(1);
+            exit(EXIT_FAILURE);
         } else {
             /* Avoid an uninitialized variable warning */
             bios_size = -1;
@@ -329,7 +329,7 @@ static void ref405ep_init(MachineState *machine)
         if (kernel_size < 0) {
             fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         printf("Load kernel size %ld at " TARGET_FMT_lx,
                kernel_size, kernel_base);
@@ -341,7 +341,7 @@ static void ref405ep_init(MachineState *machine)
             if (initrd_size < 0) {
                 fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
                         initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         } else {
             initrd_base = 0;
@@ -564,13 +564,13 @@ static void taihu_405ep_init(MachineState *machine)
             g_free(filename);
             if (bios_size < 0 || bios_size > BIOS_SIZE) {
                 error_report("Could not load PowerPC BIOS '%s'", bios_name);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             bios_size = (bios_size + 0xfff) & ~0xfff;
             memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios);
         } else if (!qtest_enabled()) {
             error_report("Could not load PowerPC BIOS '%s'", bios_name);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         memory_region_set_readonly(bios, true);
     }
@@ -613,7 +613,7 @@ static void taihu_405ep_init(MachineState *machine)
         if (kernel_size < 0) {
             fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         /* load initrd */
         if (initrd_filename) {
@@ -624,7 +624,7 @@ static void taihu_405ep_init(MachineState *machine)
                 fprintf(stderr,
                         "qemu: could not load initial ram disk '%s'\n",
                         initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         } else {
             initrd_base = 0;
diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
index 5c535b1..26b3f46 100644
--- a/hw/ppc/ppc440_bamboo.c
+++ b/hw/ppc/ppc440_bamboo.c
@@ -189,7 +189,7 @@ static void bamboo_init(MachineState *machine)
     cpu = cpu_ppc_init(machine->cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "Unable to initialize CPU!\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
@@ -223,7 +223,7 @@ static void bamboo_init(MachineState *machine)
     pcibus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
     if (!pcibus) {
         fprintf(stderr, "couldn't create PCI controller!\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     memory_region_init_alias(isa, NULL, "isa_mmio",
@@ -265,7 +265,7 @@ static void bamboo_init(MachineState *machine)
         if (success < 0) {
             fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -277,7 +277,7 @@ static void bamboo_init(MachineState *machine)
         if (initrd_size < 0) {
             fprintf(stderr, "qemu: could not load ram disk '%s' at %x\n",
                     initrd_filename, RAMDISK_ADDR);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -286,7 +286,7 @@ static void bamboo_init(MachineState *machine)
         if (bamboo_load_device_tree(FDT_ADDR, ram_size, RAMDISK_ADDR,
                                     initrd_size, kernel_cmdline) < 0) {
             fprintf(stderr, "couldn't load device tree\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 }
diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c
index e7f413e..0e6312a 100644
--- a/hw/ppc/ppc4xx_devs.c
+++ b/hw/ppc/ppc4xx_devs.c
@@ -60,7 +60,7 @@ PowerPCCPU *ppc4xx_init(const char *cpu_model,
     if (cpu == NULL) {
         fprintf(stderr, "Unable to find PowerPC %s CPU definition\n",
                 cpu_model);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index 054af1e..1040ddc 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -512,7 +512,7 @@ static void ppc_prep_init(MachineState *machine)
         cpu = cpu_ppc_init(machine->cpu_model);
         if (cpu == NULL) {
             fprintf(stderr, "Unable to find PowerPC CPU definition\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         env = &cpu->env;
 
@@ -537,7 +537,7 @@ static void ppc_prep_init(MachineState *machine)
                                           ram_size - kernel_base);
         if (kernel_size < 0) {
             error_report("could not load kernel '%s'", kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         /* load initrd */
         if (initrd_filename) {
@@ -547,7 +547,7 @@ static void ppc_prep_init(MachineState *machine)
             if (initrd_size < 0) {
                 error_report("could not load initial ram disk '%s'",
                              initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         } else {
             initrd_base = 0;
@@ -569,13 +569,13 @@ static void ppc_prep_init(MachineState *machine)
         }
         if (ppc_boot_device == '\0') {
             fprintf(stderr, "No valid boot device for Mac99 machine\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
     if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
         error_report("Only 6xx bus is supported on PREP machine");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     dev = qdev_create(NULL, "raven-pcihost");
@@ -590,7 +590,7 @@ static void ppc_prep_init(MachineState *machine)
     pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
     if (pci_bus == NULL) {
         fprintf(stderr, "Couldn't create PCI host controller.\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     sysctrl->contiguous_map_irq = qdev_get_gpio_in(dev, 0);
 
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index ca77bb0..9019fe4 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -912,20 +912,20 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr,
     ret = spapr_populate_memory(spapr, fdt);
     if (ret < 0) {
         error_report("couldn't setup memory nodes in fdt");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     ret = spapr_populate_vdevice(spapr->vio_bus, fdt);
     if (ret < 0) {
         error_report("couldn't setup vio devices in fdt");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (object_resolve_path_type("", TYPE_SPAPR_RNG, NULL)) {
         ret = spapr_rng_populate_dt(fdt);
         if (ret < 0) {
             error_report("could not set up rng device in the fdt");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -933,7 +933,7 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr,
         ret = spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt);
         if (ret < 0) {
             error_report("couldn't setup PCI devices in fdt");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -950,7 +950,7 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr,
     if (cb && bootlist) {
         int offset = fdt_path_offset(fdt, "/chosen");
         if (offset < 0) {
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         for (i = 0; i < cb; i++) {
             if (bootlist[i] == '\n') {
@@ -965,7 +965,7 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr,
         int offset = fdt_path_offset(fdt, "/chosen");
 
         if (offset < 0) {
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         fdt_setprop_string(fdt, offset, "qemu,boot-device", boot_device);
     }
@@ -984,7 +984,7 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr,
                                     SPAPR_DR_CONNECTOR_TYPE_CPU);
         if (ret < 0) {
             error_report("Couldn't set up CPU DR device tree properties");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -993,7 +993,7 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr,
     if (fdt_totalsize(fdt) > FDT_MAX_SIZE) {
         error_report("FDT too big ! 0x%x bytes (max is 0x%x)",
                      fdt_totalsize(fdt), FDT_MAX_SIZE);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt));
@@ -1126,7 +1126,7 @@ static int find_unknown_sysbus_device(SysBusDevice *sbdev, void *opaque)
     if (!matched) {
         error_report("Device %s is not supported by this machine yet.",
                      qdev_fw_name(DEVICE(sbdev)));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     return 0;
@@ -1696,12 +1696,12 @@ static void ppc_spapr_init(MachineState *machine)
         if (smp_cpus % smp_threads) {
             error_report("smp_cpus (%u) must be multiple of threads (%u)",
                          smp_cpus, smp_threads);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         if (max_cpus % smp_threads) {
             error_report("max_cpus (%u) must be multiple of threads (%u)",
                          max_cpus, smp_threads);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -1716,7 +1716,7 @@ static void ppc_spapr_init(MachineState *machine)
 
     if (rma_alloc_size == -1) {
         error_report("Unable to create RMA");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (rma_alloc_size && (rma_alloc_size < node0_size)) {
@@ -1749,7 +1749,7 @@ static void ppc_spapr_init(MachineState *machine)
     if (spapr->rma_size > node0_size) {
         error_report("Numa node 0 has to span the RMA (%#08"HWADDR_PRIx")",
                      spapr->rma_size);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Setup a load limit for the ramdisk leaving room for SLOF and FDT */
@@ -1776,7 +1776,7 @@ static void ppc_spapr_init(MachineState *machine)
 
         if (type == NULL) {
             error_report("Unable to find sPAPR CPU Core definition");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         spapr->cores = g_new0(Object *, spapr_max_cores);
@@ -1804,7 +1804,7 @@ static void ppc_spapr_init(MachineState *machine)
             PowerPCCPU *cpu = cpu_ppc_init(machine->cpu_model);
             if (cpu == NULL) {
                 error_report("Unable to find PowerPC CPU definition");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             spapr_cpu_init(spapr, cpu, &error_fatal);
        }
@@ -1847,7 +1847,7 @@ static void ppc_spapr_init(MachineState *machine)
             error_report("Specified number of memory slots %"
                          PRIu64" exceeds max supported %d",
                          machine->ram_slots, max_memslots);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         spapr->hotplug_memory.base = ROUND_UP(machine->ram_size,
@@ -1865,22 +1865,22 @@ static void ppc_spapr_init(MachineState *machine)
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin");
     if (!filename) {
         error_report("Could not find LPAR rtas '%s'", "spapr-rtas.bin");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     spapr->rtas_size = get_image_size(filename);
     if (spapr->rtas_size < 0) {
         error_report("Could not get size of LPAR rtas '%s'", filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     spapr->rtas_blob = g_malloc(spapr->rtas_size);
     if (load_image_size(filename, spapr->rtas_blob, spapr->rtas_size) < 0) {
         error_report("Could not load LPAR rtas '%s'", filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (spapr->rtas_size > RTAS_MAX_SIZE) {
         error_report("RTAS too big ! 0x%zx bytes (max is 0x%x)",
                      (size_t)spapr->rtas_size, RTAS_MAX_SIZE);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     g_free(filename);
 
@@ -1950,7 +1950,7 @@ static void ppc_spapr_init(MachineState *machine)
         error_report(
             "pSeries SLOF firmware requires >= %ldM guest RMA (Real Mode Area memory)",
             MIN_RMA_SLOF);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (kernel_filename) {
@@ -1969,7 +1969,7 @@ static void ppc_spapr_init(MachineState *machine)
         if (kernel_size < 0) {
             error_report("error loading %s: %s",
                          kernel_filename, load_elf_strerror(kernel_size));
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         /* load initrd */
@@ -1983,7 +1983,7 @@ static void ppc_spapr_init(MachineState *machine)
             if (initrd_size < 0) {
                 error_report("could not load initial ram disk '%s'",
                              initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         } else {
             initrd_base = 0;
@@ -1997,12 +1997,12 @@ static void ppc_spapr_init(MachineState *machine)
     filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
     if (!filename) {
         error_report("Could not find LPAR firmware '%s'", bios_name);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     fw_size = load_image_targphys(filename, 0, FW_MAX_SIZE);
     if (fw_size <= 0) {
         error_report("Could not load LPAR firmware '%s'", filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     g_free(filename);
 
@@ -2042,7 +2042,7 @@ static int spapr_kvm_type(const char *vm_type)
     }
 
     error_report("Unknown kvm-type specified '%s'", vm_type);
-    exit(1);
+    exit(EXIT_FAILURE);
 }
 
 /*
diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
index b97d966..fb540a3 100644
--- a/hw/ppc/virtex_ml507.c
+++ b/hw/ppc/virtex_ml507.c
@@ -99,7 +99,7 @@ static PowerPCCPU *ppc440_init_xilinx(ram_addr_t *ram_size,
     cpu = cpu_ppc_init(cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "Unable to initialize CPU!\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
@@ -284,7 +284,7 @@ static void virtex_init(MachineState *machine)
             if (initrd_size < 0) {
                 error_report("couldn't load ram disk '%s'",
                              machine->initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             high = ROUND_UP(high + initrd_size, 4);
         }
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index dcb68b9..231718b 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -323,7 +323,7 @@ static long gethugepagesize(const char *mem_path)
     if (ret != 0) {
         fprintf(stderr, "Couldn't statfs() memory path: %s\n",
                 strerror(errno));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
 #define HUGETLBFS_MAGIC       0x958458f6
@@ -2063,7 +2063,7 @@ void kvmppc_set_papr(PowerPCCPU *cpu)
     ret = kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_PAPR, 0);
     if (ret) {
         error_report("This vCPU type or KVM version does not support PAPR");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Update the capability flag so we sync the right information
@@ -2084,7 +2084,7 @@ void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
     ret = kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_EPR, 0, mpic_proxy);
     if (ret && mpic_proxy) {
         error_report("This KVM version does not support EPR");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index 618334a..b704676 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -7149,7 +7149,7 @@ void gen_intermediate_code(CPUPPCState *env, struct TranslationBlock *tb)
             fprintf(stderr, "Opcode %02x %02x %02x %02x (%08x) leaked "
                     "temporaries\n", opc1(ctx.opcode), opc2(ctx.opcode),
                     opc3(ctx.opcode), opc4(ctx.opcode), ctx.opcode);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
     if (tb->cflags & CF_LAST_IO)
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 407ccb9..b362ae7 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -656,7 +656,7 @@ static inline void _spr_register(CPUPPCState *env, int num,
 #endif
         spr->uea_read != NULL || spr->uea_write != NULL) {
         printf("Error: Trying to register SPR %d (%03x) twice !\n", num, num);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 #if defined(PPC_DEBUG_SPR)
     printf("*** register spr %d (%03x) %s val " TARGET_FMT_lx "\n", num, num,
@@ -1742,7 +1742,7 @@ static void gen_spr_BookE (CPUPPCState *env, uint64_t ivor_mask)
         if (ivor_mask & (1ULL << i)) {
             if (ivor_sprn[i] == SPR_BOOKE_IVORxx) {
                 fprintf(stderr, "ERROR: IVOR %d SPR is not defined\n", i);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             spr_register(env, ivor_sprn[i], ivor_names[i],
                          SPR_NOACCESS, SPR_NOACCESS,
@@ -8974,12 +8974,12 @@ static void init_ppc_proc(PowerPCCPU *cpu)
         default:
             fprintf(stderr, "PowerPC MSR definition inconsistency\n"
                     "Should define POWERPC_FLAG_SPE or POWERPC_FLAG_VRE\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else if (env->flags & (POWERPC_FLAG_SPE | POWERPC_FLAG_VRE)) {
         fprintf(stderr, "PowerPC MSR definition inconsistency\n"
                 "Should not define POWERPC_FLAG_SPE nor POWERPC_FLAG_VRE\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (env->msr_mask & (1 << 17)) {
         switch (env->flags & (POWERPC_FLAG_TGPR | POWERPC_FLAG_CE)) {
@@ -8989,12 +8989,12 @@ static void init_ppc_proc(PowerPCCPU *cpu)
         default:
             fprintf(stderr, "PowerPC MSR definition inconsistency\n"
                     "Should define POWERPC_FLAG_TGPR or POWERPC_FLAG_CE\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else if (env->flags & (POWERPC_FLAG_TGPR | POWERPC_FLAG_CE)) {
         fprintf(stderr, "PowerPC MSR definition inconsistency\n"
                 "Should not define POWERPC_FLAG_TGPR nor POWERPC_FLAG_CE\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (env->msr_mask & (1 << 10)) {
         switch (env->flags & (POWERPC_FLAG_SE | POWERPC_FLAG_DWE |
@@ -9007,14 +9007,14 @@ static void init_ppc_proc(PowerPCCPU *cpu)
             fprintf(stderr, "PowerPC MSR definition inconsistency\n"
                     "Should define POWERPC_FLAG_SE or POWERPC_FLAG_DWE or "
                     "POWERPC_FLAG_UBLE\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else if (env->flags & (POWERPC_FLAG_SE | POWERPC_FLAG_DWE |
                              POWERPC_FLAG_UBLE)) {
         fprintf(stderr, "PowerPC MSR definition inconsistency\n"
                 "Should not define POWERPC_FLAG_SE nor POWERPC_FLAG_DWE nor "
                 "POWERPC_FLAG_UBLE\n");
-            exit(1);
+            exit(EXIT_FAILURE);
     }
     if (env->msr_mask & (1 << 9)) {
         switch (env->flags & (POWERPC_FLAG_BE | POWERPC_FLAG_DE)) {
@@ -9024,12 +9024,12 @@ static void init_ppc_proc(PowerPCCPU *cpu)
         default:
             fprintf(stderr, "PowerPC MSR definition inconsistency\n"
                     "Should define POWERPC_FLAG_BE or POWERPC_FLAG_DE\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else if (env->flags & (POWERPC_FLAG_BE | POWERPC_FLAG_DE)) {
         fprintf(stderr, "PowerPC MSR definition inconsistency\n"
                 "Should not define POWERPC_FLAG_BE nor POWERPC_FLAG_DE\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (env->msr_mask & (1 << 2)) {
         switch (env->flags & (POWERPC_FLAG_PX | POWERPC_FLAG_PMM)) {
@@ -9039,17 +9039,17 @@ static void init_ppc_proc(PowerPCCPU *cpu)
         default:
             fprintf(stderr, "PowerPC MSR definition inconsistency\n"
                     "Should define POWERPC_FLAG_PX or POWERPC_FLAG_PMM\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else if (env->flags & (POWERPC_FLAG_PX | POWERPC_FLAG_PMM)) {
         fprintf(stderr, "PowerPC MSR definition inconsistency\n"
                 "Should not define POWERPC_FLAG_PX nor POWERPC_FLAG_PMM\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if ((env->flags & (POWERPC_FLAG_RTC_CLK | POWERPC_FLAG_BUS_CLK)) == 0) {
         fprintf(stderr, "PowerPC flags inconsistency\n"
                 "Should define the time-base and decrementer clock source\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     /* Allocate TLBs buffer when needed */
 #if !defined(CONFIG_USER_ONLY)
@@ -10365,7 +10365,7 @@ static void ppc_cpu_reset(CPUState *s)
     msr |= (target_ulong)1 << MSR_LE; /* Little-endian user mode */
     if (!((env->msr_mask >> MSR_LE) & 1)) {
         fprintf(stderr, "Selected CPU does not support little-endian.\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 #endif
 #endif
diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c
index eaf1bd9..8377302 100644
--- a/tcg/ppc/tcg-target.inc.c
+++ b/tcg/ppc/tcg-target.inc.c
@@ -2742,7 +2742,7 @@ static void __attribute__((constructor)) tcg_cache_init(void)
         if (isize == 0) {
             fprintf(stderr, "getauxval AT_ICACHEBSIZE failed\n");
         }
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     dcache_bsize = dsize;
     icache_bsize = isize;
@@ -2760,7 +2760,7 @@ static void __attribute__((constructor)) tcg_cache_init(void)
     len = sizeof(cacheline);
     if (sysctl(name, 2, &cacheline, &len, NULL, 0)) {
         perror("sysctl CTL_HW HW_CACHELINE failed");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     dcache_bsize = cacheline;
     icache_bsize = cacheline;
@@ -2777,7 +2777,7 @@ static void __attribute__((constructor)) tcg_cache_init(void)
     if (sysctlbyname ("machdep.cacheline_size", &cacheline, &len, NULL, 0)) {
         fprintf(stderr, "sysctlbyname machdep.cacheline_size failed: %s\n",
                 strerror(errno));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     dcache_bsize = cacheline;
     icache_bsize = cacheline;
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 06/26] graphics: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (4 preceding siblings ...)
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 05/26] ppc: " Laurent Vivier
@ 2016-09-16 13:55 ` Laurent Vivier
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 07/26] tests: " Laurent Vivier
                   ` (22 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:55 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Gerd Hoffmann

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/console-gl.c |  2 +-
 ui/console.c    |  2 +-
 ui/curses.c     |  4 ++--
 ui/gtk.c        |  2 +-
 ui/sdl.c        |  8 ++++----
 ui/sdl2.c       |  2 +-
 ui/spice-core.c | 22 +++++++++++-----------
 ui/vnc.c        |  4 ++--
 8 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/ui/console-gl.c b/ui/console-gl.c
index 5165e21..42627fb 100644
--- a/ui/console-gl.c
+++ b/ui/console-gl.c
@@ -46,7 +46,7 @@ ConsoleGLState *console_gl_init_context(void)
     gls->texture_blit_prog = qemu_gl_create_compile_link_program
         (texture_blit_vert_src, texture_blit_frag_src);
     if (!gls->texture_blit_prog) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     gls->texture_blit_vao =
diff --git a/ui/console.c b/ui/console.c
index 3940762..bef0678 100644
--- a/ui/console.c
+++ b/ui/console.c
@@ -1389,7 +1389,7 @@ void register_displaychangelistener(DisplayChangeListener *dcl)
         if (dcl->con->gl) {
             fprintf(stderr, "can't register two opengl displays (%s, %s)\n",
                     dcl->ops->dpy_name, dcl->con->gl->ops->dpy_name);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         dcl->con->gl = dcl;
     }
diff --git a/ui/curses.c b/ui/curses.c
index d06f724..ea5834d 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -408,7 +408,7 @@ static void curses_keyboard_setup(void)
     if(keyboard_layout) {
         kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
         if (!kbd_layout)
-            exit(1);
+            exit(EXIT_FAILURE);
     }
 }
 
@@ -425,7 +425,7 @@ void curses_display_init(DisplayState *ds, int full_screen)
 #ifndef _WIN32
     if (!isatty(1)) {
         fprintf(stderr, "We need a terminal output\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 #endif
 
diff --git a/ui/gtk.c b/ui/gtk.c
index 58d20ee..39d456a 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -2158,7 +2158,7 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
 
     if (!gtkinit) {
         fprintf(stderr, "gtk initialization failed\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
diff --git a/ui/sdl.c b/ui/sdl.c
index d8cf5bc..d2d67aa 100644
--- a/ui/sdl.c
+++ b/ui/sdl.c
@@ -92,7 +92,7 @@ static void sdl_update(DisplayChangeListener *dcl,
         } else {
             if (sdl_zoom_blit(guest_screen, real_screen, SMOOTHING_ON, &rec) < 0) {
                 fprintf(stderr, "Zoom blit failed\n");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         }
     } 
@@ -122,7 +122,7 @@ static void do_sdl_resize(int width, int height, int bpp)
         if (!tmp_screen) {
             fprintf(stderr, "Could not open SDL display (%dx%dx%d): %s\n",
                     width, height, bpp, SDL_GetError());
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else {
         /*
@@ -957,7 +957,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     if(keyboard_layout) {
         kbd_layout = init_keyboard_layout(name2keysym, keyboard_layout);
         if (!kbd_layout)
-            exit(1);
+            exit(EXIT_FAILURE);
     }
 
     if (no_frame)
@@ -987,7 +987,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     if (SDL_Init (flags)) {
         fprintf(stderr, "Could not initialize SDL(%s) - exiting\n",
                 SDL_GetError());
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     vi = SDL_GetVideoInfo();
     host_format = *(vi->vfmt);
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 30d2a3c..73891aa 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -783,7 +783,7 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame)
     if (SDL_Init(flags)) {
         fprintf(stderr, "Could not initialize SDL(%s) - exiting\n",
                 SDL_GetError());
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     SDL_SetHint(SDL_HINT_GRAB_KEYBOARD, "1");
 
diff --git a/ui/spice-core.c b/ui/spice-core.c
index da05054..859cba6 100644
--- a/ui/spice-core.c
+++ b/ui/spice-core.c
@@ -333,7 +333,7 @@ static int parse_name(const char *string, const char *optname,
         return value;
     }
     error_report("spice: invalid %s: %s", optname, string);
-    exit(1);
+    exit(EXIT_FAILURE);
 }
 
 static const char *stream_video_names[] = {
@@ -605,7 +605,7 @@ static int add_channel(void *opaque, const char *name, const char *value,
         if (!*tls_port) {
             error_report("spice: tried to setup tls-channel"
                          " without specifying a TLS port");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         security = SPICE_CHANNEL_SECURITY_SSL;
     }
@@ -622,7 +622,7 @@ static int add_channel(void *opaque, const char *name, const char *value,
     }
     if (rc != 0) {
         error_report("spice: failed to set channel security for %s", value);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     return 0;
 }
@@ -661,11 +661,11 @@ void qemu_spice_init(void)
     tls_port = qemu_opt_get_number(opts, "tls-port", 0);
     if (port < 0 || port > 65535) {
         error_report("spice port is out of range");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (tls_port < 0 || tls_port > 65535) {
         error_report("spice tls-port is out of range");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     password = qemu_opt_get(opts, "password");
 
@@ -736,7 +736,7 @@ void qemu_spice_init(void)
     if (qemu_opt_get_bool(opts, "sasl", 0)) {
         if (spice_server_set_sasl(spice_server, 1) == -1) {
             error_report("spice: failed to enable sasl");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         auth = "sasl";
     }
@@ -755,7 +755,7 @@ void qemu_spice_init(void)
 #else
         error_report("this qemu build does not support the "
                      "\"disable-agent-file-xfer\" option");
-        exit(1);
+        exit(EXIT_FAILURE);
 #endif
     }
 
@@ -803,7 +803,7 @@ void qemu_spice_init(void)
     spice_server_set_sasl_appname(spice_server, "qemu");
     if (spice_server_init(spice_server, &core_interface) != 0) {
         error_report("failed to initialize spice server");
-        exit(1);
+        exit(EXIT_FAILURE);
     };
     using_spice = 1;
 
@@ -831,11 +831,11 @@ void qemu_spice_init(void)
         if ((port != 0) || (tls_port != 0)) {
             error_report("SPICE GL support is local-only for now and "
                          "incompatible with -spice port/tls-port");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         if (egl_rendernode_init() != 0) {
             error_report("Failed to initialize EGL render node for SPICE GL");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         display_opengl = 1;
     }
@@ -847,7 +847,7 @@ int qemu_spice_add_interface(SpiceBaseInstance *sin)
     if (!spice_server) {
         if (QTAILQ_FIRST(&qemu_spice_opts.head) != NULL) {
             error_report("Oops: spice configured but not active");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         /*
          * Create a spice server instance.
diff --git a/ui/vnc.c b/ui/vnc.c
index 76a3273..796d857 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -3154,7 +3154,7 @@ void vnc_display_init(const char *id)
     }
 
     if (!vs->kbd_layout)
-        exit(1);
+        exit(EXIT_FAILURE);
 
     vs->share_policy = VNC_SHARE_POLICY_ALLOW_EXCLUSIVE;
     vs->connections_limit = 32;
@@ -3929,7 +3929,7 @@ int vnc_init_func(void *opaque, QemuOpts *opts, Error **errp)
     vnc_display_open(id, &local_err);
     if (local_err != NULL) {
         error_reportf_err(local_err, "Failed to start VNC server: ");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     return 0;
 }
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 07/26] tests: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (5 preceding siblings ...)
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 06/26] graphics: " Laurent Vivier
@ 2016-09-16 13:55 ` Laurent Vivier
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 08/26] replay: " Laurent Vivier
                   ` (21 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:55 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 tests/ipmi-bt-test.c      |  6 +++---
 tests/libqtest.c          |  8 ++++----
 tests/migration/stress.c  |  4 ++--
 tests/qht-bench.c         |  2 +-
 tests/rcutorture.c        |  4 ++--
 tests/tcg/hello-i386.c    |  2 +-
 tests/tcg/linux-test.c    |  4 ++--
 tests/tcg/runcom.c        | 12 ++++++------
 tests/tcg/test_path.c     |  2 +-
 tests/test-aio.c          |  2 +-
 tests/test-iov.c          |  8 ++++----
 tests/test-thread-pool.c  |  2 +-
 tests/vhost-user-bridge.c | 18 +++++++++---------
 13 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/tests/ipmi-bt-test.c b/tests/ipmi-bt-test.c
index be9005e..269f276 100644
--- a/tests/ipmi-bt-test.c
+++ b/tests/ipmi-bt-test.c
@@ -383,16 +383,16 @@ static void open_socket(void)
     emu_lfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
     if (emu_lfd == -1) {
         perror("socket");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (bind(emu_lfd, (struct sockaddr *) &myaddr, sizeof(myaddr)) == -1) {
         perror("bind");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     addrlen = sizeof(myaddr);
     if (getsockname(emu_lfd, (struct sockaddr *) &myaddr , &addrlen) == -1) {
         perror("getsockname");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     emu_port = ntohs(myaddr.sin_port);
     assert(listen(emu_lfd, 1) != -1);
diff --git a/tests/libqtest.c b/tests/libqtest.c
index 42ccb62..92e019f 100644
--- a/tests/libqtest.c
+++ b/tests/libqtest.c
@@ -182,7 +182,7 @@ QTestState *qtest_init(const char *extra_args)
                                   qmp_socket_path,
                                   extra_args ?: "");
         execlp("/bin/sh", "sh", "-c", command, NULL);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     s->fd = socket_accept(sock);
@@ -284,7 +284,7 @@ static GString *qtest_recv_line(QTestState *s)
 
         if (len == -1 || len == 0) {
             fprintf(stderr, "Broken pipe\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         g_string_append_len(s->rx, buffer, len);
@@ -355,7 +355,7 @@ static void qmp_response(JSONMessageParser *parser, GQueue *tokens)
     obj = json_parser_parse(tokens, NULL);
     if (!obj) {
         fprintf(stderr, "QMP JSON response parsing failed\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     g_assert(qobject_type(obj) == QTYPE_QDICT);
@@ -381,7 +381,7 @@ QDict *qmp_fd_receive(int fd)
 
         if (len == -1 || len == 0) {
             fprintf(stderr, "Broken pipe\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         if (log) {
diff --git a/tests/migration/stress.c b/tests/migration/stress.c
index cf8ce8b..95d2e02 100644
--- a/tests/migration/stress.c
+++ b/tests/migration/stress.c
@@ -51,7 +51,7 @@ static __attribute__((noreturn)) void exit_failure(void)
                 argv0, gettid(), strerror(errno));
         abort();
     } else {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -64,7 +64,7 @@ static __attribute__((noreturn)) void exit_success(void)
                 argv0, gettid(), strerror(errno));
         abort();
     } else {
-        exit(0);
+        exit(EXIT_SUCCESS);
     }
 }
 
diff --git a/tests/qht-bench.c b/tests/qht-bench.c
index 76360a0..4bf2aa3 100644
--- a/tests/qht-bench.c
+++ b/tests/qht-bench.c
@@ -432,7 +432,7 @@ static void parse_args(int argc, char *argv[])
             break;
         case 'h':
             usage_complete(argc, argv);
-            exit(0);
+            exit(EXIT_SUCCESS);
         case 'k':
             init_size = atol(optarg);
             break;
diff --git a/tests/rcutorture.c b/tests/rcutorture.c
index 4002ecf..0a992fd 100644
--- a/tests/rcutorture.c
+++ b/tests/rcutorture.c
@@ -179,7 +179,7 @@ static void perftestrun(int nthreads, int duration, int nreaders, int nupdaters)
         (double)n_reads),
            ((duration * 1000*1000*1000.*(double)nupdaters) /
         (double)n_updates));
-    exit(0);
+    exit(EXIT_SUCCESS);
 }
 
 static void perftest(int nreaders, int duration)
@@ -362,7 +362,7 @@ static void stresstest(int nreaders, int duration)
         printf(" %lld", rcu_stress_count[i]);
     }
     printf("\n");
-    exit(0);
+    exit(EXIT_SUCCESS);
 }
 
 /* GTest interface */
diff --git a/tests/tcg/hello-i386.c b/tests/tcg/hello-i386.c
index fa00380..8b74684 100644
--- a/tests/tcg/hello-i386.c
+++ b/tests/tcg/hello-i386.c
@@ -23,5 +23,5 @@ static inline int write(int fd, const char * buf, int len)
 void _start(void)
 {
     write(1, "Hello World\n", 12);
-    exit(0);
+    exit(EXIT_SUCCESS);
 }
diff --git a/tests/tcg/linux-test.c b/tests/tcg/linux-test.c
index 5070d31..c61cc22 100644
--- a/tests/tcg/linux-test.c
+++ b/tests/tcg/linux-test.c
@@ -53,7 +53,7 @@ void error1(const char *filename, int line, const char *fmt, ...)
     vfprintf(stderr, fmt, ap);
     fprintf(stderr, "\n");
     va_end(ap);
-    exit(1);
+    exit(EXIT_FAILURE);
 }
 
 int __chk_error(const char *filename, int line, int ret)
@@ -334,7 +334,7 @@ void test_socket(void)
         client_fd = client_socket();
         send(client_fd, socket_msg, sizeof(socket_msg), 0);
         close(client_fd);
-        exit(0);
+        exit(EXIT_SUCCESS);
     }
     len = sizeof(sockaddr);
     fd = chk_error(accept(server_fd, (struct sockaddr *)&sockaddr, &len));
diff --git a/tests/tcg/runcom.c b/tests/tcg/runcom.c
index d60342b..3483b62 100644
--- a/tests/tcg/runcom.c
+++ b/tests/tcg/runcom.c
@@ -27,7 +27,7 @@ static void usage(void)
     printf("runcom version 0.1 (c) 2003 Fabrice Bellard\n"
            "usage: runcom file.com\n"
            "VM86 Run simple .com DOS executables (linux vm86 test mode)\n");
-    exit(1);
+    exit(EXIT_FAILURE);
 }
 
 static inline void set_bit(uint8_t *a, unsigned int bit)
@@ -83,7 +83,7 @@ int main(int argc, char **argv)
                     MAP_FIXED | MAP_ANON | MAP_PRIVATE, -1, 0);
     if (vm86_mem == MAP_FAILED) {
         perror("mmap");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 #ifdef SIGTEST
     {
@@ -101,12 +101,12 @@ int main(int argc, char **argv)
     fd = open(filename, O_RDONLY);
     if (fd < 0) {
         perror(filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     ret = read(fd, vm86_mem + COM_BASE_ADDR, 65536 - 256);
     if (ret < 0) {
         perror("read");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     close(fd);
 
@@ -151,7 +151,7 @@ int main(int argc, char **argv)
                 ah = (r->eax >> 8) & 0xff;
                 switch(ah) {
                 case 0x00: /* exit */
-                    exit(0);
+                    exit(EXIT_SUCCESS);
                 case 0x02: /* write char */
                     {
                         uint8_t c = r->edx;
@@ -186,7 +186,7 @@ int main(int argc, char **argv)
         default:
             fprintf(stderr, "unhandled vm86 return code (0x%x)\n", ret);
             dump_regs(&ctx.regs);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 }
diff --git a/tests/tcg/test_path.c b/tests/tcg/test_path.c
index 1c29bce..303eb66 100644
--- a/tests/tcg/test_path.c
+++ b/tests/tcg/test_path.c
@@ -20,7 +20,7 @@ void qemu_log(const char *fmt, ...)
     va_start(ap, fmt);
     vfprintf(stderr, fmt, ap);
     va_end(ap);
-    exit(1);
+    exit(EXIT_FAILURE);
 }
 
 #define NO_CHANGE(_path)						\
diff --git a/tests/test-aio.c b/tests/test-aio.c
index 03aa846..3249bc7 100644
--- a/tests/test-aio.c
+++ b/tests/test-aio.c
@@ -834,7 +834,7 @@ int main(int argc, char **argv)
     ctx = aio_context_new(&local_error);
     if (!ctx) {
         error_reportf_err(local_error, "Failed to create AIO Context: ");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     src = aio_get_g_source(ctx);
     g_source_attach(src, NULL);
diff --git a/tests/test-iov.c b/tests/test-iov.c
index a22d71f..9af8f32 100644
--- a/tests/test-iov.c
+++ b/tests/test-iov.c
@@ -172,7 +172,7 @@ static void test_io(void)
 
     if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) < 0) {
        perror("socketpair");
-       exit(1);
+       exit(EXIT_FAILURE);
     }
 
     FD_ZERO(&fds);
@@ -203,7 +203,7 @@ static void test_io(void)
                        continue;
                    } else {
                        perror("send");
-                       exit(1);
+                       exit(EXIT_FAILURE);
                    }
                } while(k < j);
            }
@@ -211,7 +211,7 @@ static void test_io(void)
        iov_free(iov, niov);
        g_free(buf);
        g_free(siov);
-       exit(0);
+       exit(EXIT_SUCCESS);
 
     } else {
        /* reader & verifier */
@@ -243,7 +243,7 @@ static void test_io(void)
                        continue;
                    } else {
                        perror("recv");
-                       exit(1);
+                       exit(EXIT_FAILURE);
                    }
                } while(k < j);
                test_iov_bytes(iov, niov, i, j - i);
diff --git a/tests/test-thread-pool.c b/tests/test-thread-pool.c
index 8dbf66a..6b992de 100644
--- a/tests/test-thread-pool.c
+++ b/tests/test-thread-pool.c
@@ -231,7 +231,7 @@ int main(int argc, char **argv)
     ctx = aio_context_new(&local_error);
     if (!ctx) {
         error_reportf_err(local_error, "Failed to create AIO Context: ");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     pool = aio_get_thread_pool(ctx);
 
diff --git a/tests/vhost-user-bridge.c b/tests/vhost-user-bridge.c
index 775e031..63c3716 100644
--- a/tests/vhost-user-bridge.c
+++ b/tests/vhost-user-bridge.c
@@ -68,7 +68,7 @@ static void
 vubr_die(const char *s)
 {
     perror(s);
-    exit(1);
+    exit(EXIT_FAILURE);
 }
 
 static int
@@ -389,7 +389,7 @@ vubr_message_read(int conn_fd, VhostUserMsg *vmsg)
     if (rc == 0) {
         vubr_die("recvmsg");
         fprintf(stderr, "Peer disconnected.\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (rc < 0) {
         vubr_die("recvmsg");
@@ -413,7 +413,7 @@ vubr_message_read(int conn_fd, VhostUserMsg *vmsg)
                 "Error: too big message request: %d, size: vmsg->size: %u, "
                 "while sizeof(vmsg->payload) = %zu\n",
                 vmsg->request, vmsg->size, sizeof(vmsg->payload));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (vmsg->size) {
@@ -421,7 +421,7 @@ vubr_message_read(int conn_fd, VhostUserMsg *vmsg)
         if (rc == 0) {
             vubr_die("recvmsg");
             fprintf(stderr, "Peer disconnected.\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         if (rc < 0) {
             vubr_die("recvmsg");
@@ -572,7 +572,7 @@ vubr_post_buffer(VubrDev *dev, VubrVirtq *vq, uint8_t *buf, int32_t len)
         if (!(desc[i].flags & VRING_DESC_F_WRITE)) {
             /* FIXME: we should find writable descriptor. */
             fprintf(stderr, "Error: descriptor is not writable. Exiting.\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         void *chunk_start = (void *)(uintptr_t)gpa_to_va(dev, desc[i].addr);
@@ -1276,14 +1276,14 @@ vubr_set_host(struct sockaddr_in *saddr, const char *host)
     if (isdigit(host[0])) {
         if (!inet_aton(host, &saddr->sin_addr)) {
             fprintf(stderr, "inet_aton() failed.\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else {
         struct hostent *he = gethostbyname(host);
 
         if (!he) {
             fprintf(stderr, "gethostbyname() failed.\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         saddr->sin_addr = *(struct in_addr *)he->h_addr;
     }
@@ -1304,13 +1304,13 @@ vubr_backend_udp_setup(VubrDev *dev,
     lport = strtol(local_port, (char **)&r, 0);
     if (r == local_port) {
         fprintf(stderr, "lport parsing failed.\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     rport = strtol(remote_port, (char **)&r, 0);
     if (r == remote_port) {
         fprintf(stderr, "rport parsing failed.\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     struct sockaddr_in si_local = {
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 08/26] replay: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (6 preceding siblings ...)
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 07/26] tests: " Laurent Vivier
@ 2016-09-16 13:55 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 09/26] qemu-user: " Laurent Vivier
                   ` (20 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:55 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 replay/replay-char.c     |  6 +++---
 replay/replay-events.c   |  6 +++---
 replay/replay-internal.c |  2 +-
 replay/replay-time.c     |  2 +-
 replay/replay.c          | 14 +++++++-------
 5 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/replay/replay-char.c b/replay/replay-char.c
index edf46ab..0011079 100755
--- a/replay/replay-char.c
+++ b/replay/replay-char.c
@@ -56,7 +56,7 @@ void replay_chr_be_write(CharDriverState *s, uint8_t *buf, int len)
     event->id = find_char_driver(s);
     if (event->id < 0) {
         fprintf(stderr, "Replay: cannot find char driver\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     event->buf = g_malloc(len);
     memcpy(event->buf, buf, len);
@@ -116,7 +116,7 @@ void replay_char_write_event_load(int *res, int *offset)
     } else {
         replay_mutex_unlock();
         error_report("Missing character write event in the replay log");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -140,7 +140,7 @@ int replay_char_read_all_load(uint8_t *buf)
     } else {
         replay_mutex_unlock();
         error_report("Missing character read all event in the replay log");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
diff --git a/replay/replay-events.c b/replay/replay-events.c
index 3807245..14a2978 100644
--- a/replay/replay-events.c
+++ b/replay/replay-events.c
@@ -57,7 +57,7 @@ static void replay_run_event(Event *event)
     default:
         error_report("Replay: invalid async event ID (%d) in the queue",
                     event->event_kind);
-        exit(1);
+        exit(EXIT_FAILURE);
         break;
     }
 }
@@ -191,7 +191,7 @@ static void replay_save_event(Event *event, int checkpoint)
             break;
         default:
             error_report("Unknown ID %" PRId64 " of replay event", event->id);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 }
@@ -254,7 +254,7 @@ static Event *replay_read_event(int checkpoint)
         break;
     default:
         error_report("Unknown ID %d of replay event", read_event_kind);
-        exit(1);
+        exit(EXIT_FAILURE);
         break;
     }
 
diff --git a/replay/replay-internal.c b/replay/replay-internal.c
index 5835e8d..532323d 100644
--- a/replay/replay-internal.c
+++ b/replay/replay-internal.c
@@ -159,7 +159,7 @@ void replay_fetch_data_kind(void)
             replay_has_unread_data = 1;
             if (replay_data_kind >= EVENT_COUNT) {
                 error_report("Replay: unknown event kind %d", replay_data_kind);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         }
     }
diff --git a/replay/replay-time.c b/replay/replay-time.c
index fffe072..1741a84 100644
--- a/replay/replay-time.c
+++ b/replay/replay-time.c
@@ -61,5 +61,5 @@ int64_t replay_read_clock(ReplayClockKind kind)
     }
 
     error_report("REPLAY INTERNAL ERROR %d", __LINE__);
-    exit(1);
+    exit(EXIT_FAILURE);
 }
diff --git a/replay/replay.c b/replay/replay.c
index 167fd29..d257b24 100644
--- a/replay/replay.c
+++ b/replay/replay.c
@@ -221,7 +221,7 @@ static void replay_enable(const char *fname, int mode)
         break;
     default:
         fprintf(stderr, "Replay: internal error: invalid replay mode\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     atexit(replay_finish);
@@ -231,7 +231,7 @@ static void replay_enable(const char *fname, int mode)
     replay_file = fopen(fname, fmode);
     if (replay_file == NULL) {
         fprintf(stderr, "Replay: open %s: %s\n", fname, strerror(errno));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     replay_filename = g_strdup(fname);
@@ -248,7 +248,7 @@ static void replay_enable(const char *fname, int mode)
         unsigned int version = replay_get_dword();
         if (version != REPLAY_VERSION) {
             fprintf(stderr, "Replay: invalid input log file version\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         /* go to the beginning */
         fseek(replay_file, HEADER_SIZE, SEEK_SET);
@@ -282,13 +282,13 @@ void replay_configure(QemuOpts *opts)
         mode = REPLAY_MODE_PLAY;
     } else {
         error_report("Invalid icount rr option: %s", rr);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     fname = qemu_opt_get(opts, "rrfile");
     if (!fname) {
         error_report("File name not specified for replay");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     replay_enable(fname, mode);
@@ -305,11 +305,11 @@ void replay_start(void)
 
     if (replay_blockers) {
         error_reportf_err(replay_blockers->data, "Record/replay: ");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (!use_icount) {
         error_report("Please enable icount to use record/replay");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Timer for snapshotting will be set up here. */
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 09/26] qemu-user: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (7 preceding siblings ...)
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 08/26] replay: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-21 19:21   ` Riku Voipio
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 10/26] m68k: " Laurent Vivier
                   ` (19 subsequent siblings)
  28 siblings, 1 reply; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Riku Voipio

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Riku Voipio <riku.voipio@iki.fi>
---
 bsd-user/main.c      | 20 ++++++++++----------
 linux-user/main.c    |  4 ++--
 linux-user/syscall.c |  2 +-
 3 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/bsd-user/main.c b/bsd-user/main.c
index 0fb08e4..e47e4d7 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -658,7 +658,7 @@ void cpu_loop(CPUSPARCState *env)
 #endif
             printf ("Unhandled trap: 0x%x\n", trapnr);
             cpu_dump_state(cs, stderr, fprintf, 0);
-            exit (1);
+            exit(EXIT_FAILURE);
         }
         process_pending_signals (env);
     }
@@ -708,7 +708,7 @@ static void usage(void)
            TARGET_NAME,
            interp_prefix,
            x86_stack_size);
-    exit(1);
+    exit(EXIT_FAILURE);
 }
 
 THREAD CPUState *thread_cpu;
@@ -752,7 +752,7 @@ int main(int argc, char **argv)
 
     if ((envlist = envlist_create()) == NULL) {
         (void) fprintf(stderr, "Unable to allocate envlist\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* add current environment into the list */
@@ -793,7 +793,7 @@ int main(int argc, char **argv)
             envlist_free(envlist);
             if ((envlist = envlist_create()) == NULL) {
                 (void) fprintf(stderr, "Unable to allocate envlist\n");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         } else if (!strcmp(r, "U")) {
             r = argv[optind++];
@@ -815,7 +815,7 @@ int main(int argc, char **argv)
             if (qemu_host_page_size == 0 ||
                 (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) {
                 fprintf(stderr, "page size must be a power of two\n");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         } else if (!strcmp(r, "g")) {
             gdbstub_port = atoi(argv[optind++]);
@@ -828,7 +828,7 @@ int main(int argc, char **argv)
 #if defined(cpu_list)
                     cpu_list(stdout, &fprintf);
 #endif
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         } else if (!strcmp(r, "B")) {
            guest_base = strtol(argv[optind++], NULL, 0);
@@ -867,7 +867,7 @@ int main(int argc, char **argv)
         mask = qemu_str_to_log_mask(log_mask);
         if (!mask) {
             qemu_print_log_usage(stdout);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         qemu_set_log(mask);
     }
@@ -878,7 +878,7 @@ int main(int argc, char **argv)
     filename = argv[optind];
 
     if (!trace_init_backends()) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     trace_init_file(trace_file);
 
@@ -914,7 +914,7 @@ int main(int argc, char **argv)
     cpu = cpu_init(cpu_model);
     if (!cpu) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = cpu->env_ptr;
 #if defined(TARGET_SPARC) || defined(TARGET_PPC)
@@ -1010,7 +1010,7 @@ int main(int argc, char **argv)
     /* enable 64 bit mode if possible */
     if (!(env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM)) {
         fprintf(stderr, "The selected x86 CPU does not support 64 bit mode\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env->cr[4] |= CR4_PAE_MASK;
     env->efer |= MSR_EFER_LMA | MSR_EFER_LME;
diff --git a/linux-user/main.c b/linux-user/main.c
index 3ad70f8..0ab5360 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -4243,7 +4243,7 @@ int main(int argc, char **argv, char **envp)
     optind = parse_args(argc, argv);
 
     if (!trace_init_backends()) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     trace_init_file(trace_file);
 
@@ -4700,7 +4700,7 @@ int main(int argc, char **argv, char **envp)
             if ((env->active_fpu.fcr31_rw_bitmask &
                   (1 << FCR31_NAN2008)) == 0) {
                 fprintf(stderr, "ELF binary's NaN mode not supported by CPU\n");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             if ((info->elf_flags & EF_MIPS_NAN2008) != 0) {
                 env->active_fpu.fcr31 |= (1 << FCR31_NAN2008);
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ca06943..da1f581 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6513,7 +6513,7 @@ void syscall_init(void)
             if (arg_type[0] != TYPE_PTR) {
                 fprintf(stderr, "cannot patch size for ioctl 0x%x\n",
                         ie->target_cmd);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             arg_type++;
             size = thunk_type_size(arg_type, 0);
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 10/26] m68k: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (8 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 09/26] qemu-user: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 11/26] pci, virtio: " Laurent Vivier
                   ` (18 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 hw/m68k/an5206.c     | 6 +++---
 hw/m68k/dummy_m68k.c | 4 ++--
 hw/m68k/mcf5208.c    | 8 ++++----
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/hw/m68k/an5206.c b/hw/m68k/an5206.c
index 142bab9..9c2cb1e 100644
--- a/hw/m68k/an5206.c
+++ b/hw/m68k/an5206.c
@@ -45,7 +45,7 @@ static void an5206_init(MachineState *machine)
     cpu = cpu_m68k_init(cpu_model);
     if (!cpu) {
         error_report("Unable to find m68k CPU definition");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
@@ -72,7 +72,7 @@ static void an5206_init(MachineState *machine)
             return;
         }
         fprintf(stderr, "Kernel image must be specified\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
@@ -89,7 +89,7 @@ static void an5206_init(MachineState *machine)
     }
     if (kernel_size < 0) {
         fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     env->pc = entry;
diff --git a/hw/m68k/dummy_m68k.c b/hw/m68k/dummy_m68k.c
index 0b11d20..09981a0 100644
--- a/hw/m68k/dummy_m68k.c
+++ b/hw/m68k/dummy_m68k.c
@@ -37,7 +37,7 @@ static void dummy_m68k_init(MachineState *machine)
     cpu = cpu_m68k_init(cpu_model);
     if (!cpu) {
         fprintf(stderr, "Unable to find m68k CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
@@ -67,7 +67,7 @@ static void dummy_m68k_init(MachineState *machine)
         if (kernel_size < 0) {
             fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else {
         entry = 0;
diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c
index 2415557..3c833ba 100644
--- a/hw/m68k/mcf5208.c
+++ b/hw/m68k/mcf5208.c
@@ -213,7 +213,7 @@ static void mcf5208evb_init(MachineState *machine)
     cpu = cpu_m68k_init(cpu_model);
     if (!cpu) {
         fprintf(stderr, "Unable to find m68k CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
@@ -241,7 +241,7 @@ static void mcf5208evb_init(MachineState *machine)
 
     if (nb_nics > 1) {
         fprintf(stderr, "Too many NICs\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (nd_table[0].used)
         mcf_fec_init(address_space_mem, &nd_table[0],
@@ -275,7 +275,7 @@ static void mcf5208evb_init(MachineState *machine)
             return;
         }
         fprintf(stderr, "Kernel image must be specified\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
@@ -292,7 +292,7 @@ static void mcf5208evb_init(MachineState *machine)
     }
     if (kernel_size < 0) {
         fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     env->pc = entry;
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 11/26] pci, virtio: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (9 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 10/26] m68k: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 12/26] sparc: " Laurent Vivier
                   ` (17 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Stefan Hajnoczi

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/9pfs/9p.c                    |  2 +-
 hw/block/virtio-blk.c           |  6 +++---
 hw/net/virtio-net.c             | 10 +++++-----
 hw/pci/pci.c                    | 12 ++++++------
 hw/scsi/vhost-scsi.c            |  4 ++--
 hw/scsi/virtio-scsi-dataplane.c |  2 +-
 hw/scsi/virtio-scsi.c           |  6 +++---
 hw/virtio/virtio.c              | 28 ++++++++++++++--------------
 8 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index dfe293d..6fe7a1c 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -3513,7 +3513,7 @@ static void __attribute__((__constructor__)) v9fs_set_fd_limit(void)
     struct rlimit rlim;
     if (getrlimit(RLIMIT_NOFILE, &rlim) < 0) {
         error_report("Failed to get the resource limit");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     open_fd_hw = rlim.rlim_cur - MIN(400, rlim.rlim_cur/3);
     open_fd_rc = rlim.rlim_cur/2;
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index 3a6112f..8561265 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -478,20 +478,20 @@ void virtio_blk_handle_request(VirtIOBlockReq *req, MultiReqBuffer *mrb)
 
     if (req->elem.out_num < 1 || req->elem.in_num < 1) {
         error_report("virtio-blk missing headers");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (unlikely(iov_to_buf(iov, out_num, 0, &req->out,
                             sizeof(req->out)) != sizeof(req->out))) {
         error_report("virtio-blk request outhdr too short");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     iov_discard_front(&iov, &out_num, sizeof(req->out));
 
     if (in_iov[in_num - 1].iov_len < sizeof(struct virtio_blk_inhdr)) {
         error_report("virtio-blk request inhdr too short");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* We always touch the last byte, so just see how big in_iov is.  */
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 01f1351..f596cc1 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -893,7 +893,7 @@ static void virtio_net_handle_ctrl(VirtIODevice *vdev, VirtQueue *vq)
         if (iov_size(elem->in_sg, elem->in_num) < sizeof(status) ||
             iov_size(elem->out_sg, elem->out_num) < sizeof(ctrl)) {
             error_report("virtio-net ctrl missing headers");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         iov_cnt = elem->out_num;
@@ -1131,12 +1131,12 @@ static ssize_t virtio_net_receive(NetClientState *nc, const uint8_t *buf, size_t
                          i, n->mergeable_rx_bufs, offset, size,
                          n->guest_hdr_len, n->host_hdr_len,
                          vdev->guest_features);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         if (elem->in_num < 1) {
             error_report("virtio-net receive queue contains no in buffers");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         sg = elem->in_sg;
@@ -1239,14 +1239,14 @@ static int32_t virtio_net_flush_tx(VirtIONetQueue *q)
         out_sg = elem->out_sg;
         if (out_num < 1) {
             error_report("virtio-net header not in first element");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         if (n->has_vnet_hdr) {
             if (iov_to_buf(out_sg, out_num, 0, &mhdr, n->guest_hdr_len) <
                 n->guest_hdr_len) {
                 error_report("virtio-net header incorrect");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             if (n->needs_vnet_hdr_swap) {
                 virtio_net_hdr_swap(vdev, (void *) &mhdr);
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 24fae16..04723d5 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -884,7 +884,7 @@ static uint16_t pci_req_id_cache_extract(PCIReqIDCache *cache)
     default:
         error_printf("Invalid PCI requester ID cache type: %d\n",
                      cache->type);
-        exit(1);
+        exit(EXIT_FAILURE);
         break;
     }
 
@@ -1085,7 +1085,7 @@ void pci_register_bar(PCIDevice *pci_dev, int region_num,
     if (size & (size-1)) {
         fprintf(stderr, "ERROR: PCI region size must be pow2 "
                     "type=0x%x, size=0x%"FMT_PCIBUS"\n", type, size);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     r = &pci_dev->io_regions[region_num];
@@ -1787,19 +1787,19 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
     int i;
 
     if (qemu_show_nic_models(nd->model, pci_nic_models)) {
-        exit(0);
+        exit(EXIT_SUCCESS);
     }
 
     i = qemu_find_nic_model(nd, pci_nic_models, default_model);
     if (i < 0) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     bus = pci_get_bus_devfn(&devfn, rootbus, devaddr);
     if (!bus) {
         error_report("Invalid PCI device address %s for device %s",
                      devaddr, pci_nic_names[i]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     pci_dev = pci_create(bus, devfn, pci_nic_names[i]);
@@ -1810,7 +1810,7 @@ PCIDevice *pci_nic_init_nofail(NICInfo *nd, PCIBus *rootbus,
     if (err) {
         error_report_err(err);
         object_unparent(OBJECT(dev));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     return pci_dev;
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index 5b26946..1cbdc92 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -172,7 +172,7 @@ static void vhost_scsi_set_config(VirtIODevice *vdev,
     if ((uint32_t) virtio_ldl_p(vdev, &scsiconf->sense_size) != vs->sense_size ||
         (uint32_t) virtio_ldl_p(vdev, &scsiconf->cdb_size) != vs->cdb_size) {
         error_report("vhost-scsi does not support changing the sense data and CDB sizes");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -194,7 +194,7 @@ static void vhost_scsi_set_status(VirtIODevice *vdev, uint8_t val)
                          strerror(-ret));
 
             /* There is no userspace virtio-scsi fallback so exit */
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else {
         vhost_scsi_stop(s);
diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
index b173b94..18e8701 100644
--- a/hw/scsi/virtio-scsi-dataplane.c
+++ b/hw/scsi/virtio-scsi-dataplane.c
@@ -34,7 +34,7 @@ void virtio_scsi_set_iothread(VirtIOSCSI *s, IOThread *iothread)
     if (!k->set_guest_notifiers || !k->ioeventfd_started) {
         fprintf(stderr, "virtio-scsi: Failed to set iothread "
                    "(transport does not support notifiers)");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index e596b64..eaf4e18 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -84,7 +84,7 @@ static void virtio_scsi_complete_req(VirtIOSCSIReq *req)
 static void virtio_scsi_bad_req(void)
 {
     error_report("wrong size for virtio-scsi headers");
-    exit(1);
+    exit(EXIT_FAILURE);
 }
 
 static size_t qemu_sgl_concat(VirtIOSCSIReq *req, struct iovec *iov,
@@ -208,7 +208,7 @@ static void *virtio_scsi_load_request(QEMUFile *f, SCSIRequest *sreq)
     if (virtio_scsi_parse_req(req, sizeof(VirtIOSCSICmdReq) + vs->cdb_size,
                               sizeof(VirtIOSCSICmdResp) + vs->sense_size) < 0) {
         error_report("invalid SCSI request migration data");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     scsi_req_ref(sreq);
@@ -628,7 +628,7 @@ static void virtio_scsi_set_config(VirtIODevice *vdev,
     if ((uint32_t) virtio_ldl_p(vdev, &scsiconf->sense_size) >= 65536 ||
         (uint32_t) virtio_ldl_p(vdev, &scsiconf->cdb_size) >= 256) {
         error_report("bad data written to virtio-scsi configuration space");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     vs->sense_size = virtio_ldl_p(vdev, &scsiconf->sense_size);
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index fcf3358..8eb6ebb 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -339,7 +339,7 @@ static int virtqueue_num_heads(VirtQueue *vq, unsigned int idx)
     if (num_heads > vq->vring.num) {
         error_report("Guest moved used index from %u to %u",
                      idx, vq->shadow_avail_idx);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     /* On success, callers read a descriptor at vq->last_avail_idx.
      * Make sure descriptor read does not bypass avail index read. */
@@ -361,7 +361,7 @@ static unsigned int virtqueue_get_head(VirtQueue *vq, unsigned int idx)
     /* If their number is silly, that's a fatal mistake. */
     if (head >= vq->vring.num) {
         error_report("Guest says index %u is available", head);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     return head;
@@ -384,7 +384,7 @@ static unsigned virtqueue_read_next_desc(VirtIODevice *vdev, VRingDesc *desc,
 
     if (next >= max) {
         error_report("Desc next is %u", next);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     vring_desc_read(vdev, desc, desc_pa, next);
@@ -417,13 +417,13 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
         if (desc.flags & VRING_DESC_F_INDIRECT) {
             if (desc.len % sizeof(VRingDesc)) {
                 error_report("Invalid size for indirect buffer table");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
 
             /* If we've got too many, that implies a descriptor loop. */
             if (num_bufs >= max) {
                 error_report("Looped descriptor");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
 
             /* loop over the indirect descriptor table */
@@ -438,7 +438,7 @@ void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes,
             /* If we've got too many, that implies a descriptor loop. */
             if (++num_bufs > max) {
                 error_report("Looped descriptor");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
 
             if (desc.flags & VRING_DESC_F_WRITE) {
@@ -483,7 +483,7 @@ static void virtqueue_map_desc(unsigned int *p_num_sg, hwaddr *addr, struct iove
 
     if (!sz) {
         error_report("virtio: zero sized buffers are not allowed");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     while (sz) {
@@ -491,7 +491,7 @@ static void virtqueue_map_desc(unsigned int *p_num_sg, hwaddr *addr, struct iove
 
         if (num_sg == max_num_sg) {
             error_report("virtio: too many write descriptors in indirect table");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         iov[num_sg].iov_base = cpu_physical_memory_map(pa, &len, is_write);
@@ -529,11 +529,11 @@ static void virtqueue_map_iovec(struct iovec *sg, hwaddr *addr,
         sg[i].iov_base = cpu_physical_memory_map(addr[i], &len, is_write);
         if (!sg[i].iov_base) {
             error_report("virtio: error trying to map MMIO memory");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         if (len != sg[i].iov_len) {
             error_report("virtio: unexpected memory split");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 }
@@ -592,7 +592,7 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz)
 
     if (vq->inuse >= vq->vring.num) {
         error_report("Virtqueue size exceeded");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     i = head = virtqueue_get_head(vq, vq->last_avail_idx++);
@@ -604,7 +604,7 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz)
     if (desc.flags & VRING_DESC_F_INDIRECT) {
         if (desc.len % sizeof(VRingDesc)) {
             error_report("Invalid size for indirect buffer table");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         /* loop over the indirect descriptor table */
@@ -622,7 +622,7 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz)
         } else {
             if (in_num) {
                 error_report("Incorrect order for descriptors");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             virtqueue_map_desc(&out_num, addr, iov,
                                VIRTQUEUE_MAX_SIZE, false, desc.addr, desc.len);
@@ -631,7 +631,7 @@ void *virtqueue_pop(VirtQueue *vq, size_t sz)
         /* If we've got too many, that implies a descriptor loop. */
         if ((in_num + out_num) > max) {
             error_report("Looped descriptor");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } while ((i = virtqueue_read_next_desc(vdev, &desc, desc_pa, max)) != max);
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 12/26] sparc: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (10 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 11/26] pci, virtio: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 13/26] sh4: " Laurent Vivier
                   ` (16 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Mark Cave-Ayland

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/sparc/leon3.c   | 12 ++++++------
 hw/sparc/sun4m.c   | 22 +++++++++++-----------
 hw/sparc64/sun4u.c |  8 ++++----
 3 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/hw/sparc/leon3.c b/hw/sparc/leon3.c
index 6e16478..9cc5b94 100644
--- a/hw/sparc/leon3.c
+++ b/hw/sparc/leon3.c
@@ -130,7 +130,7 @@ static void leon3_generic_hw_init(MachineState *machine)
     cpu = cpu_sparc_init(cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
@@ -152,7 +152,7 @@ static void leon3_generic_hw_init(MachineState *machine)
         fprintf(stderr,
                 "qemu: Too much memory for this machine: %d, maximum 1G\n",
                 (unsigned int)(ram_size / (1024 * 1024)));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     memory_region_allocate_system_memory(ram, NULL, "leon3.ram", ram_size);
@@ -180,18 +180,18 @@ static void leon3_generic_hw_init(MachineState *machine)
     if (bios_size > prom_size) {
         fprintf(stderr, "qemu: could not load prom '%s': file too big\n",
                 filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (bios_size > 0) {
         ret = load_image_targphys(filename, 0x00000000, bios_size);
         if (ret < 0 || ret > prom_size) {
             fprintf(stderr, "qemu: could not load prom '%s'\n", filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else if (kernel_filename == NULL && !qtest_enabled()) {
         fprintf(stderr, "Can't read bios image %s\n", filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     g_free(filename);
 
@@ -205,7 +205,7 @@ static void leon3_generic_hw_init(MachineState *machine)
         if (kernel_size < 0) {
             fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         if (bios_size <= 0) {
             /* If there is no bios/monitor, start the application.  */
diff --git a/hw/sparc/sun4m.c b/hw/sparc/sun4m.c
index 478fda8..d3d6bd5 100644
--- a/hw/sparc/sun4m.c
+++ b/hw/sparc/sun4m.c
@@ -295,7 +295,7 @@ static unsigned long sun4m_load_kernel(const char *kernel_filename,
         if (kernel_size < 0) {
             fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         /* load initrd */
@@ -307,7 +307,7 @@ static unsigned long sun4m_load_kernel(const char *kernel_filename,
             if (initrd_size < 0) {
                 fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
                         initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         }
         if (initrd_size > 0) {
@@ -737,7 +737,7 @@ static void prom_init(hwaddr addr, const char *bios_name)
     }
     if (ret < 0 || ret > PROM_SIZE_MAX) {
         fprintf(stderr, "qemu: could not load prom '%s'\n", bios_name);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -807,7 +807,7 @@ static void ram_init(hwaddr addr, ram_addr_t RAM_size,
                 "qemu: Too much memory for this machine: %d, maximum %d\n",
                 (unsigned int)(RAM_size / (1024 * 1024)),
                 (unsigned int)(max_mem / (1024 * 1024)));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     dev = qdev_create(NULL, "memory");
     s = SYS_BUS_DEVICE(dev);
@@ -850,7 +850,7 @@ static void cpu_devinit(const char *cpu_model, unsigned int id,
     cpu = cpu_sparc_init(cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "qemu: Unable to find Sparc CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
@@ -944,21 +944,21 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
 
     if (graphic_depth != 8 && graphic_depth != 24) {
         error_report("Unsupported depth: %d", graphic_depth);
-        exit (1);
+        exit(EXIT_FAILURE);
     }
     num_vsimms = 0;
     if (num_vsimms == 0) {
         if (vga_interface_type == VGA_CG3) {
             if (graphic_depth != 8) {
                 error_report("Unsupported depth: %d", graphic_depth);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
 
             if (!(graphic_width == 1024 && graphic_height == 768) &&
                 !(graphic_width == 1152 && graphic_height == 900)) {
                 error_report("Unsupported resolution: %d x %d", graphic_width,
                              graphic_height);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
 
             /* sbus irq 5 */
@@ -968,13 +968,13 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
             /* If no display specified, default to TCX */
             if (graphic_depth != 8 && graphic_depth != 24) {
                 error_report("Unsupported depth: %d", graphic_depth);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
 
             if (!(graphic_width == 1024 && graphic_height == 768)) {
                 error_report("Unsupported resolution: %d x %d",
                              graphic_width, graphic_height);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
 
             tcx_init(hwdef->tcx_base, slavio_irq[11], 0x00100000,
@@ -1025,7 +1025,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
 
     if (drive_get_max_bus(IF_SCSI) > 0) {
         fprintf(stderr, "qemu: too many SCSI bus\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     esp_init(hwdef->esp_base, 2,
diff --git a/hw/sparc64/sun4u.c b/hw/sparc64/sun4u.c
index 3165e18..5ed72e5 100644
--- a/hw/sparc64/sun4u.c
+++ b/hw/sparc64/sun4u.c
@@ -207,7 +207,7 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename,
         if (kernel_size < 0) {
             fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         /* load initrd above kernel */
         *initrd_size = 0;
@@ -220,7 +220,7 @@ static uint64_t sun4u_load_kernel(const char *kernel_filename,
             if ((int)*initrd_size < 0) {
                 fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
                         initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         }
         if (*initrd_size > 0) {
@@ -647,7 +647,7 @@ static void prom_init(hwaddr addr, const char *bios_name)
     }
     if (ret < 0 || ret > PROM_SIZE_MAX) {
         fprintf(stderr, "qemu: could not load prom '%s'\n", bios_name);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -760,7 +760,7 @@ static SPARCCPU *cpu_devinit(const char *cpu_model, const struct hwdef *hwdef)
     cpu = cpu_sparc_init(cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "Unable to find Sparc CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 13/26] sh4: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (11 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 12/26] sparc: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 14/26] x86: " Laurent Vivier
                   ` (15 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Aurelien Jarno

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Aurelien Jarno <aurelien@aurel32.net>
---
 hw/sh4/r2d.c  | 6 +++---
 hw/sh4/shix.c | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/hw/sh4/r2d.c b/hw/sh4/r2d.c
index db373c7..537ef52 100644
--- a/hw/sh4/r2d.c
+++ b/hw/sh4/r2d.c
@@ -249,7 +249,7 @@ static void r2d_init(MachineState *machine)
     cpu = cpu_sh4_init(cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
@@ -318,7 +318,7 @@ static void r2d_init(MachineState *machine)
                                           INITRD_LOAD_OFFSET - LINUX_LOAD_OFFSET);
         if (kernel_size < 0) {
           fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename);
-          exit(1);
+          exit(EXIT_FAILURE);
         }
 
         /* initialization which should be done by firmware */
@@ -338,7 +338,7 @@ static void r2d_init(MachineState *machine)
 
         if (initrd_size < 0) {
           fprintf(stderr, "qemu: could not load initrd '%s'\n", initrd_filename);
-          exit(1);
+          exit(EXIT_FAILURE);
         }
 
         /* initialization which should be done by firmware */
diff --git a/hw/sh4/shix.c b/hw/sh4/shix.c
index 14d4007..977b8e4 100644
--- a/hw/sh4/shix.c
+++ b/hw/sh4/shix.c
@@ -59,7 +59,7 @@ static void shix_init(MachineState *machine)
     cpu = cpu_sh4_init(cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Allocate memory space */
@@ -82,7 +82,7 @@ static void shix_init(MachineState *machine)
     ret = load_image_targphys(bios_name, 0, 0x4000);
     if (ret < 0 && !qtest_enabled()) {
         error_report("Could not load SHIX bios '%s'", bios_name);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Register peripherals */
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 14/26] x86: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (12 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 13/26] sh4: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 15/26] mips: " Laurent Vivier
                   ` (14 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Paolo Bonzini

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i386/intel_iommu.c     |  2 +-
 hw/i386/multiboot.c       | 10 +++++-----
 hw/i386/pc.c              | 24 ++++++++++++------------
 hw/i386/pc_piix.c         |  2 +-
 hw/i386/pc_sysfw.c        |  6 +++---
 hw/i386/x86-iommu.c       |  2 +-
 hw/intc/ioapic.c          |  2 +-
 hw/smbios/smbios.c        | 22 +++++++++++-----------
 hw/xenpv/xen_machine_pv.c |  8 ++++----
 target-i386/kvm.c         |  8 ++++----
 target-i386/machine.c     |  2 +-
 xen-common.c              |  4 ++--
 xen-hvm.c                 |  2 +-
 13 files changed, 47 insertions(+), 47 deletions(-)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index 28c31a2..a9a8df7 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -2473,7 +2473,7 @@ static void vtd_realize(DeviceState *dev, Error **errp)
         !kvm_irqchip_is_split()) {
         error_report("Intel Interrupt Remapping cannot work with "
                      "kernel-irqchip=on, please use 'split|off'.");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
diff --git a/hw/i386/multiboot.c b/hw/i386/multiboot.c
index 387caa6..e1b9897 100644
--- a/hw/i386/multiboot.c
+++ b/hw/i386/multiboot.c
@@ -194,7 +194,7 @@ int load_multiboot(FWCfgState *fw_cfg,
 
         if (((struct elf64_hdr*)header)->e_machine == EM_X86_64) {
             fprintf(stderr, "Cannot load x86-64 image, give a 32bit one.\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         kernel_size = load_elf(kernel_filename, NULL, NULL, &elf_entry,
@@ -202,7 +202,7 @@ int load_multiboot(FWCfgState *fw_cfg,
                                0, 0);
         if (kernel_size < 0) {
             fprintf(stderr, "Error while loading elf kernel\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         mh_load_addr = elf_low;
         mb_kernel_size = elf_high - elf_low;
@@ -211,7 +211,7 @@ int load_multiboot(FWCfgState *fw_cfg,
         mbs.mb_buf = g_malloc(mb_kernel_size);
         if (rom_copy(mbs.mb_buf, mh_load_addr, mb_kernel_size) != mb_kernel_size) {
             fprintf(stderr, "Error while fetching elf kernel from rom\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         mb_debug("qemu: loading multiboot-elf kernel (%#x bytes) with entry %#zx\n",
@@ -251,7 +251,7 @@ int load_multiboot(FWCfgState *fw_cfg,
         fseek(f, mb_kernel_text_offset, SEEK_SET);
         if (fread(mbs.mb_buf, 1, mb_load_size, f) != mb_load_size) {
             fprintf(stderr, "fread() failed\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         memset(mbs.mb_buf + mb_load_size, 0, mb_kernel_size - mb_load_size);
         fclose(f);
@@ -308,7 +308,7 @@ int load_multiboot(FWCfgState *fw_cfg,
             mb_mod_length = get_image_size(initrd_filename);
             if (mb_mod_length < 0) {
                 fprintf(stderr, "Failed to open file '%s'\n", initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
 
             mbs.mb_buf_size = TARGET_PAGE_ALIGN(mb_mod_length + mbs.mb_buf_size);
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 2d6d792..d6095ab 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -854,7 +854,7 @@ static void load_linux(PCMachineState *pcms,
         MIN(ARRAY_SIZE(header), kernel_size)) {
         fprintf(stderr, "qemu: could not load kernel '%s': %s\n",
                 kernel_filename, strerror(errno));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* kernel protocol version */
@@ -957,14 +957,14 @@ static void load_linux(PCMachineState *pcms,
     if (initrd_filename) {
         if (protocol < 0x200) {
             fprintf(stderr, "qemu: linux kernel too old to load a ram disk\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         initrd_size = get_image_size(initrd_filename);
         if (initrd_size < 0) {
             fprintf(stderr, "qemu: error reading initrd %s: %s\n",
                     initrd_filename, strerror(errno));
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         initrd_addr = (initrd_max-initrd_size) & ~4095;
@@ -988,7 +988,7 @@ static void load_linux(PCMachineState *pcms,
     setup_size = (setup_size+1)*512;
     if (setup_size > kernel_size) {
         fprintf(stderr, "qemu: invalid kernel header\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     kernel_size -= setup_size;
 
@@ -997,11 +997,11 @@ static void load_linux(PCMachineState *pcms,
     fseek(f, 0, SEEK_SET);
     if (fread(setup, 1, setup_size, f) != setup_size) {
         fprintf(stderr, "fread() failed\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (fread(kernel, 1, kernel_size, f) != kernel_size) {
         fprintf(stderr, "fread() failed\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     fclose(f);
 
@@ -1009,14 +1009,14 @@ static void load_linux(PCMachineState *pcms,
     if (dtb_filename) {
         if (protocol < 0x209) {
             fprintf(stderr, "qemu: Linux kernel too old to load a dtb\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         dtb_size = get_image_size(dtb_filename);
         if (dtb_size <= 0) {
             fprintf(stderr, "qemu: error reading dtb %s: %s\n",
                     dtb_filename, strerror(errno));
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         setup_data_offset = QEMU_ALIGN_UP(kernel_size, 16);
@@ -1171,13 +1171,13 @@ void pc_cpus_init(PCMachineState *pcms)
     model_pieces = g_strsplit(machine->cpu_model, ",", 2);
     if (!model_pieces[0]) {
         error_report("Invalid/empty CPU model name");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     oc = cpu_class_by_name(TYPE_X86_CPU, model_pieces[0]);
     if (oc == NULL) {
         error_report("Unable to find CPU definition: %s", model_pieces[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     typename = object_class_get_name(oc);
     cc = CPU_CLASS(oc);
@@ -1195,7 +1195,7 @@ void pc_cpus_init(PCMachineState *pcms)
     if (pcms->apic_id_limit > ACPI_CPU_HOTPLUG_ID_LIMIT) {
         error_report("max_cpus is too large. APIC ID of last CPU is %u",
                      pcms->apic_id_limit - 1);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     pcms->possible_cpus = g_malloc0(sizeof(CPUArchIdList) +
@@ -2096,7 +2096,7 @@ bool pc_machine_is_smm_enabled(PCMachineState *pcms)
 
     if (pcms->smm == ON_OFF_AUTO_ON) {
         error_report("System Management Mode not supported by this hypervisor.");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     return false;
 }
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index a54a468..925fb02 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -404,7 +404,7 @@ static void pc_xen_hvm_init(MachineState *machine)
 
     if (!xen_enabled()) {
         error_report("xenfv machine requires the xen accelerator");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     pc_xen_hvm_init_pci(machine);
diff --git a/hw/i386/pc_sysfw.c b/hw/i386/pc_sysfw.c
index f915ad0..17945a1 100644
--- a/hw/i386/pc_sysfw.c
+++ b/hw/i386/pc_sysfw.c
@@ -150,7 +150,7 @@ static void pc_system_flash_init(MemoryRegion *rom_memory)
             error_report("%s", fatal_errmsg);
             loc_pop(&loc);
             g_free(fatal_errmsg);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         phys_addr -= size;
@@ -204,7 +204,7 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
     if (ret != 0) {
     bios_error:
         fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     g_free(filename);
 
@@ -246,7 +246,7 @@ void pc_system_firmware_init(MemoryRegion *rom_memory, bool isapc_ram_fw)
         /* Older KVM cannot execute from device memory. So, flash memory
          * cannot be used unless the readonly memory kvm capability is present. */
         fprintf(stderr, "qemu: pflash with kvm requires KVM readonly memory support\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     pc_system_flash_init(rom_memory);
diff --git a/hw/i386/x86-iommu.c b/hw/i386/x86-iommu.c
index ce26b2a..8852613 100644
--- a/hw/i386/x86-iommu.c
+++ b/hw/i386/x86-iommu.c
@@ -60,7 +60,7 @@ static void x86_iommu_set_default(X86IOMMUState *x86_iommu)
     if (x86_iommu_default) {
         error_report("QEMU does not support multiple vIOMMUs "
                      "for x86 yet.");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     x86_iommu_default = x86_iommu;
diff --git a/hw/intc/ioapic.c b/hw/intc/ioapic.c
index 31791b0..873c0fd 100644
--- a/hw/intc/ioapic.c
+++ b/hw/intc/ioapic.c
@@ -402,7 +402,7 @@ static void ioapic_realize(DeviceState *dev, Error **errp)
     if (s->version != 0x11 && s->version != 0x20) {
         error_report("IOAPIC only supports version 0x11 or 0x20 "
                      "(default: 0x11).");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     memory_region_init_io(&s->io_memory, OBJECT(s), &ioapic_io_ops, s,
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index 74c7102..020d52b 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -332,7 +332,7 @@ static void smbios_validate_table(void)
     if (smbios_type4_count && smbios_type4_count != expect_t4_count) {
         error_report("Expected %d SMBIOS Type 4 tables, got %d instead",
                      expect_t4_count, smbios_type4_count);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -733,7 +733,7 @@ void smbios_set_defaults(const char *manufacturer, const char *product,
                           SMBIOS_MAX_TYPE+1, 2) < SMBIOS_MAX_TYPE+1) {
             error_report("can't process fields for smbios "
                          "types > 1 on machine versions < 2.1!");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else {
         g_free(smbios_entries);
@@ -898,7 +898,7 @@ void smbios_entry_add(QemuOpts *opts)
         size = get_image_size(val);
         if (size == -1 || size < sizeof(struct smbios_structure_header)) {
             error_report("Cannot read SMBIOS file %s", val);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         /*
@@ -912,13 +912,13 @@ void smbios_entry_add(QemuOpts *opts)
 
         if (load_image(val, (uint8_t *)header) != size) {
             error_report("Failed to load SMBIOS file %s", val);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         if (test_bit(header->type, have_fields_bitmap)) {
             error_report("can't load type %d struct, fields already specified!",
                          header->type);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         set_bit(header->type, have_binfile_bitmap);
 
@@ -964,12 +964,12 @@ void smbios_entry_add(QemuOpts *opts)
 
         if (type > SMBIOS_MAX_TYPE) {
             error_report("out of range!");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         if (test_bit(type, have_binfile_bitmap)) {
             error_report("can't add fields, binary file already loaded!");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         set_bit(type, have_fields_bitmap);
 
@@ -985,7 +985,7 @@ void smbios_entry_add(QemuOpts *opts)
             if (val) {
                 if (sscanf(val, "%hhu.%hhu", &type0.major, &type0.minor) != 2) {
                     error_report("Invalid release");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 type0.have_major_minor = true;
             }
@@ -1003,7 +1003,7 @@ void smbios_entry_add(QemuOpts *opts)
             if (val) {
                 if (qemu_uuid_parse(val, qemu_uuid) != 0) {
                     error_report("Invalid UUID");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 qemu_uuid_set = true;
             }
@@ -1047,10 +1047,10 @@ void smbios_entry_add(QemuOpts *opts)
         default:
             error_report("Don't know how to build fields for SMBIOS type %ld",
                          type);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
     error_report("Must specify type= or file=");
-    exit(1);
+    exit(EXIT_FAILURE);
 }
diff --git a/hw/xenpv/xen_machine_pv.c b/hw/xenpv/xen_machine_pv.c
index 79aef4e..233ec7c 100644
--- a/hw/xenpv/xen_machine_pv.c
+++ b/hw/xenpv/xen_machine_pv.c
@@ -37,7 +37,7 @@ static void xen_init_pv(MachineState *machine)
     /* Initialize backend core & drivers */
     if (xen_be_init() != 0) {
         fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     switch (xen_mode) {
@@ -52,18 +52,18 @@ static void xen_init_pv(MachineState *machine)
         if (xen_domain_build_pv(kernel_filename, initrd_filename,
                                 kernel_cmdline) < 0) {
             fprintf(stderr, "xen pv domain creation failed\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         break;
     }
 #endif
     case XEN_EMULATE:
         fprintf(stderr, "xen emulation not implemented (yet)\n");
-        exit(1);
+        exit(EXIT_FAILURE);
         break;
     default:
         fprintf(stderr, "unhandled xen_mode %d\n", xen_mode);
-        exit(1);
+        exit(EXIT_FAILURE);
         break;
     }
 
diff --git a/target-i386/kvm.c b/target-i386/kvm.c
index f1ad805..b5c2e08 100644
--- a/target-i386/kvm.c
+++ b/target-i386/kvm.c
@@ -193,7 +193,7 @@ static struct kvm_cpuid2 *try_get_cpuid(KVMState *s, int max)
         } else {
             fprintf(stderr, "KVM_GET_SUPPORTED_CPUID failed: %s\n",
                     strerror(-r));
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
     return cpuid;
@@ -426,7 +426,7 @@ static void kvm_mce_inject(X86CPU *cpu, hwaddr paddr, int code)
 static void hardware_memory_error(void)
 {
     fprintf(stderr, "Hardware memory error!\n");
-    exit(1);
+    exit(EXIT_FAILURE);
 }
 
 int kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr)
@@ -3228,7 +3228,7 @@ void kvm_arch_init_irq_routing(KVMState *s)
         for (i = 0; i < IOAPIC_NUM_PINS; i++) {
             if (kvm_irqchip_add_msi_route(s, 0, NULL) < 0) {
                 error_report("Could not enable split IRQ mode.");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         }
     }
@@ -3242,7 +3242,7 @@ int kvm_arch_irqchip_create(MachineState *ms, KVMState *s)
         if (ret) {
             error_report("Could not enable split irqchip mode: %s",
                          strerror(-ret));
-            exit(1);
+            exit(EXIT_FAILURE);
         } else {
             DPRINTF("Enabled KVM_CAP_SPLIT_IRQCHIP\n");
             kvm_split_irqchip = true;
diff --git a/target-i386/machine.c b/target-i386/machine.c
index 71c0e4d..56f31ae 100644
--- a/target-i386/machine.c
+++ b/target-i386/machine.c
@@ -142,7 +142,7 @@ static const VMStateDescription vmstate_mtrr_var = {
 static void put_fpreg_error(QEMUFile *f, void *opaque, size_t size)
 {
     fprintf(stderr, "call put_fpreg() with invalid arguments\n");
-    exit(0);
+    exit(EXIT_SUCCESS);
 }
 
 /* XXX: add that in a FPU generic layer */
diff --git a/xen-common.c b/xen-common.c
index e641ad1..4b1c992 100644
--- a/xen-common.c
+++ b/xen-common.c
@@ -92,13 +92,13 @@ static void xenstore_record_dm_state(struct xs_handle *xs, const char *state)
 
     if (xs == NULL) {
         fprintf(stderr, "xenstore connection not initialized\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     snprintf(path, sizeof (path), "device-model/%u/state", xen_domid);
     if (!xs_write(xs, XBT_NULL, path, state, strlen(state))) {
         fprintf(stderr, "error recording dm state\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
diff --git a/xen-hvm.c b/xen-hvm.c
index 2f348ed..328f721 100644
--- a/xen-hvm.c
+++ b/xen-hvm.c
@@ -1320,7 +1320,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
 
 err:
     error_report("xen hardware virtual machine initialisation failed");
-    exit(1);
+    exit(EXIT_FAILURE);
 }
 
 void destroy_hvm_domain(bool reboot)
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 15/26] mips: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (13 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 14/26] x86: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 16/26] s390: " Laurent Vivier
                   ` (13 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Leon Alrae

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Leon Alrae <leon.alrae@imgtec.com>
---
 hw/mips/mips_fulong2e.c | 12 ++++++------
 hw/mips/mips_jazz.c     | 10 +++++-----
 hw/mips/mips_malta.c    | 20 ++++++++++----------
 hw/mips/mips_mipssim.c  | 10 +++++-----
 hw/mips/mips_r4k.c      | 10 +++++-----
 hw/pci-host/bonito.c    |  2 +-
 6 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c
index 889cdc7..24adc46 100644
--- a/hw/mips/mips_fulong2e.c
+++ b/hw/mips/mips_fulong2e.c
@@ -121,7 +121,7 @@ static int64_t load_kernel (CPUMIPSState *env)
                  (uint64_t *)&kernel_high, 0, EM_MIPS, 1, 0) < 0) {
         fprintf(stderr, "qemu: could not load kernel '%s'\n",
                 loaderparams.kernel_filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* load initrd */
@@ -135,7 +135,7 @@ static int64_t load_kernel (CPUMIPSState *env)
                 fprintf(stderr,
                         "qemu: memory too small for initial ram disk '%s'\n",
                         loaderparams.initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             initrd_size = load_image_targphys(loaderparams.initrd_filename,
                                      initrd_offset, ram_size - initrd_offset);
@@ -143,7 +143,7 @@ static int64_t load_kernel (CPUMIPSState *env)
         if (initrd_size == (target_ulong) -1) {
             fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
                     loaderparams.initrd_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -281,7 +281,7 @@ static void mips_fulong2e_init(MachineState *machine)
     cpu = cpu_mips_init(cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
@@ -329,7 +329,7 @@ static void mips_fulong2e_init(MachineState *machine)
         if ((bios_size < 0 || bios_size > BIOS_SIZE) &&
             !kernel_filename && !qtest_enabled()) {
             error_report("Could not load MIPS bios '%s'", bios_name);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -346,7 +346,7 @@ static void mips_fulong2e_init(MachineState *machine)
     isa_bus = vt82c686b_init(pci_bus, PCI_DEVFN(FULONG2E_VIA_SLOT, 0));
     if (!isa_bus) {
         fprintf(stderr, "vt82c686b_init error\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Interrupt controller */
diff --git a/hw/mips/mips_jazz.c b/hw/mips/mips_jazz.c
index 73f6c9f..6c4b423 100644
--- a/hw/mips/mips_jazz.c
+++ b/hw/mips/mips_jazz.c
@@ -154,7 +154,7 @@ static void mips_jazz_init(MachineState *machine,
     cpu = cpu_mips_init(cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
     qemu_register_reset(main_cpu_reset, cpu);
@@ -197,7 +197,7 @@ static void mips_jazz_init(MachineState *machine,
     }
     if ((bios_size < 0 || bios_size > MAGNUM_BIOS_SIZE) && !qtest_enabled()) {
         error_report("Could not load MIPS bios '%s'", bios_name);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Init CPU internal devices */
@@ -278,10 +278,10 @@ static void mips_jazz_init(MachineState *machine,
             break;
         } else if (is_help_option(nd->model)) {
             fprintf(stderr, "qemu: Supported NICs: dp83932\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         } else {
             fprintf(stderr, "qemu: Unsupported NIC: %s\n", nd->model);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -293,7 +293,7 @@ static void mips_jazz_init(MachineState *machine,
     /* Floppy */
     if (drive_get_max_bus(IF_FLOPPY) >= MAX_FD) {
         fprintf(stderr, "qemu: too many floppy drives\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     for (n = 0; n < MAX_FD; n++) {
         fds[n] = drive_get(IF_FLOPPY, 0, n);
diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c
index e90857e..c7baa51 100644
--- a/hw/mips/mips_malta.c
+++ b/hw/mips/mips_malta.c
@@ -803,7 +803,7 @@ static int64_t load_kernel (void)
                  big_endian, EM_MIPS, 1, 0) < 0) {
         fprintf(stderr, "qemu: could not load kernel '%s'\n",
                 loaderparams.kernel_filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Sanity check where the kernel has been linked */
@@ -811,7 +811,7 @@ static int64_t load_kernel (void)
         if (kernel_entry & 0x80000000ll) {
             error_report("KVM guest kernels must be linked in useg. "
                          "Did you forget to enable CONFIG_KVM_GUEST?");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         xlate_to_kseg0 = cpu_mips_kvm_um_phys_to_kseg0;
@@ -819,7 +819,7 @@ static int64_t load_kernel (void)
         if (!(kernel_entry & 0x80000000ll)) {
             error_report("KVM guest kernels aren't supported with TCG. "
                          "Did you unintentionally enable CONFIG_KVM_GUEST?");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         xlate_to_kseg0 = cpu_mips_phys_to_kseg0;
@@ -836,7 +836,7 @@ static int64_t load_kernel (void)
                 fprintf(stderr,
                         "qemu: memory too small for initial ram disk '%s'\n",
                         loaderparams.initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             initrd_size = load_image_targphys(loaderparams.initrd_filename,
                                               initrd_offset,
@@ -845,7 +845,7 @@ static int64_t load_kernel (void)
         if (initrd_size == (target_ulong) -1) {
             fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
                     loaderparams.initrd_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -921,7 +921,7 @@ static void create_cpu_without_cps(const char *cpu_model,
         cpu = cpu_mips_init(cpu_model);
         if (cpu == NULL) {
             fprintf(stderr, "Unable to find CPU definition\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         /* Init internal devices */
@@ -950,7 +950,7 @@ static void create_cps(MaltaState *s, const char *cpu_model,
     object_property_set_bool(OBJECT(s->cps), true, "realized", &err);
     if (err != NULL) {
         error_report("%s", error_get_pretty(err));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     sysbus_mmio_map_overlap(SYS_BUS_DEVICE(s->cps), 0, 0, 1);
@@ -1037,7 +1037,7 @@ void mips_malta_init(MachineState *machine)
         fprintf(stderr,
                 "qemu: Too much memory for this machine: %d MB, maximum 2048 MB\n",
                 ((unsigned int)ram_size / (1 << 20)));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* register RAM at high address where it is undisturbed by IO */
@@ -1121,7 +1121,7 @@ void mips_malta_init(MachineState *machine)
         if (kvm_enabled()) {
             error_report("KVM enabled but no -kernel argument was specified. "
                          "Booting from flash is not supported with KVM.");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         /* Load firmware from flash. */
         if (!dinfo) {
@@ -1141,7 +1141,7 @@ void mips_malta_init(MachineState *machine)
                 !kernel_filename && !qtest_enabled()) {
                 error_report("Could not load MIPS bios '%s', and no "
                              "-kernel argument was specified", bios_name);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         }
         /* In little endian mode the 32bit words in the bios are swapped,
diff --git a/hw/mips/mips_mipssim.c b/hw/mips/mips_mipssim.c
index 1b91195..d9dc5fa 100644
--- a/hw/mips/mips_mipssim.c
+++ b/hw/mips/mips_mipssim.c
@@ -80,7 +80,7 @@ static int64_t load_kernel(void)
     } else {
         fprintf(stderr, "qemu: could not load kernel '%s'\n",
                 loaderparams.kernel_filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* load initrd */
@@ -94,7 +94,7 @@ static int64_t load_kernel(void)
                 fprintf(stderr,
                         "qemu: memory too small for initial ram disk '%s'\n",
                         loaderparams.initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             initrd_size = load_image_targphys(loaderparams.initrd_filename,
                 initrd_offset, loaderparams.ram_size - initrd_offset);
@@ -102,7 +102,7 @@ static int64_t load_kernel(void)
         if (initrd_size == (target_ulong) -1) {
             fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
                     loaderparams.initrd_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
     return entry;
@@ -165,7 +165,7 @@ mips_mipssim_init(MachineState *machine)
     cpu = cpu_mips_init(cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
@@ -201,7 +201,7 @@ mips_mipssim_init(MachineState *machine)
         /* Bail out if we have neither a kernel image nor boot vector code. */
         error_report("Could not load MIPS bios '%s', and no "
                      "-kernel argument was specified", bios_name);
-        exit(1);
+        exit(EXIT_FAILURE);
     } else {
         /* We have a boot vector start address. */
         env->active_tc.PC = (target_long)(int32_t)0xbfc00000;
diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
index 16a59c7..fd5808e 100644
--- a/hw/mips/mips_r4k.c
+++ b/hw/mips/mips_r4k.c
@@ -98,7 +98,7 @@ static int64_t load_kernel(void)
     } else {
         fprintf(stderr, "qemu: could not load kernel '%s'\n",
                 loaderparams.kernel_filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* load initrd */
@@ -112,7 +112,7 @@ static int64_t load_kernel(void)
                 fprintf(stderr,
                         "qemu: memory too small for initial ram disk '%s'\n",
                         loaderparams.initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             initrd_size = load_image_targphys(loaderparams.initrd_filename,
                                               initrd_offset,
@@ -121,7 +121,7 @@ static int64_t load_kernel(void)
         if (initrd_size == (target_ulong) -1) {
             fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
                     loaderparams.initrd_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -194,7 +194,7 @@ void mips_r4k_init(MachineState *machine)
     cpu = cpu_mips_init(cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
@@ -208,7 +208,7 @@ void mips_r4k_init(MachineState *machine)
         fprintf(stderr,
                 "qemu: Too much memory for this machine: %d MB, maximum 256 MB\n",
                 ((unsigned int)ram_size / (1 << 20)));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     memory_region_allocate_system_memory(ram, NULL, "mips_r4k.ram", ram_size);
 
diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
index 1999ece..19ae58f 100644
--- a/hw/pci-host/bonito.c
+++ b/hw/pci-host/bonito.c
@@ -451,7 +451,7 @@ static uint32_t bonito_sbridge_pciaddr(void *opaque, hwaddr addr)
     if (idsel == 0) {
         fprintf(stderr, "error in bonito pci config address " TARGET_FMT_plx
             ",pcimap_cfg=%x\n", addr, s->regs[BONITO_PCIMAP_CFG]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     pciaddr = PCI_ADDR(pci_bus_num(phb->bus), devno, funno, regno);
     DPRINTF("cfgaddr %x pciaddr %x busno %x devno %d funno %d regno %d\n",
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 16/26] s390: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (14 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 15/26] mips: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-19 11:07   ` Cornelia Huck
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 17/26] tcg: " Laurent Vivier
                   ` (12 subsequent siblings)
  28 siblings, 1 reply; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Cornelia Huck

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Cornelia Huck <cornelia.huck@de.ibm.com>
---
 target-s390x/cpu.c        |  2 +-
 target-s390x/kvm.c        | 18 +++++++++---------
 target-s390x/mmu_helper.c |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
index 2f3c8e2..d4ca6af 100644
--- a/target-s390x/cpu.c
+++ b/target-s390x/cpu.c
@@ -385,7 +385,7 @@ unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu)
     default:
         error_report("Requested CPU state is not a valid S390 CPU state: %u",
                      cpu_state);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (kvm_enabled() && cpu->env.cpu_state != cpu_state) {
         kvm_s390_set_cpu_state(cpu, cpu_state);
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index dfaf1ca..2b1b908 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -920,13 +920,13 @@ static void inject_vcpu_irq_legacy(CPUState *cs, struct kvm_s390_irq *irq)
     r = s390_kvm_irq_to_interrupt(irq, &kvmint);
     if (r < 0) {
         fprintf(stderr, "%s called with bogus interrupt\n", __func__);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     r = kvm_vcpu_ioctl(cs, KVM_S390_INTERRUPT, &kvmint);
     if (r < 0) {
         fprintf(stderr, "KVM failed to inject interrupt\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -941,7 +941,7 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq)
             return;
         }
         error_report("KVM failed to inject interrupt %llx", irq->type);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     inject_vcpu_irq_legacy(cs, irq);
@@ -955,13 +955,13 @@ static void __kvm_s390_floating_interrupt(struct kvm_s390_irq *irq)
     r = s390_kvm_irq_to_interrupt(irq, &kvmint);
     if (r < 0) {
         fprintf(stderr, "%s called with bogus interrupt\n", __func__);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     r = kvm_vm_ioctl(kvm_state, KVM_S390_INTERRUPT, &kvmint);
     if (r < 0) {
         fprintf(stderr, "KVM failed to inject interrupt\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -1905,15 +1905,15 @@ static int handle_intercept(S390CPU *cpu)
             break;
         case ICPT_SOFT_INTERCEPT:
             fprintf(stderr, "KVM unimplemented icpt SOFT\n");
-            exit(1);
+            exit(EXIT_FAILURE);
             break;
         case ICPT_IO:
             fprintf(stderr, "KVM unimplemented icpt IO\n");
-            exit(1);
+            exit(EXIT_FAILURE);
             break;
         default:
             fprintf(stderr, "Unknown intercept code: %d\n", icpt_code);
-            exit(1);
+            exit(EXIT_FAILURE);
             break;
     }
 
@@ -2222,7 +2222,7 @@ int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state)
     default:
         error_report("Requested CPU state is not a valid S390 CPU state: %u",
                      cpu_state);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MP_STATE, &mp_state);
diff --git a/target-s390x/mmu_helper.c b/target-s390x/mmu_helper.c
index b11a027..dc9960a 100644
--- a/target-s390x/mmu_helper.c
+++ b/target-s390x/mmu_helper.c
@@ -414,7 +414,7 @@ static bool lowprot_enabled(const CPUS390XState *env)
     default:
         /* We don't support access register mode */
         error_report("unsupported addressing mode");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 17/26] tcg: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (15 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 16/26] s390: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 18/26] posix: " Laurent Vivier
                   ` (11 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Richard Henderson

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Richard Henderson <rth@twiddle.net>
---
 cpus.c          | 16 ++++++++--------
 cputlb.c        |  2 +-
 exec.c          |  2 +-
 tcg/tcg.c       |  2 +-
 translate-all.c |  2 +-
 5 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/cpus.c b/cpus.c
index e39ccb7..16898d3 100644
--- a/cpus.c
+++ b/cpus.c
@@ -159,7 +159,7 @@ int64_t cpu_get_icount_raw(void)
     if (cpu) {
         if (!cpu->can_do_io) {
             fprintf(stderr, "Bad icount read\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         icount -= (cpu->icount_decr.u16.low + cpu->icount_extra);
     }
@@ -829,7 +829,7 @@ static void qemu_kvm_eat_signals(CPUState *cpu)
         r = sigtimedwait(&waitset, &siginfo, &ts);
         if (r == -1 && !(errno == EAGAIN || errno == EINTR)) {
             perror("sigtimedwait");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         switch (r) {
@@ -845,7 +845,7 @@ static void qemu_kvm_eat_signals(CPUState *cpu)
         r = sigpending(&chkset);
         if (r == -1) {
             perror("sigpending");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } while (sigismember(&chkset, SIG_IPI) || sigismember(&chkset, SIGBUS));
 }
@@ -882,7 +882,7 @@ static void qemu_kvm_init_cpu_signals(CPUState *cpu)
     r = kvm_set_signal_mask(cpu, &set);
     if (r) {
         fprintf(stderr, "kvm_set_signal_mask: %s\n", strerror(-r));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
@@ -1070,7 +1070,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg)
     r = kvm_init_vcpu(cpu);
     if (r < 0) {
         fprintf(stderr, "kvm_init_vcpu failed: %s\n", strerror(-r));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     qemu_kvm_init_cpu_signals(cpu);
@@ -1100,7 +1100,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg)
 {
 #ifdef _WIN32
     fprintf(stderr, "qtest is not supported under Windows\n");
-    exit(1);
+    exit(EXIT_FAILURE);
 #else
     CPUState *cpu = arg;
     sigset_t waitset;
@@ -1130,7 +1130,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg)
         } while (r == -1 && (errno == EAGAIN || errno == EINTR));
         if (r == -1) {
             perror("sigwait");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         qemu_mutex_lock_iothread();
         current_cpu = cpu;
@@ -1213,7 +1213,7 @@ static void qemu_cpu_kick_thread(CPUState *cpu)
     err = pthread_kill(cpu->thread->thread, SIG_IPI);
     if (err) {
         fprintf(stderr, "qemu:%s: %s", __func__, strerror(err));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 #else /* _WIN32 */
     abort();
diff --git a/cputlb.c b/cputlb.c
index d068ee5..39cc513 100644
--- a/cputlb.c
+++ b/cputlb.c
@@ -491,7 +491,7 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr)
             cc->do_unassigned_access(cpu, addr, false, true, 0, 4);
         } else {
             report_bad_exec(cpu, addr);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
     p = (void *)((uintptr_t)addr + env1->tlb_table[mmu_idx][page_index].addend);
diff --git a/exec.c b/exec.c
index c81d5ab..f62a54c 100644
--- a/exec.c
+++ b/exec.c
@@ -1801,7 +1801,7 @@ void qemu_ram_remap(ram_addr_t addr, ram_addr_t length)
                     fprintf(stderr, "Could not remap addr: "
                             RAM_ADDR_FMT "@" RAM_ADDR_FMT "\n",
                             length, addr);
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 memory_try_enable_merging(vaddr, length);
                 qemu_ram_setup_dump(vaddr, length);
diff --git a/tcg/tcg.c b/tcg/tcg.c
index c450c62..0094fa5 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -1269,7 +1269,7 @@ void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs)
                         if (target_parse_constraint(&def->args_ct[i], &ct_str) < 0) {
                             fprintf(stderr, "Invalid constraint '%s' for arg %d of operation '%s'\n",
                                     ct_str, i, def->name);
-                            exit(1);
+                            exit(EXIT_FAILURE);
                         }
                     }
                 }
diff --git a/translate-all.c b/translate-all.c
index b6663dc..5f1be0f 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -720,7 +720,7 @@ static inline void code_gen_alloc(size_t tb_size)
     tcg_ctx.code_gen_buffer = alloc_code_gen_buffer();
     if (tcg_ctx.code_gen_buffer == NULL) {
         fprintf(stderr, "Could not allocate dynamic translator buffer\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Estimate a good size for the number of TBs we can support.  We
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 18/26] posix: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (16 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 17/26] tcg: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 19/26] alpha: " Laurent Vivier
                   ` (10 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 os-posix.c         | 34 +++++++++++++++++-----------------
 util/oslib-posix.c |  2 +-
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/os-posix.c b/os-posix.c
index c6ddb7d..c4137ba 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -121,11 +121,11 @@ void os_set_proc_name(const char *s)
        This simple way is enough for `top'. */
     if (prctl(PR_SET_NAME, name)) {
         perror("unable to change process name");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 #else
     fprintf(stderr, "Change of process name not supported by your OS\n");
-    exit(1);
+    exit(EXIT_FAILURE);
 #endif
 }
 
@@ -141,14 +141,14 @@ void os_parse_cmd_args(int index, const char *optarg)
         error_report("The -smb option is deprecated. "
                      "Please use '-netdev user,smb=...' instead.");
         if (net_slirp_smb(optarg) < 0)
-            exit(1);
+            exit(EXIT_FAILURE);
         break;
 #endif
     case QEMU_OPTION_runas:
         user_pwd = getpwnam(optarg);
         if (!user_pwd) {
             fprintf(stderr, "User \"%s\" doesn't exist\n", optarg);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         break;
     case QEMU_OPTION_chroot:
@@ -170,20 +170,20 @@ static void change_process_uid(void)
     if (user_pwd) {
         if (setgid(user_pwd->pw_gid) < 0) {
             fprintf(stderr, "Failed to setgid(%d)\n", user_pwd->pw_gid);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         if (initgroups(user_pwd->pw_name, user_pwd->pw_gid) < 0) {
             fprintf(stderr, "Failed to initgroups(\"%s\", %d)\n",
                     user_pwd->pw_name, user_pwd->pw_gid);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         if (setuid(user_pwd->pw_uid) < 0) {
             fprintf(stderr, "Failed to setuid(%d)\n", user_pwd->pw_uid);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         if (setuid(0) != -1) {
             fprintf(stderr, "Dropping privileges failed\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 }
@@ -193,11 +193,11 @@ static void change_root(void)
     if (chroot_dir) {
         if (chroot(chroot_dir) < 0) {
             fprintf(stderr, "chroot failed\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         if (chdir("/")) {
             perror("not able to chdir to /");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -210,7 +210,7 @@ void os_daemonize(void)
         int fds[2];
 
         if (pipe(fds) == -1) {
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         pid = fork();
@@ -229,7 +229,7 @@ void os_daemonize(void)
             exit(len == 1 && status == 0 ? 0 : 1);
 
         } else if (pid < 0) {
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         close(fds[0]);
@@ -240,9 +240,9 @@ void os_daemonize(void)
 
         pid = fork();
         if (pid > 0) {
-            exit(0);
+            exit(EXIT_SUCCESS);
         } else if (pid < 0) {
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         umask(027);
 
@@ -260,11 +260,11 @@ void os_setup_post(void)
     if (daemonize) {
         if (chdir("/")) {
             perror("not able to chdir to /");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         TFR(fd = qemu_open("/dev/null", O_RDWR));
         if (fd == -1) {
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -288,7 +288,7 @@ void os_setup_post(void)
             len = write(daemon_pipe, &status, 1);
         } while (len < 0 && errno == EINTR);
         if (len != 1) {
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 }
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index f2d4e9e..026fd1c 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -358,7 +358,7 @@ void os_mem_prealloc(int fd, char *area, size_t memory, Error **errp)
     if (ret) {
         /* Terminate QEMU since it can't recover from error */
         perror("os_mem_prealloc: failed to reinstall signal handler");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     pthread_sigmask(SIG_SETMASK, &oldset, NULL);
 }
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 19/26] alpha: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (17 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 18/26] posix: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 20/26] common: " Laurent Vivier
                   ` (9 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Richard Henderson

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Richard Henderson <rth@twiddle.net>
---
 hw/alpha/dp264.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
index f1267b5..d533d2f 100644
--- a/hw/alpha/dp264.c
+++ b/hw/alpha/dp264.c
@@ -110,14 +110,14 @@ static void clipper_init(MachineState *machine)
                                 bios_name ? bios_name : "palcode-clipper");
     if (palcode_filename == NULL) {
         error_report("no palcode provided");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     size = load_elf(palcode_filename, cpu_alpha_superpage_to_phys,
                     NULL, &palcode_entry, &palcode_low, &palcode_high,
                     0, EM_ALPHA, 0, 0);
     if (size < 0) {
         error_report("could not load palcode '%s'", palcode_filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     g_free(palcode_filename);
 
@@ -137,7 +137,7 @@ static void clipper_init(MachineState *machine)
                         0, EM_ALPHA, 0, 0);
         if (size < 0) {
             error_report("could not load kernel '%s'", kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         cpus[0]->env.trap_arg1 = kernel_entry;
@@ -155,7 +155,7 @@ static void clipper_init(MachineState *machine)
             if (initrd_size < 0) {
                 error_report("could not load initial ram disk '%s'",
                              initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
 
             /* Put the initrd image as high in memory as possible.  */
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 20/26] common: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (18 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 19/26] alpha: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 21/26] misc machine: " Laurent Vivier
                   ` (8 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Paolo Bonzini

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
---
 accel.c                       |   2 +-
 arch_init.c                   |   6 +-
 bootdevice.c                  |   2 +-
 contrib/ivshmem-server/main.c |  12 +-
 gdbstub.c                     |   2 +-
 hw/watchdog/watchdog.c        |   2 +-
 kvm-all.c                     |   8 +-
 qemu-char.c                   |   6 +-
 qemu-nbd.c                    |   6 +-
 util/qemu-timer-common.c      |   2 +-
 vl.c                          | 270 +++++++++++++++++++++---------------------
 11 files changed, 159 insertions(+), 159 deletions(-)

diff --git a/accel.c b/accel.c
index 403eb5e..c1b7fcd 100644
--- a/accel.c
+++ b/accel.c
@@ -122,7 +122,7 @@ void configure_accelerator(MachineState *ms)
         if (!init_failed) {
             fprintf(stderr, "No accelerator found!\n");
         }
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (init_failed) {
diff --git a/arch_init.c b/arch_init.c
index fa05973..c4273fa 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -221,13 +221,13 @@ void audio_init(void)
             if (c->isa) {
                 if (!isa_bus) {
                     error_report("ISA bus not available for %s", c->name);
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 c->init.init_isa(isa_bus);
             } else {
                 if (!pci_bus) {
                     error_report("PCI bus not available for %s", c->name);
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 c->init.init_pci(pci_bus);
             }
@@ -262,7 +262,7 @@ void do_acpitable_option(const QemuOpts *opts)
     acpi_table_add(opts, &err);
     if (err) {
         error_reportf_err(err, "Wrong acpi table provided: ");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 #endif
 }
diff --git a/bootdevice.c b/bootdevice.c
index 33e3029..fdd199c 100644
--- a/bootdevice.c
+++ b/bootdevice.c
@@ -173,7 +173,7 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
     QTAILQ_FOREACH(i, &fw_boot_order, link) {
         if (i->bootindex == bootindex) {
             error_report("Two devices with same boot index %d", bootindex);
-            exit(1);
+            exit(EXIT_FAILURE);
         } else if (i->bootindex < bootindex) {
             continue;
         }
diff --git a/contrib/ivshmem-server/main.c b/contrib/ivshmem-server/main.c
index 45776d8..63d6d91 100644
--- a/contrib/ivshmem-server/main.c
+++ b/contrib/ivshmem-server/main.c
@@ -77,7 +77,7 @@ ivshmem_server_parse_args(IvshmemServerArgs *args, int argc, char *argv[])
         switch (c) {
         case 'h': /* help */
             ivshmem_server_usage(argv[0]);
-            exit(0);
+            exit(EXIT_SUCCESS);
             break;
 
         case 'v': /* verbose */
@@ -107,7 +107,7 @@ ivshmem_server_parse_args(IvshmemServerArgs *args, int argc, char *argv[])
             if (err) {
                 error_report_err(err);
                 ivshmem_server_help(argv[0]);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             break;
 
@@ -115,14 +115,14 @@ ivshmem_server_parse_args(IvshmemServerArgs *args, int argc, char *argv[])
             if (parse_uint_full(optarg, &v, 0) < 0) {
                 fprintf(stderr, "cannot parse n_vectors\n");
                 ivshmem_server_help(argv[0]);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             args->n_vectors = v;
             break;
 
         default:
             ivshmem_server_usage(argv[0]);
-            exit(1);
+            exit(EXIT_FAILURE);
             break;
         }
     }
@@ -131,13 +131,13 @@ ivshmem_server_parse_args(IvshmemServerArgs *args, int argc, char *argv[])
         fprintf(stderr, "too many requested vectors (max is %d)\n",
                 IVSHMEM_SERVER_MAX_VECTORS);
         ivshmem_server_help(argv[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (args->verbose == 1 && args->foreground == 0) {
         fprintf(stderr, "cannot use verbose in daemon mode\n");
         ivshmem_server_help(argv[0]);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
diff --git a/gdbstub.c b/gdbstub.c
index ecea8c4..fd7405c 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -891,7 +891,7 @@ static int gdb_handle_packet(GDBState *s, const char *line_buf)
     case 'k':
         /* Kill the target */
         fprintf(stderr, "\nQEMU: Terminated via GDBstub\n");
-        exit(0);
+        exit(EXIT_SUCCESS);
     case 'D':
         /* Detach packet */
         gdb_breakpoint_remove_all();
diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c
index 2aeaf1f..97e0772 100644
--- a/hw/watchdog/watchdog.c
+++ b/hw/watchdog/watchdog.c
@@ -120,7 +120,7 @@ void watchdog_perform_action(void)
 
     case WDT_POWEROFF:          /* same as 'quit' command in monitor */
         qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_POWEROFF, &error_abort);
-        exit(0);
+        exit(EXIT_SUCCESS);
 
     case WDT_PAUSE:             /* same as 'stop' command in monitor */
         /* In a timer callback, when vm_stop calls qemu_clock_enable
diff --git a/kvm-all.c b/kvm-all.c
index 8a4382e..ad9aa8e 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -1488,7 +1488,7 @@ static void kvm_irqchip_create(MachineState *machine, KVMState *s)
         ret = kvm_vm_enable_cap(s, KVM_CAP_S390_IRQCHIP, 0);
         if (ret < 0) {
             fprintf(stderr, "Enable kernel irqchip failed: %s\n", strerror(-ret));
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else {
         return;
@@ -1500,14 +1500,14 @@ static void kvm_irqchip_create(MachineState *machine, KVMState *s)
     if (ret == 0) {
         if (machine_kernel_irqchip_split(machine)) {
             perror("Split IRQ chip mode not supported.");
-            exit(1);
+            exit(EXIT_FAILURE);
         } else {
             ret = kvm_vm_ioctl(s, KVM_CREATE_IRQCHIP);
         }
     }
     if (ret < 0) {
         fprintf(stderr, "Create kernel irqchip failed: %s\n", strerror(-ret));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     kvm_kernel_irqchip = true;
@@ -1632,7 +1632,7 @@ static int kvm_init(MachineState *ms)
                 fprintf(stderr, "Number of %s cpus requested (%d) exceeds "
                         "the maximum cpus supported by KVM (%d)\n",
                         nc->name, nc->num, hard_vcpus_limit);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
         }
         nc++;
diff --git a/qemu-char.c b/qemu-char.c
index 8826419..deab972 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -408,7 +408,7 @@ int qemu_chr_fe_get_msgfd(CharDriverState *s)
     if (s->replay) {
         fprintf(stderr,
                 "Replay: get msgfd is not supported for serial devices yet\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     return res;
 }
@@ -633,7 +633,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch)
             {
                  const char *term =  "QEMU: Terminated\n\r";
                  qemu_chr_fe_write_all(chr, (uint8_t *)term, strlen(term));
-                 exit(0);
+                 exit(EXIT_SUCCESS);
                  break;
             }
         case 's':
@@ -4083,7 +4083,7 @@ void qemu_chr_fe_claim_no_fail(CharDriverState *s)
     if (qemu_chr_fe_claim(s) != 0) {
         fprintf(stderr, "%s: error chardev \"%s\" already used\n",
                 __func__, s->label);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 99297a5..f30e3d4 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -687,11 +687,11 @@ int main(int argc, char **argv)
             break;
         case 'V':
             version(argv[0]);
-            exit(0);
+            exit(EXIT_SUCCESS);
             break;
         case 'h':
             usage(argv[0]);
-            exit(0);
+            exit(EXIT_SUCCESS);
             break;
         case '?':
             error_report("Try `%s --help' for more information.", argv[0]);
@@ -730,7 +730,7 @@ int main(int argc, char **argv)
     }
 
     if (!trace_init_backends()) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     trace_init_file(trace_file);
     qemu_set_log(LOG_TRACE);
diff --git a/util/qemu-timer-common.c b/util/qemu-timer-common.c
index 06d084d..5d6df5d 100644
--- a/util/qemu-timer-common.c
+++ b/util/qemu-timer-common.c
@@ -38,7 +38,7 @@ static void __attribute__((constructor)) init_get_clock(void)
     ret = QueryPerformanceFrequency(&freq);
     if (ret == 0) {
         fprintf(stderr, "Could not calibrate ticks\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     clock_freq = freq.QuadPart;
 }
diff --git a/vl.c b/vl.c
index ad2664b..7f7c4d8 100644
--- a/vl.c
+++ b/vl.c
@@ -834,7 +834,7 @@ static void configure_rtc_date_offset(const char *startdate, int legacy)
             error_report("invalid date format");
             error_printf("valid formats: "
                          "'2006-06-17T16:01:21' or '2006-06-17'\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         rtc_date_offset = qemu_time() - rtc_start_date;
     }
@@ -868,7 +868,7 @@ static void configure_rtc(QemuOpts *opts)
             rtc_clock = QEMU_CLOCK_VIRTUAL;
         } else {
             error_report("invalid option value '%s'", value);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
     value = qemu_opt_get(opts, "driftfix");
@@ -885,7 +885,7 @@ static void configure_rtc(QemuOpts *opts)
             /* discard is default */
         } else {
             error_report("invalid option value '%s'", value);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 }
@@ -1164,7 +1164,7 @@ static void default_drive(int enable, int snapshot, BlockInterfaceType type,
 
     dinfo = drive_new(opts, type);
     if (!dinfo) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     dinfo->is_default = true;
 
@@ -1224,19 +1224,19 @@ static void smp_parse(QemuOpts *opts)
                          "sockets (%u) * cores (%u) * threads (%u) < "
                          "smp_cpus (%u)",
                          sockets, cores, threads, cpus);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         max_cpus = qemu_opt_get_number(opts, "maxcpus", cpus);
 
         if (max_cpus > MAX_CPUMASK_BITS) {
             error_report("unsupported number of maxcpus");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         if (max_cpus < cpus) {
             error_report("maxcpus must be equal to or greater than smp");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         if (sockets * cores * threads > max_cpus) {
@@ -1244,7 +1244,7 @@ static void smp_parse(QemuOpts *opts)
                          "sockets (%u) * cores (%u) * threads (%u) > "
                          "maxcpus (%u)",
                          sockets, cores, threads, max_cpus);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         smp_cpus = cpus;
@@ -1264,7 +1264,7 @@ static void realtime_init(void)
     if (enable_mlock) {
         if (os_mlock() < 0) {
             error_report("locking memory failed");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 }
@@ -2028,7 +2028,7 @@ static void select_vgahw(const char *p)
         if (ti->opt_name && strstart(p, ti->opt_name, &opts)) {
             if (!vga_interface_available(t)) {
                 error_report("%s not available", ti->name);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             vga_interface_type = t;
             break;
@@ -2037,7 +2037,7 @@ static void select_vgahw(const char *p)
     if (t == VGA_TYPE_MAX) {
     invalid_vga:
         error_report("unknown vga type: %s", p);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     while (*opts) {
         const char *nextopt;
@@ -2122,27 +2122,27 @@ static DisplayType select_display(const char *p)
             } else {
             invalid_sdl_args:
                 error_report("invalid SDL option string");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             opts = nextopt;
         }
 #else
         error_report("SDL support is disabled");
-        exit(1);
+        exit(EXIT_FAILURE);
 #endif
     } else if (strstart(p, "vnc", &opts)) {
         if (*opts == '=') {
             vnc_parse(opts + 1, &error_fatal);
         } else {
             error_report("VNC requires a display argument vnc=<display>");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else if (strstart(p, "curses", &opts)) {
 #ifdef CONFIG_CURSES
         display = DT_CURSES;
 #else
         error_report("curses support is disabled");
-        exit(1);
+        exit(EXIT_FAILURE);
 #endif
     } else if (strstart(p, "gtk", &opts)) {
 #ifdef CONFIG_GTK
@@ -2171,19 +2171,19 @@ static DisplayType select_display(const char *p)
             } else {
             invalid_gtk_args:
                 error_report("invalid GTK option string");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             opts = nextopt;
         }
 #else
         error_report("GTK support is disabled");
-        exit(1);
+        exit(EXIT_FAILURE);
 #endif
     } else if (strstart(p, "none", &opts)) {
         display = DT_NONE;
     } else {
         error_report("unknown display type");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     return display;
@@ -2358,7 +2358,7 @@ static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)
         flags = MONITOR_USE_CONTROL;
     } else {
         error_report("unknown monitor mode \"%s\"", mode);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (qemu_opt_get_bool(opts, "pretty", 0))
@@ -2371,7 +2371,7 @@ static int mon_init_func(void *opaque, QemuOpts *opts, Error **errp)
     chr = qemu_chr_find(chardev);
     if (chr == NULL) {
         error_report("chardev \"%s\" not found", chardev);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     qemu_chr_fe_claim_no_fail(chr);
@@ -2398,7 +2398,7 @@ static void monitor_parse(const char *optarg, const char *mode, bool pretty)
         opts = qemu_chr_parse_compat(label, optarg);
         if (!opts) {
             error_report("parse error: %s", optarg);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -2468,7 +2468,7 @@ static int serial_parse(const char *devname)
         return 0;
     if (index == MAX_SERIAL_PORTS) {
         error_report("too many serial ports");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     snprintf(label, sizeof(label), "serial%d", index);
     serial_hds[index] = qemu_chr_new(label, devname, NULL);
@@ -2490,7 +2490,7 @@ static int parallel_parse(const char *devname)
         return 0;
     if (index == MAX_PARALLEL_PORTS) {
         error_report("too many parallel ports");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     snprintf(label, sizeof(label), "parallel%d", index);
     parallel_hds[index] = qemu_chr_new(label, devname, NULL);
@@ -2514,7 +2514,7 @@ static int virtcon_parse(const char *devname)
         return 0;
     if (index == MAX_VIRTIO_CONSOLES) {
         error_report("too many virtio consoles");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     bus_opts = qemu_opts_create(device, NULL, 0, &error_abort);
@@ -2548,7 +2548,7 @@ static int sclp_parse(const char *devname)
     }
     if (index == MAX_SCLP_CONSOLES) {
         error_report("too many sclp consoles");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     assert(arch_type == QEMU_ARCH_S390X);
@@ -2574,12 +2574,12 @@ static int debugcon_parse(const char *devname)
     QemuOpts *opts;
 
     if (!qemu_chr_new("debugcon", devname, NULL)) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     opts = qemu_opts_create(qemu_find_opts("device"), "debugcon", 1, NULL);
     if (!opts) {
         error_report("already have a debugcon device");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     qemu_opt_set(opts, "driver", "isa-debugcon", &error_abort);
     qemu_opt_set(opts, "chardev", "debugcon", &error_abort);
@@ -2705,7 +2705,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
     for(;;) {
         if (!popt->name) {
             error_report("invalid option");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         if (!strcmp(popt->name, r + 1))
             break;
@@ -2714,7 +2714,7 @@ static const QEMUOption *lookup_opt(int argc, char **argv,
     if (popt->flags & HAS_ARG) {
         if (optind >= argc) {
             error_report("requires an argument");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         optarg = argv[optind++];
         loc_set_cmdline(argv, optind - 2, 2);
@@ -2748,7 +2748,7 @@ static MachineClass *select_machine(void)
     if (!machine_class) {
         error_report("No machine specified, and there is no default");
         error_printf("Use -machine help to list supported machines\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     loc_pop(&loc);
@@ -3022,7 +3022,7 @@ int main(int argc, char **argv, char **envp)
 
     if (qcrypto_init(&err) < 0) {
         error_reportf_err(err, "cannot initialize crypto: ");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     rtc_clock = QEMU_CLOCK_HOST;
 
@@ -3065,7 +3065,7 @@ int main(int argc, char **argv, char **envp)
         int ret;
         ret = qemu_read_default_config_files(userconfig);
         if (ret < 0) {
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -3082,7 +3082,7 @@ int main(int argc, char **argv, char **envp)
             popt = lookup_opt(argc, argv, &optarg, &optind);
             if (!(popt->arch_mask & arch_type)) {
                 error_report("Option not supported for this target");
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             switch(popt->index) {
             case QEMU_OPTION_no_kvm_irqchip: {
@@ -3118,16 +3118,16 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_drive:
                 if (drive_def(optarg) == NULL) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_set:
                 if (qemu_set_option(optarg) != 0)
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 break;
             case QEMU_OPTION_global:
                 if (qemu_global_option(optarg) != 0)
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 break;
             case QEMU_OPTION_mtdblock:
                 drive_add(IF_MTD, -1, optarg, MTD_OPTS);
@@ -3178,7 +3178,7 @@ int main(int argc, char **argv, char **envp)
                     } else if (*p != '\0') {
                     chs_fail:
                         error_report("invalid physical CHS format");
-                        exit(1);
+                        exit(EXIT_FAILURE);
                     }
                     if (hda_opts != NULL) {
                         qemu_opt_set_number(hda_opts, "cyls", cyls,
@@ -3207,7 +3207,7 @@ int main(int argc, char **argv, char **envp)
                 opts = qemu_opts_parse_noisily(qemu_find_opts("numa"),
                                                optarg, true);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_display:
@@ -3224,7 +3224,7 @@ int main(int argc, char **argv, char **envp)
                 display_type = DT_CURSES;
 #else
                 error_report("curses support is disabled");
-                exit(1);
+                exit(EXIT_FAILURE);
 #endif
                 break;
             case QEMU_OPTION_portrait:
@@ -3235,7 +3235,7 @@ int main(int argc, char **argv, char **envp)
                 if (graphic_rotate != 0 && graphic_rotate != 90 &&
                     graphic_rotate != 180 && graphic_rotate != 270) {
                     error_report("only 90, 180, 270 deg rotation is available");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_kernel:
@@ -3261,7 +3261,7 @@ int main(int argc, char **argv, char **envp)
                 opts = qemu_opts_parse_noisily(qemu_find_opts("boot-opts"),
                                                optarg, true);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_fda:
@@ -3275,13 +3275,13 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_netdev:
                 default_net = 0;
                 if (net_client_parse(qemu_find_opts("netdev"), optarg) == -1) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_net:
                 default_net = 0;
                 if (net_client_parse(qemu_find_opts("net"), optarg) == -1) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
 #ifdef CONFIG_LIBISCSI
@@ -3289,7 +3289,7 @@ int main(int argc, char **argv, char **envp)
                 opts = qemu_opts_parse_noisily(qemu_find_opts("iscsi"),
                                                optarg, false);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
 #endif
@@ -3308,7 +3308,7 @@ int main(int argc, char **argv, char **envp)
                 error_report("The -redir option is deprecated. "
                              "Please use '-netdev user,hostfwd=...' instead.");
                 if (net_slirp_redir(optarg) < 0)
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 break;
 #endif
             case QEMU_OPTION_bt:
@@ -3316,7 +3316,7 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_audio_help:
                 AUD_help ();
-                exit (0);
+                exit(EXIT_SUCCESS);
                 break;
             case QEMU_OPTION_soundhw:
                 select_soundhw (optarg);
@@ -3326,7 +3326,7 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_version:
                 version();
-                exit(0);
+                exit(EXIT_SUCCESS);
                 break;
             case QEMU_OPTION_m:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("memory"),
@@ -3338,7 +3338,7 @@ int main(int argc, char **argv, char **envp)
 #ifdef CONFIG_TPM
             case QEMU_OPTION_tpmdev:
                 if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
 #endif
@@ -3399,7 +3399,7 @@ int main(int argc, char **argv, char **envp)
                     if (w <= 0) {
                     graphic_error:
                         error_report("invalid resolution or depth");
-                        exit(1);
+                        exit(EXIT_FAILURE);
                     }
                     if (*p != 'x')
                         goto graphic_error;
@@ -3450,7 +3450,7 @@ int main(int argc, char **argv, char **envp)
                 opts = qemu_opts_parse_noisily(qemu_find_opts("mon"), optarg,
                                                true);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 default_monitor = 0;
                 break;
@@ -3458,18 +3458,18 @@ int main(int argc, char **argv, char **envp)
                 opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"),
                                                optarg, true);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_fsdev:
                 olist = qemu_find_opts("fsdev");
                 if (!olist) {
                     error_report("fsdev support is disabled");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 opts = qemu_opts_parse_noisily(olist, optarg, true);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_virtfs: {
@@ -3480,17 +3480,17 @@ int main(int argc, char **argv, char **envp)
                 olist = qemu_find_opts("virtfs");
                 if (!olist) {
                     error_report("virtfs support is disabled");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 opts = qemu_opts_parse_noisily(olist, optarg, true);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
 
                 if (qemu_opt_get(opts, "fsdriver") == NULL ||
                     qemu_opt_get(opts, "mount_tag") == NULL) {
                     error_report("Usage: -virtfs fsdriver,mount_tag=tag");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 fsdev = qemu_opts_create(qemu_find_opts("fsdev"),
                                          qemu_opt_get(opts, "mount_tag"),
@@ -3498,7 +3498,7 @@ int main(int argc, char **argv, char **envp)
                 if (!fsdev) {
                     error_report("duplicate fsdev id: %s",
                                  qemu_opt_get(opts, "mount_tag"));
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
 
                 writeout = qemu_opt_get(opts, "writeout");
@@ -3508,7 +3508,7 @@ int main(int argc, char **argv, char **envp)
 #else
                     error_report("writeout=immediate not supported "
                                  "on this platform");
-                    exit(1);
+                    exit(EXIT_FAILURE);
 #endif
                 }
                 qemu_opt_set(fsdev, "fsdriver",
@@ -3547,7 +3547,7 @@ int main(int argc, char **argv, char **envp)
                                          1, NULL);
                 if (!fsdev) {
                     error_report("duplicate option: %s", "virtfs_synth");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 qemu_opt_set(fsdev, "fsdriver", "synth", &error_abort);
 
@@ -3575,7 +3575,7 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_watchdog_action:
                 if (select_watchdog_action(optarg) == -1) {
                     error_report("unknown -watchdog-action parameter");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_virtiocon:
@@ -3619,7 +3619,7 @@ int main(int argc, char **argv, char **envp)
                 break;
 #else
                 error_report("SDL support is disabled");
-                exit(1);
+                exit(EXIT_FAILURE);
 #endif
             case QEMU_OPTION_pidfile:
                 pid_file = optarg;
@@ -3641,7 +3641,7 @@ int main(int argc, char **argv, char **envp)
                 opts = qemu_opts_parse_noisily(qemu_find_opts("acpi"),
                                                optarg, true);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 do_acpitable_option(opts);
                 break;
@@ -3649,7 +3649,7 @@ int main(int argc, char **argv, char **envp)
                 opts = qemu_opts_parse_noisily(qemu_find_opts("smbios"),
                                                optarg, false);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 do_smbios_option(opts);
                 break;
@@ -3657,7 +3657,7 @@ int main(int argc, char **argv, char **envp)
                 opts = qemu_opts_parse_noisily(qemu_find_opts("fw_cfg"),
                                                optarg, true);
                 if (opts == NULL) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_enable_kvm:
@@ -3669,7 +3669,7 @@ int main(int argc, char **argv, char **envp)
                 olist = qemu_find_opts("machine");
                 opts = qemu_opts_parse_noisily(olist, optarg, true);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
              case QEMU_OPTION_no_kvm:
@@ -3704,13 +3704,13 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_device:
                 if (!qemu_opts_parse_noisily(qemu_find_opts("device"),
                                              optarg, true)) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_smp:
                 if (!qemu_opts_parse_noisily(qemu_find_opts("smp-opts"),
                                              optarg, true)) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_vnc:
@@ -3725,7 +3725,7 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_balloon:
                 if (balloon_parse(optarg) < 0) {
                     error_report("unknown -balloon argument %s", optarg);
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_no_reboot:
@@ -3740,26 +3740,26 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_uuid:
                 if(qemu_uuid_parse(optarg, qemu_uuid) < 0) {
                     error_report("failed to parse UUID string: wrong format");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 qemu_uuid_set = true;
                 break;
             case QEMU_OPTION_option_rom:
                 if (nb_option_roms >= MAX_OPTION_ROMS) {
                     error_report("too many option ROMs");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 opts = qemu_opts_parse_noisily(qemu_find_opts("option-rom"),
                                                optarg, true);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 option_rom[nb_option_roms].name = qemu_opt_get(opts, "romfile");
                 option_rom[nb_option_roms].bootindex =
                     qemu_opt_get_number(opts, "bootindex", -1);
                 if (!option_rom[nb_option_roms].name) {
                     error_report("Option ROM file is not specified");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 nb_option_roms++;
                 break;
@@ -3785,7 +3785,7 @@ int main(int argc, char **argv, char **envp)
                         } else {
                             error_report("unsupported semihosting-config %s",
                                          optarg);
-                            exit(1);
+                            exit(EXIT_FAILURE);
                         }
                     } else {
                         semihosting.target = SEMIHOSTING_TARGET_AUTO;
@@ -3795,7 +3795,7 @@ int main(int argc, char **argv, char **envp)
                                      &semihosting, NULL);
                 } else {
                     error_report("unsupported semihosting-config %s", optarg);
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_tdf:
@@ -3805,13 +3805,13 @@ int main(int argc, char **argv, char **envp)
                 opts = qemu_opts_parse_noisily(qemu_find_opts("name"),
                                                optarg, true);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_prom_env:
                 if (nb_prom_envs >= MAX_PROM_ENVS) {
                     error_report("too many prom variables");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 prom_envs[nb_prom_envs] = optarg;
                 nb_prom_envs++;
@@ -3831,7 +3831,7 @@ int main(int argc, char **argv, char **envp)
                 opts = qemu_opts_parse_noisily(qemu_find_opts("rtc"), optarg,
                                                false);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 configure_rtc(opts);
                 break;
@@ -3845,7 +3845,7 @@ int main(int argc, char **argv, char **envp)
                 icount_opts = qemu_opts_parse_noisily(qemu_find_opts("icount"),
                                                       optarg, true);
                 if (!icount_opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_incoming:
@@ -3860,21 +3860,21 @@ int main(int argc, char **argv, char **envp)
             case QEMU_OPTION_xen_domid:
                 if (!(xen_available())) {
                     error_report("Option not supported for this target");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 xen_domid = atoi(optarg);
                 break;
             case QEMU_OPTION_xen_create:
                 if (!(xen_available())) {
                     error_report("Option not supported for this target");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 xen_mode = XEN_CREATE;
                 break;
             case QEMU_OPTION_xen_attach:
                 if (!(xen_available())) {
                     error_report("Option not supported for this target");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 xen_mode = XEN_ATTACH;
                 break;
@@ -3888,7 +3888,7 @@ int main(int argc, char **argv, char **envp)
                     if (ret < 0) {
                         error_report("read config %s: %s", optarg,
                                      strerror(-ret));
-                        exit(1);
+                        exit(EXIT_FAILURE);
                     }
                     break;
                 }
@@ -3896,11 +3896,11 @@ int main(int argc, char **argv, char **envp)
                 olist = qemu_find_opts("spice");
                 if (!olist) {
                     error_report("spice support is disabled");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 opts = qemu_opts_parse_noisily(olist, optarg, false);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 display_remote++;
                 break;
@@ -3914,7 +3914,7 @@ int main(int argc, char **argv, char **envp)
                         if (fp == NULL) {
                             error_report("open %s: %s", optarg,
                                          strerror(errno));
-                            exit(1);
+                            exit(EXIT_FAILURE);
                         }
                     }
                     qemu_config_write(fp);
@@ -3933,7 +3933,7 @@ int main(int argc, char **argv, char **envp)
                 opts = qemu_opts_parse_noisily(qemu_find_opts("sandbox"),
                                                optarg, true);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_add_fd:
@@ -3941,26 +3941,26 @@ int main(int argc, char **argv, char **envp)
                 opts = qemu_opts_parse_noisily(qemu_find_opts("add-fd"),
                                                optarg, false);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
 #else
                 error_report("File descriptor passing is disabled on this "
                              "platform");
-                exit(1);
+                exit(EXIT_FAILURE);
 #endif
                 break;
             case QEMU_OPTION_object:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("object"),
                                                optarg, true);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             case QEMU_OPTION_realtime:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("realtime"),
                                                optarg, false);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 enable_mlock = qemu_opt_get_bool(opts, "mlock", true);
                 break;
@@ -3968,7 +3968,7 @@ int main(int argc, char **argv, char **envp)
                 opts = qemu_opts_parse_noisily(qemu_find_opts("msg"), optarg,
                                                false);
                 if (!opts) {
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 configure_msg(opts);
                 break;
@@ -3976,12 +3976,12 @@ int main(int argc, char **argv, char **envp)
                 if (vmstate_dump_file) {
                     error_report("only one '-dump-vmstate' "
                                  "option may be given");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 vmstate_dump_file = fopen(optarg, "w");
                 if (vmstate_dump_file == NULL) {
                     error_report("open %s: %s", optarg, strerror(errno));
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 break;
             default:
@@ -4005,35 +4005,35 @@ int main(int argc, char **argv, char **envp)
 
     if (qemu_init_main_loop(&main_loop_err)) {
         error_report_err(main_loop_err);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (qemu_opts_foreach(qemu_find_opts("sandbox"),
                           parse_sandbox, NULL, NULL)) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (qemu_opts_foreach(qemu_find_opts("name"),
                           parse_name, NULL, NULL)) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
 #ifndef _WIN32
     if (qemu_opts_foreach(qemu_find_opts("add-fd"),
                           parse_add_fd, NULL, NULL)) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (qemu_opts_foreach(qemu_find_opts("add-fd"),
                           cleanup_add_fd, NULL, NULL)) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 #endif
 
     current_machine = MACHINE(object_new(object_class_get_name(
                           OBJECT_CLASS(machine_class))));
     if (machine_help_func(qemu_get_machine_opts(), current_machine)) {
-        exit(0);
+        exit(EXIT_SUCCESS);
     }
     object_property_add_child(object_get_root(), "machine",
                               OBJECT(current_machine), &error_abort);
@@ -4045,11 +4045,11 @@ int main(int argc, char **argv, char **envp)
 
     if (cpu_model && is_help_option(cpu_model)) {
         list_cpus(stdout, &fprintf, cpu_model);
-        exit(0);
+        exit(EXIT_SUCCESS);
     }
 
     if (!trace_init_backends()) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     trace_init_file(trace_file);
 
@@ -4064,7 +4064,7 @@ int main(int argc, char **argv, char **envp)
         mask = qemu_str_to_log_mask(log_mask);
         if (!mask) {
             qemu_print_log_usage(stdout);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         qemu_set_log(mask);
     } else {
@@ -4089,7 +4089,7 @@ int main(int argc, char **argv, char **envp)
         for (i = 0; i < data_dir_idx; i++) {
             printf("%s\n", data_dir[i]);
         }
-        exit(0);
+        exit(EXIT_SUCCESS);
     }
 
     smp_parse(qemu_opts_find(qemu_find_opts("smp-opts"), NULL));
@@ -4099,7 +4099,7 @@ int main(int argc, char **argv, char **envp)
         error_report("Number of SMP CPUs requested (%d) exceeds max CPUs "
                      "supported by machine '%s' (%d)", max_cpus,
                      machine_class->name, machine_class->max_cpus);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /*
@@ -4160,12 +4160,12 @@ int main(int argc, char **argv, char **envp)
             && (default_parallel || default_serial
                 || default_monitor || default_virtcon)) {
             error_report("-nographic cannot be used with -daemonize");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 #ifdef CONFIG_CURSES
         if (display_type == DT_CURSES) {
             error_report("curses display cannot be used with -daemonize");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 #endif
     }
@@ -4246,7 +4246,7 @@ int main(int argc, char **argv, char **envp)
 #else
         error_report("OpenGL support is disabled");
 #endif
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     page_size_init();
@@ -4255,36 +4255,36 @@ int main(int argc, char **argv, char **envp)
     if (qemu_opts_foreach(qemu_find_opts("object"),
                           user_creatable_add_opts_foreach,
                           object_create_initial, NULL)) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (qemu_opts_foreach(qemu_find_opts("chardev"),
                           chardev_init_func, NULL, NULL)) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
 #ifdef CONFIG_VIRTFS
     if (qemu_opts_foreach(qemu_find_opts("fsdev"),
                           fsdev_init_func, NULL, NULL)) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 #endif
 
     if (pid_file && qemu_create_pidfile(pid_file) != 0) {
         error_report("could not acquire pid file: %s", strerror(errno));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (qemu_opts_foreach(qemu_find_opts("device"),
                           device_help_func, NULL, NULL)) {
-        exit(0);
+        exit(EXIT_SUCCESS);
     }
 
     machine_opts = qemu_get_machine_opts();
     if (qemu_opt_foreach(machine_opts, machine_set_property, current_machine,
                          NULL)) {
         object_unref(OBJECT(current_machine));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     configure_accelerator(current_machine);
@@ -4328,17 +4328,17 @@ int main(int argc, char **argv, char **envp)
 
     if (!linux_boot && *kernel_cmdline != '\0') {
         error_report("-append only allowed with -kernel option");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (!linux_boot && initrd_filename != NULL) {
         error_report("-initrd only allowed with -kernel option");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (!linux_boot && qemu_opt_get(machine_opts, "dtb")) {
         error_report("-dtb only allowed with -kernel option");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (semihosting_enabled() && !semihosting_get_argc() && kernel_filename) {
@@ -4355,7 +4355,7 @@ int main(int argc, char **argv, char **envp)
     if (icount_opts) {
         if (kvm_enabled() || xen_enabled()) {
             error_report("-icount is not allowed with kvm or xen");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         configure_icount(icount_opts, &error_abort);
         qemu_opts_del(icount_opts);
@@ -4370,30 +4370,30 @@ int main(int argc, char **argv, char **envp)
     }
 
     if (net_init_clients() < 0) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (qemu_opts_foreach(qemu_find_opts("object"),
                           user_creatable_add_opts_foreach,
                           object_create_delayed, NULL)) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
 #ifdef CONFIG_TPM
     if (tpm_init() < 0) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 #endif
 
     /* init the bluetooth world */
     if (foreach_device_config(DEV_BT, bt_parse))
-        exit(1);
+        exit(EXIT_FAILURE);
 
     if (!xen_enabled()) {
         /* On 32-bit hosts, QEMU is limited by virtual address space */
         if (ram_size > (2047 << 20) && HOST_LONG_BITS == 32) {
             error_report("at most 2047 MB RAM can be simulated");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -4414,7 +4414,7 @@ int main(int argc, char **argv, char **envp)
     }
     if (qemu_opts_foreach(qemu_find_opts("drive"), drive_init_func,
                           &machine_class->block_default_type, NULL)) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     default_drive(default_cdrom, snapshot, machine_class->block_default_type, 2,
@@ -4426,20 +4426,20 @@ int main(int argc, char **argv, char **envp)
 
     if (qemu_opts_foreach(qemu_find_opts("mon"),
                           mon_init_func, NULL, NULL)) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (foreach_device_config(DEV_SERIAL, serial_parse) < 0)
-        exit(1);
+        exit(EXIT_FAILURE);
     if (foreach_device_config(DEV_PARALLEL, parallel_parse) < 0)
-        exit(1);
+        exit(EXIT_FAILURE);
     if (foreach_device_config(DEV_VIRTCON, virtcon_parse) < 0)
-        exit(1);
+        exit(EXIT_FAILURE);
     if (foreach_device_config(DEV_SCLP, sclp_parse) < 0) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (foreach_device_config(DEV_DEBUGCON, debugcon_parse) < 0)
-        exit(1);
+        exit(EXIT_FAILURE);
 
     /* If no default VGA is requested, the default is "none".  */
     if (default_vga) {
@@ -4490,13 +4490,13 @@ int main(int argc, char **argv, char **envp)
 
     if (qemu_opts_foreach(qemu_find_opts("fw_cfg"),
                           parse_fw_cfg, fw_cfg_find(), NULL) != 0) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* init USB devices */
     if (machine_usb(current_machine)) {
         if (foreach_device_config(DEV_USB, usb_parse) < 0)
-            exit(1);
+            exit(EXIT_FAILURE);
     }
 
     /* Check if IGD GFX passthrough. */
@@ -4506,7 +4506,7 @@ int main(int argc, char **argv, char **envp)
     rom_set_order_override(FW_CFG_ORDER_OVERRIDE_DEVICE);
     if (qemu_opts_foreach(qemu_find_opts("device"),
                           device_init_func, NULL, NULL)) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     rom_reset_order_override();
 
@@ -4565,7 +4565,7 @@ int main(int argc, char **argv, char **envp)
     }
 
     if (foreach_device_config(DEV_GDB, gdbserver_start) < 0) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     qdev_machine_creation_done();
@@ -4577,7 +4577,7 @@ int main(int argc, char **argv, char **envp)
 
     if (rom_check_and_register_reset() != 0) {
         error_report("rom check and register reset failed");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     replay_start();
@@ -4606,7 +4606,7 @@ int main(int argc, char **argv, char **envp)
         qemu_start_incoming_migration(incoming, &local_err);
         if (local_err) {
             error_reportf_err(local_err, "-incoming %s: ", incoming);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     } else if (autostart) {
         vm_start();
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 21/26] misc machine: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (19 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 20/26] common: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 22/26] blockdev: " Laurent Vivier
                   ` (7 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 hw/cris/axis_dev88.c           | 2 +-
 hw/lm32/lm32_boards.c          | 8 ++++----
 hw/lm32/milkymist.c            | 6 +++---
 hw/openrisc/openrisc_sim.c     | 4 ++--
 hw/tricore/tricore_testboard.c | 4 ++--
 hw/unicore32/puv3.c            | 6 +++---
 6 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/hw/cris/axis_dev88.c b/hw/cris/axis_dev88.c
index 60df887..fb022dd 100644
--- a/hw/cris/axis_dev88.c
+++ b/hw/cris/axis_dev88.c
@@ -351,7 +351,7 @@ void axisdev88_init(MachineState *machine)
         cris_load_image(cpu, &li);
     } else if (!qtest_enabled()) {
         fprintf(stderr, "Kernel image must be specified\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
diff --git a/hw/lm32/lm32_boards.c b/hw/lm32/lm32_boards.c
index 8f0c307..7e4ccc3 100644
--- a/hw/lm32/lm32_boards.c
+++ b/hw/lm32/lm32_boards.c
@@ -107,7 +107,7 @@ static void lm32_evr_init(MachineState *machine)
     cpu = cpu_lm32_init(cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "qemu: unable to find CPU '%s'\n", cpu_model);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     env = &cpu->env;
@@ -158,7 +158,7 @@ static void lm32_evr_init(MachineState *machine)
         if (kernel_size < 0) {
             fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -208,7 +208,7 @@ static void lm32_uclinux_init(MachineState *machine)
     cpu = cpu_lm32_init(cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "qemu: unable to find CPU '%s'\n", cpu_model);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     env = &cpu->env;
@@ -260,7 +260,7 @@ static void lm32_uclinux_init(MachineState *machine)
         if (kernel_size < 0) {
             fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
diff --git a/hw/lm32/milkymist.c b/hw/lm32/milkymist.c
index 5cae0f1..de1147e 100644
--- a/hw/lm32/milkymist.c
+++ b/hw/lm32/milkymist.c
@@ -114,7 +114,7 @@ milkymist_init(MachineState *machine)
     cpu = cpu_lm32_init(cpu_model);
     if (cpu == NULL) {
         fprintf(stderr, "qemu: unable to find CPU '%s'\n", cpu_model);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     env = &cpu->env;
@@ -155,7 +155,7 @@ milkymist_init(MachineState *machine)
     if (!kernel_filename && !dinfo && !bios_filename && !qtest_enabled()) {
         fprintf(stderr, "qemu: could not load Milkymist One bios '%s'\n",
                 bios_name);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     g_free(bios_filename);
 
@@ -194,7 +194,7 @@ milkymist_init(MachineState *machine)
         if (kernel_size < 0) {
             fprintf(stderr, "qemu: could not load kernel '%s'\n",
                     kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c
index 6d06d5b..48764b6 100644
--- a/hw/openrisc/openrisc_sim.c
+++ b/hw/openrisc/openrisc_sim.c
@@ -89,7 +89,7 @@ static void cpu_openrisc_load_kernel(ram_addr_t ram_size,
         if (kernel_size < 0) {
             fprintf(stderr, "QEMU: couldn't load the kernel '%s'\n",
                     kernel_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         cpu->env.pc = entry;
     }
@@ -112,7 +112,7 @@ static void openrisc_sim_init(MachineState *machine)
         cpu = cpu_openrisc_init(cpu_model);
         if (cpu == NULL) {
             fprintf(stderr, "Unable to find CPU definition!\n");
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         qemu_register_reset(main_cpu_reset, cpu);
         main_cpu_reset(cpu);
diff --git a/hw/tricore/tricore_testboard.c b/hw/tricore/tricore_testboard.c
index 19dd587..ccc0703 100644
--- a/hw/tricore/tricore_testboard.c
+++ b/hw/tricore/tricore_testboard.c
@@ -52,7 +52,7 @@ static void tricore_load_kernel(CPUTriCoreState *env)
     if (kernel_size <= 0) {
         error_report("qemu: no kernel file '%s'",
                 tricoretb_binfo.kernel_filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env->PC = entry;
 
@@ -77,7 +77,7 @@ static void tricore_testboard_init(MachineState *machine, int board_id)
     cpu = cpu_tricore_init(machine->cpu_model);
     if (!cpu) {
         error_report("Unable to find CPU definition");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
     memory_region_init_ram(ext_cram, NULL, "powerlink_ext_c.ram", 2*1024*1024,
diff --git a/hw/unicore32/puv3.c b/hw/unicore32/puv3.c
index 31cd171..f9c65be 100644
--- a/hw/unicore32/puv3.c
+++ b/hw/unicore32/puv3.c
@@ -101,7 +101,7 @@ static void puv3_load_kernel(const char *kernel_filename)
             KERNEL_MAX_SIZE);
     if (size < 0) {
         error_report("Load kernel error: '%s'", kernel_filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* cheat curses that we have a graphic console, only under ocd console */
@@ -119,7 +119,7 @@ static void puv3_init(MachineState *machine)
 
     if (initrd_filename) {
         error_report("Please use kernel built-in initramdisk");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     if (!cpu_model) {
@@ -129,7 +129,7 @@ static void puv3_init(MachineState *machine)
     cpu = uc32_cpu_init(cpu_model);
     if (!cpu) {
         error_report("Unable to find CPU definition");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 22/26] blockdev: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (20 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 21/26] misc machine: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 23/26] core: " Laurent Vivier
                   ` (6 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, John Snow

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: John Snow <jsnow@redhat.com>
---
 hw/ide/core.c        | 2 +-
 hw/scsi/lsi53c895a.c | 7 ++++---
 hw/sd/ssi-sd.c       | 3 ++-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/hw/ide/core.c b/hw/ide/core.c
index b0e42a6..b927bd8 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2855,7 +2855,7 @@ void ide_drive_get(DriveInfo **hd, int n)
     if (highest_bus > n_buses) {
         error_report("Too many IDE buses defined (%d > %d)",
                      highest_bus, n_buses);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     for (i = 0; i < n; i++) {
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index feb1191..9cd4796 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -28,7 +28,8 @@
 #define DPRINTF(fmt, ...) \
 do { printf("lsi_scsi: " fmt , ## __VA_ARGS__); } while (0)
 #define BADF(fmt, ...) \
-do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
+do { fprintf(stderr, "lsi_scsi: error: " fmt , ## __VA_ARGS__); \
+     exit(EXIT_FAILURE); } while (0)
 #else
 #define DPRINTF(fmt, ...) do {} while(0)
 #define BADF(fmt, ...) \
@@ -1205,7 +1206,7 @@ again:
             break;
         default:
             BADF("Unimplemented phase %d\n", s->sstat1 & PHASE_MASK);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
         s->dfifo = s->dbc & 0xff;
         s->ctest5 = (s->ctest5 & 0xfc) | ((s->dbc >> 8) & 3);
@@ -1276,7 +1277,7 @@ again:
                 }
                 if (insn & (1 << 9)) {
                     BADF("Target mode not implemented\n");
-                    exit(1);
+                    exit(EXIT_FAILURE);
                 }
                 if (insn & (1 << 10))
                     s->carry = 1;
diff --git a/hw/sd/ssi-sd.c b/hw/sd/ssi-sd.c
index 3ff0886..f188455 100644
--- a/hw/sd/ssi-sd.c
+++ b/hw/sd/ssi-sd.c
@@ -23,7 +23,8 @@
 #define DPRINTF(fmt, ...) \
 do { printf("ssi_sd: " fmt , ## __VA_ARGS__); } while (0)
 #define BADF(fmt, ...) \
-do { fprintf(stderr, "ssi_sd: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
+do { fprintf(stderr, "ssi_sd: error: " fmt , ## __VA_ARGS__); \
+     exit(EXIT_FAILURE); } while (0)
 #else
 #define DPRINTF(fmt, ...) do {} while(0)
 #define BADF(fmt, ...) \
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 23/26] core: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (21 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 22/26] blockdev: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 24/26] error, trace: " Laurent Vivier
                   ` (5 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Marcel Apfelbaum

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Marcel Apfelbaum <marcel@redhat.com>
---
 hw/core/machine.c      |  2 +-
 hw/core/platform-bus.c |  4 ++--
 hw/core/qdev.c         |  2 +-
 numa.c                 | 12 ++++++------
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 00fbe3e..3eeb1cc 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -336,7 +336,7 @@ static int error_on_sysbus_device(SysBusDevice *sbdev, void *opaque)
 {
     error_report("Option '-device %s' cannot be handled by this machine",
                  object_class_get_name(object_get_class(OBJECT(sbdev))));
-    exit(1);
+    exit(EXIT_FAILURE);
 }
 
 static void machine_init_notify(Notifier *notifier, void *data)
diff --git a/hw/core/platform-bus.c b/hw/core/platform-bus.c
index 36f84ab..03c6c17 100644
--- a/hw/core/platform-bus.c
+++ b/hw/core/platform-bus.c
@@ -122,7 +122,7 @@ static void platform_bus_map_irq(PlatformBusDevice *pbus, SysBusDevice *sbdev,
     irqn = find_first_zero_bit(pbus->used_irqs, max_irqs);
     if (irqn >= max_irqs) {
         error_report("Platform Bus: Can not fit IRQ line");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     set_bit(irqn, pbus->used_irqs);
@@ -157,7 +157,7 @@ static void platform_bus_map_mmio(PlatformBusDevice *pbus, SysBusDevice *sbdev,
     if (!found_region) {
         error_report("Platform Bus: Can not fit MMIO region of size %"PRIx64,
                      size);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* Map the device's region into our Platform Bus MMIO space */
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 5783442..d6e4483 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -359,7 +359,7 @@ void qdev_init_nofail(DeviceState *dev)
     if (err) {
         error_reportf_err(err, "Initialization of device %s failed: ",
                           object_get_typename(OBJECT(dev)));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     object_unref(OBJECT(dev));
 }
diff --git a/numa.c b/numa.c
index 6289f46..57e4fc4 100644
--- a/numa.c
+++ b/numa.c
@@ -298,7 +298,7 @@ void parse_numa_opts(MachineClass *mc)
     int i;
 
     if (qemu_opts_foreach(qemu_find_opts("numa"), parse_numa, NULL, NULL)) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     assert(max_numa_nodeid <= MAX_NODES);
@@ -308,7 +308,7 @@ void parse_numa_opts(MachineClass *mc)
         /* Report large node IDs first, to make mistakes easier to spot */
         if (!numa_info[i].present) {
             error_report("numa: Node ID missing: %d", i);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
@@ -352,7 +352,7 @@ void parse_numa_opts(MachineClass *mc)
             error_report("total memory for NUMA nodes (0x%" PRIx64 ")"
                          " should equal RAM size (0x" RAM_ADDR_FMT ")",
                          numa_total, ram_size);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         for (i = 0; i < nb_numa_nodes; i++) {
@@ -416,7 +416,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
         if (err) {
             error_report_err(err);
             if (mem_prealloc) {
-                exit(1);
+                exit(EXIT_FAILURE);
             }
 
             /* Legacy behavior: if allocation failed, fall back to
@@ -426,7 +426,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
         }
 #else
         fprintf(stderr, "-mem-path not supported on this host\n");
-        exit(1);
+        exit(EXIT_FAILURE);
 #endif
     } else {
         memory_region_init_ram(mr, owner, name, ram_size, &error_fatal);
@@ -461,7 +461,7 @@ void memory_region_allocate_system_memory(MemoryRegion *mr, Object *owner,
             error_report("memory backend %s is used multiple times. Each "
                          "-numa option must use a different memdev value.",
                          path);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
 
         host_memory_backend_set_mapped(backend, true);
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 24/26] error, trace: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (22 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 23/26] core: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 15:55   ` Eric Blake
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 25/26] hw: " Laurent Vivier
                   ` (4 subsequent siblings)
  28 siblings, 1 reply; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Markus Armbruster

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
---
 trace/control.c | 10 +++++-----
 util/error.c    |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/trace/control.c b/trace/control.c
index 05d85ac..b09d6f1 100644
--- a/trace/control.c
+++ b/trace/control.c
@@ -165,7 +165,7 @@ void trace_enable_events(const char *line_buf)
     if (is_help_option(line_buf)) {
         trace_list_events();
         if (cur_mon == NULL) {
-            exit(0);
+            exit(EXIT_SUCCESS);
         }
     } else {
         do_trace_enable_events(line_buf);
@@ -188,7 +188,7 @@ static void trace_init_events(const char *fname)
     fp = fopen(fname, "r");
     if (!fp) {
         error_report("%s", strerror(errno));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     while (fgets(line_buf, sizeof(line_buf), fp)) {
         loc_set_file(fname, ++line_idx);
@@ -204,7 +204,7 @@ static void trace_init_events(const char *fname)
     if (fclose(fp) != 0) {
         loc_set_file(fname, 0);
         error_report("%s", strerror(errno));
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     loc_pop(&loc);
 }
@@ -224,7 +224,7 @@ void trace_init_file(const char *file)
     if (file) {
         fprintf(stderr, "error: -trace file=...: "
                 "option not supported by the selected tracing backends\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 #endif
 }
@@ -258,7 +258,7 @@ char *trace_opt_parse(const char *optarg)
     QemuOpts *opts = qemu_opts_parse_noisily(qemu_find_opts("trace"),
                                              optarg, true);
     if (!opts) {
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     if (qemu_opt_get(opts, "enable")) {
         trace_enable_events(qemu_opt_get(opts, "enable"));
diff --git a/util/error.c b/util/error.c
index 9c40b1f..89b6e25 100644
--- a/util/error.c
+++ b/util/error.c
@@ -39,7 +39,7 @@ static void error_handle_fatal(Error **errp, Error *err)
     }
     if (errp == &error_fatal) {
         error_report_err(err);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 }
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 25/26] hw: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (23 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 24/26] error, trace: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 26/26] net: " Laurent Vivier
                   ` (3 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
 hw/display/ssd0303.c  | 3 ++-
 hw/i2c/smbus.c        | 3 ++-
 hw/moxie/moxiesim.c   | 8 ++++----
 hw/nvram/eeprom93xx.c | 2 +-
 hw/nvram/fw_cfg.c     | 2 +-
 5 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/hw/display/ssd0303.c b/hw/display/ssd0303.c
index d301756..bc01d0a 100644
--- a/hw/display/ssd0303.c
+++ b/hw/display/ssd0303.c
@@ -20,7 +20,8 @@
 #define DPRINTF(fmt, ...) \
 do { printf("ssd0303: " fmt , ## __VA_ARGS__); } while (0)
 #define BADF(fmt, ...) \
-do { fprintf(stderr, "ssd0303: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
+do { fprintf(stderr, "ssd0303: error: " fmt , ## __VA_ARGS__); \
+     exit(EXIT_FAILURE); } while (0)
 #else
 #define DPRINTF(fmt, ...) do {} while(0)
 #define BADF(fmt, ...) \
diff --git a/hw/i2c/smbus.c b/hw/i2c/smbus.c
index 3979b3d..38928cf 100644
--- a/hw/i2c/smbus.c
+++ b/hw/i2c/smbus.c
@@ -20,7 +20,8 @@
 #define DPRINTF(fmt, ...) \
 do { printf("smbus(%02x): " fmt , dev->i2c.address, ## __VA_ARGS__); } while (0)
 #define BADF(fmt, ...) \
-do { fprintf(stderr, "smbus: error: " fmt , ## __VA_ARGS__); exit(1);} while (0)
+do { fprintf(stderr, "smbus: error: " fmt , ## __VA_ARGS__); \
+     exit(EXIT_FAILURE); } while (0)
 #else
 #define DPRINTF(fmt, ...) do {} while(0)
 #define BADF(fmt, ...) \
diff --git a/hw/moxie/moxiesim.c b/hw/moxie/moxiesim.c
index 3069834..9adae85 100644
--- a/hw/moxie/moxiesim.c
+++ b/hw/moxie/moxiesim.c
@@ -63,7 +63,7 @@ static void load_kernel(MoxieCPU *cpu, LoaderParams *loader_params)
     if (kernel_size <= 0) {
         fprintf(stderr, "qemu: could not load kernel '%s'\n",
                 loader_params->kernel_filename);
-        exit(1);
+        exit(EXIT_FAILURE);
     }
 
     /* load initrd */
@@ -78,7 +78,7 @@ static void load_kernel(MoxieCPU *cpu, LoaderParams *loader_params)
                 fprintf(stderr,
                         "qemu: memory too small for initial ram disk '%s'\n",
                         loader_params->initrd_filename);
-                exit(1);
+                exit(EXIT_FAILURE);
             }
             initrd_size = load_image_targphys(loader_params->initrd_filename,
                                               initrd_offset,
@@ -87,7 +87,7 @@ static void load_kernel(MoxieCPU *cpu, LoaderParams *loader_params)
         if (initrd_size == (target_ulong)-1) {
             fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
                     loader_params->initrd_filename);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 }
@@ -121,7 +121,7 @@ static void moxiesim_init(MachineState *machine)
     cpu = cpu_moxie_init(cpu_model);
     if (!cpu) {
         fprintf(stderr, "Unable to find CPU definition\n");
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     env = &cpu->env;
 
diff --git a/hw/nvram/eeprom93xx.c b/hw/nvram/eeprom93xx.c
index 2c16fc2..b0ddda6 100644
--- a/hw/nvram/eeprom93xx.c
+++ b/hw/nvram/eeprom93xx.c
@@ -105,7 +105,7 @@ static void put_unused(QEMUFile *f, void *pv, size_t size)
 {
     fprintf(stderr, "uint16_from_uint8 is used only for backwards compatibility.\n");
     fprintf(stderr, "Never should be used to write a new state.\n");
-    exit(0);
+    exit(EXIT_SUCCESS);
 }
 
 static const VMStateInfo vmstate_hack_uint16_from_uint8 = {
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 1776b1b..07bb06d 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -807,7 +807,7 @@ void fw_cfg_add_file_callback(FWCfgState *s,  const char *filename,
             strcmp(s->files->f[index].name, s->files->f[i].name) == 0) {
             error_report("duplicate fw_cfg file name: %s",
                          s->files->f[index].name);
-            exit(1);
+            exit(EXIT_FAILURE);
         }
     }
 
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [Qemu-devel] [PATCH 26/26] net: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (24 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 25/26] hw: " Laurent Vivier
@ 2016-09-16 13:56 ` Laurent Vivier
  2016-09-16 14:41 ` [Qemu-devel] [PATCH 00/26] trivial: " no-reply
                   ` (2 subsequent siblings)
  28 siblings, 0 replies; 43+ messages in thread
From: Laurent Vivier @ 2016-09-16 13:56 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Laurent Vivier, Jason Wang

This patch is the result of coccinelle script
scripts/coccinelle/exit.cocci

Signed-off-by: Laurent Vivier <lvivier@redhat.com>
CC: Jason Wang <jasowang@redhat.com>
---
 net/net.c    | 4 ++--
 slirp/misc.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/net.c b/net/net.c
index d51cb29..0215618 100644
--- a/net/net.c
+++ b/net/net.c
@@ -840,9 +840,9 @@ void qemu_check_nic_model(NICInfo *nd, const char *model)
     models[1] = NULL;
 
     if (qemu_show_nic_models(nd->model, models))
-        exit(0);
+        exit(EXIT_SUCCESS);
     if (qemu_find_nic_model(nd, models, model) < 0)
-        exit(1);
+        exit(EXIT_FAILURE);
 }
 
 int qemu_find_nic_model(NICInfo *nd, const char * const *models,
diff --git a/slirp/misc.c b/slirp/misc.c
index 88e9d94..9ceb822 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -172,7 +172,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
         fprintf(stderr, "Error: execvp of %s failed: %s\n",
                 argv[0], strerror(errno));
 		close(0); close(1); close(2); /* XXX */
-		exit(1);
+                exit(EXIT_FAILURE);
 
 	 default:
 		qemu_add_child_watch(pid);
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (25 preceding siblings ...)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 26/26] net: " Laurent Vivier
@ 2016-09-16 14:41 ` no-reply
  2016-09-16 14:47 ` Peter Maydell
  2016-09-16 15:27 ` Daniel P. Berrange
  28 siblings, 0 replies; 43+ messages in thread
From: no-reply @ 2016-09-16 14:41 UTC (permalink / raw)
  To: lvivier; +Cc: famz, qemu-trivial, qemu-devel

Hi,

Your series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 1474034177-17663-1-git-send-email-lvivier@redhat.com
Subject: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git show --no-patch --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]         patchew/1474034177-17663-1-git-send-email-lvivier@redhat.com -> patchew/1474034177-17663-1-git-send-email-lvivier@redhat.com
Switched to a new branch 'test'
3235810 net: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
135fd75 hw: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
e7b6224 error, trace: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
c137ac2 core: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
07288c1 blockdev: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
7b628d1 misc machine: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
6c4967c common: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
7b8ef6f alpha: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
84c70f3 posix: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
c550aba tcg: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
d2b8848 s390: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
f98628c mips: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
2128499 x86: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
ff054fd sh4: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
865df75 sparc: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
c443546 pci, virtio: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
624a839 m68k: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
d8e62e0 qemu-user: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
a95c986 replay: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
bc2fa7d tests: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
8ad5b66 graphics: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
086d557 ppc: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
f456e5f block: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
2bc700c cris: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
5cacfb6 arm: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
566755c coccinelle: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)

=== OUTPUT BEGIN ===
Checking PATCH 1/26: coccinelle: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 2/26: arm: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 3/26: cris: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
ERROR: code indent should never use tabs
#64: FILE: tests/tcg/cris/check_glibc_kernelversion.c:115:
+^Iexit(EXIT_SUCCESS);$

ERROR: code indent should never use tabs
#86: FILE: tests/tcg/cris/check_lz.c:48:
+^Iexit(EXIT_SUCCESS);$

ERROR: code indent should never use tabs
#233: FILE: tests/tcg/cris/sys.c:15:
+^Iexit(EXIT_SUCCESS);$

total: 3 errors, 0 warnings, 133 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 4/26: block: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 5/26: ppc: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 6/26: graphics: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 7/26: tests: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 8/26: replay: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 9/26: qemu-user: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 10/26: m68k: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 11/26: pci, virtio: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 12/26: sparc: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 13/26: sh4: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 14/26: x86: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 15/26: mips: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 16/26: s390: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 17/26: tcg: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 18/26: posix: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 19/26: alpha: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 20/26: common: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 21/26: misc machine: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 22/26: blockdev: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 23/26: core: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 24/26: error, trace: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 25/26: hw: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
Checking PATCH 26/26: net: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 03/26] cris: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 03/26] cris: " Laurent Vivier
@ 2016-09-16 14:41   ` Edgar E. Iglesias
  0 siblings, 0 replies; 43+ messages in thread
From: Edgar E. Iglesias @ 2016-09-16 14:41 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-trivial, qemu-devel

On Fri, Sep 16, 2016 at 03:55:54PM +0200, Laurent Vivier wrote:
> This patch is the result of coccinelle script
> scripts/coccinelle/exit.cocci
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> CC: Edgar E. Iglesias <edgar.iglesias@gmail.com>

Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>


> ---
>  hw/cris/boot.c                              | 4 ++--
>  tests/tcg/cris/check_gcctorture_pr28634-1.c | 2 +-
>  tests/tcg/cris/check_gcctorture_pr28634.c   | 2 +-
>  tests/tcg/cris/check_glibc_kernelversion.c  | 2 +-
>  tests/tcg/cris/check_hello.c                | 2 +-
>  tests/tcg/cris/check_lz.c                   | 2 +-
>  tests/tcg/cris/check_mapbrk.c               | 6 +++---
>  tests/tcg/cris/check_mmap1.c                | 2 +-
>  tests/tcg/cris/check_mmap2.c                | 2 +-
>  tests/tcg/cris/check_mmap3.c                | 2 +-
>  tests/tcg/cris/check_openpf5.c              | 2 +-
>  tests/tcg/cris/check_stat1.c                | 2 +-
>  tests/tcg/cris/check_stat2.c                | 2 +-
>  tests/tcg/cris/check_stat3.c                | 2 +-
>  tests/tcg/cris/check_stat4.c                | 2 +-
>  tests/tcg/cris/check_time1.c                | 2 +-
>  tests/tcg/cris/check_time2.c                | 2 +-
>  tests/tcg/cris/sys.c                        | 2 +-
>  18 files changed, 21 insertions(+), 21 deletions(-)
> 
> diff --git a/hw/cris/boot.c b/hw/cris/boot.c
> index f896ed7..85ab8c4 100644
> --- a/hw/cris/boot.c
> +++ b/hw/cris/boot.c
> @@ -88,13 +88,13 @@ void cris_load_image(CRISCPU *cpu, struct cris_load_info *li)
>      if (image_size < 0) {
>          fprintf(stderr, "qemu: could not load kernel '%s'\n",
>                  li->image_filename);
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      if (li->cmdline && (kcmdline_len = strlen(li->cmdline))) {
>          if (kcmdline_len > 256) {
>              fprintf(stderr, "Too long CRIS kernel cmdline (max 256)\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          pstrcpy_targphys("cmdline", 0x40000000, 256, li->cmdline);
>      }
> diff --git a/tests/tcg/cris/check_gcctorture_pr28634-1.c b/tests/tcg/cris/check_gcctorture_pr28634-1.c
> index 45ecd15..ebe3f6f 100644
> --- a/tests/tcg/cris/check_gcctorture_pr28634-1.c
> +++ b/tests/tcg/cris/check_gcctorture_pr28634-1.c
> @@ -11,5 +11,5 @@ main (void)
>      y += x;
>    if (y != x + 1)
>      abort ();
> -  exit (0);
> +  exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_gcctorture_pr28634.c b/tests/tcg/cris/check_gcctorture_pr28634.c
> index a0c5254..52e5ef3 100644
> --- a/tests/tcg/cris/check_gcctorture_pr28634.c
> +++ b/tests/tcg/cris/check_gcctorture_pr28634.c
> @@ -11,5 +11,5 @@ main (void)
>      y += x;
>    if (y != x + 1)
>      abort ();
> -  exit (0);
> +  exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_glibc_kernelversion.c b/tests/tcg/cris/check_glibc_kernelversion.c
> index 0744872..ebc4959 100644
> --- a/tests/tcg/cris/check_glibc_kernelversion.c
> +++ b/tests/tcg/cris/check_glibc_kernelversion.c
> @@ -112,5 +112,5 @@ int main(void)
>  	if (version < __LINUX_KERNEL_VERSION)
>  		err();
>  	pass();
> -	exit(0);
> +	exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_hello.c b/tests/tcg/cris/check_hello.c
> index fb403ba..14b6fff 100644
> --- a/tests/tcg/cris/check_hello.c
> +++ b/tests/tcg/cris/check_hello.c
> @@ -3,5 +3,5 @@
>  int main ()
>  {
>    printf ("pass\n");
> -  exit (0);
> +  exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_lz.c b/tests/tcg/cris/check_lz.c
> index 69c2e6d..603aeac 100644
> --- a/tests/tcg/cris/check_lz.c
> +++ b/tests/tcg/cris/check_lz.c
> @@ -45,5 +45,5 @@ int main(void)
>  {
>  	check_lz();
>  	pass();
> -	exit(0);
> +	exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_mapbrk.c b/tests/tcg/cris/check_mapbrk.c
> index 1aff762..8d5ec3f 100644
> --- a/tests/tcg/cris/check_mapbrk.c
> +++ b/tests/tcg/cris/check_mapbrk.c
> @@ -16,7 +16,7 @@ int main ()
>        || (p6 = malloc (8191*1024)) == NULL)
>    {
>      printf ("fail\n");
> -    exit (1);
> +    exit(EXIT_FAILURE);
>    }
>  
>    free (p1);
> @@ -30,10 +30,10 @@ int main ()
>    if (p1 == NULL)
>    {
>      printf ("fail\n");
> -    exit (1);
> +    exit(EXIT_FAILURE);
>    }
>    free (p1);
>  
>    printf ("pass\n");
> -  exit (0);
> +  exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_mmap1.c b/tests/tcg/cris/check_mmap1.c
> index b803f0c..12a7fb5 100644
> --- a/tests/tcg/cris/check_mmap1.c
> +++ b/tests/tcg/cris/check_mmap1.c
> @@ -44,5 +44,5 @@ int main (int argc, char *argv[])
>      abort ();
>  
>    printf ("pass\n");
> -  exit (0);
> +  exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_mmap2.c b/tests/tcg/cris/check_mmap2.c
> index 35139a0..6c04db3 100644
> --- a/tests/tcg/cris/check_mmap2.c
> +++ b/tests/tcg/cris/check_mmap2.c
> @@ -44,5 +44,5 @@ int main (int argc, char *argv[])
>      abort ();
>  
>    printf ("pass\n");
> -  exit (0);
> +  exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_mmap3.c b/tests/tcg/cris/check_mmap3.c
> index 34401fa..9430177 100644
> --- a/tests/tcg/cris/check_mmap3.c
> +++ b/tests/tcg/cris/check_mmap3.c
> @@ -29,5 +29,5 @@ int main (int argc, char *argv[])
>      abort ();
>  
>    printf ("pass\n");
> -  exit (0);
> +  exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_openpf5.c b/tests/tcg/cris/check_openpf5.c
> index 1f86ea2..29c9ad3 100644
> --- a/tests/tcg/cris/check_openpf5.c
> +++ b/tests/tcg/cris/check_openpf5.c
> @@ -52,5 +52,5 @@ int main (int argc, char *argv[])
>  
>  ok:
>    printf ("pass\n");
> -  exit (0);
> +  exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_stat1.c b/tests/tcg/cris/check_stat1.c
> index 2e2cae5..bf17527 100644
> --- a/tests/tcg/cris/check_stat1.c
> +++ b/tests/tcg/cris/check_stat1.c
> @@ -12,5 +12,5 @@ int main (void)
>        || !S_ISDIR (buf.st_mode))
>      abort ();
>    printf ("pass\n");
> -  exit (0);
> +  exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_stat2.c b/tests/tcg/cris/check_stat2.c
> index e36172e..e9ca81a 100644
> --- a/tests/tcg/cris/check_stat2.c
> +++ b/tests/tcg/cris/check_stat2.c
> @@ -16,5 +16,5 @@ int main (void)
>        || !S_ISDIR (buf.st_mode))
>      abort ();
>    printf ("pass\n");
> -  exit (0);
> +  exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_stat3.c b/tests/tcg/cris/check_stat3.c
> index 36a9d5d..3696f0d 100644
> --- a/tests/tcg/cris/check_stat3.c
> +++ b/tests/tcg/cris/check_stat3.c
> @@ -21,5 +21,5 @@ int main (int argc, char *argv[])
>        || !S_ISREG (buf.st_mode))
>      abort ();
>    printf ("pass\n");
> -  exit (0);
> +  exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_stat4.c b/tests/tcg/cris/check_stat4.c
> index 04f21fe..bc28b98 100644
> --- a/tests/tcg/cris/check_stat4.c
> +++ b/tests/tcg/cris/check_stat4.c
> @@ -23,5 +23,5 @@ int main (int argc, char *argv[])
>        || !S_ISREG (buf.st_mode))
>      abort ();
>    printf ("pass\n");
> -  exit (0);
> +  exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_time1.c b/tests/tcg/cris/check_time1.c
> index 3fcf0e1..92c00a3 100644
> --- a/tests/tcg/cris/check_time1.c
> +++ b/tests/tcg/cris/check_time1.c
> @@ -42,5 +42,5 @@ main (void)
>      }
>  
>    printf ("pass\n");
> -  exit (0);
> +  exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/check_time2.c b/tests/tcg/cris/check_time2.c
> index 20b69b4..9960866 100644
> --- a/tests/tcg/cris/check_time2.c
> +++ b/tests/tcg/cris/check_time2.c
> @@ -14,5 +14,5 @@ main (void)
>    if (t == (time_t) -1 || t != x)
>      abort ();
>    printf ("pass\n");
> -  exit (0);
> +  exit(EXIT_SUCCESS);
>  }
> diff --git a/tests/tcg/cris/sys.c b/tests/tcg/cris/sys.c
> index 551c5dd..ace397e 100644
> --- a/tests/tcg/cris/sys.c
> +++ b/tests/tcg/cris/sys.c
> @@ -12,7 +12,7 @@ static inline int mystrlen(char *s) {
>  void pass(void) {
>  	char s[] = "passed.\n";
>  	write (1, s, sizeof (s) - 1);
> -	exit (0);
> +	exit(EXIT_SUCCESS);
>  }
>  
>  void _fail(char *reason) {
> -- 
> 2.5.5
> 

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (26 preceding siblings ...)
  2016-09-16 14:41 ` [Qemu-devel] [PATCH 00/26] trivial: " no-reply
@ 2016-09-16 14:47 ` Peter Maydell
  2016-09-16 15:39   ` Daniel P. Berrange
  2016-09-16 15:27 ` Daniel P. Berrange
  28 siblings, 1 reply; 43+ messages in thread
From: Peter Maydell @ 2016-09-16 14:47 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: QEMU Trivial, QEMU Developers

On 16 September 2016 at 14:55, Laurent Vivier <lvivier@redhat.com> wrote:
> This series is the result of coccinelle patch
> scripts/coccinelle/exit.cocci
> provided by the first patch of the series.
>
> It replaces exit(0) by exit(EXIT_SUCCESS)
> and exit(1) by exit(EXIT_FAILURE).
>
> All other exit() are not modified as we don't want
> to change the behavior.
>
> In some cases, I've added manually a line break to comply
> with the maximum line length.

>  182 files changed, 734 insertions(+), 715 deletions(-)

You don't say why this is a useful change to make, and it's an
awful lot of churn for a stylistic issue...

thanks
-- PMM

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
                   ` (27 preceding siblings ...)
  2016-09-16 14:47 ` Peter Maydell
@ 2016-09-16 15:27 ` Daniel P. Berrange
  2016-09-16 15:39   ` Eric Blake
  28 siblings, 1 reply; 43+ messages in thread
From: Daniel P. Berrange @ 2016-09-16 15:27 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-trivial, qemu-devel

On Fri, Sep 16, 2016 at 03:55:51PM +0200, Laurent Vivier wrote:
> This series is the result of coccinelle patch
> scripts/coccinelle/exit.cocci
> provided by the first patch of the series.
> 
> It replaces exit(0) by exit(EXIT_SUCCESS)
> and exit(1) by exit(EXIT_FAILURE).

Some places use '_exit' and should have had the same
change applied AFAICT.

> All other exit() are not modified as we don't want
> to change the behavior.

IMHO, modifying the other exit() calls is precisely
what would make this series useful.

eg there's a bunch of places which arbitrarily use
'-1' instead of '1' as the value for no good reason.

Consolidating the inconsistent use of -1 and 1 would
have functional benefit.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 01/26] coccinelle: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 01/26] coccinelle: " Laurent Vivier
@ 2016-09-16 15:35   ` Eric Blake
  0 siblings, 0 replies; 43+ messages in thread
From: Eric Blake @ 2016-09-16 15:35 UTC (permalink / raw)
  To: Laurent Vivier, qemu-trivial; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1234 bytes --]

On 09/16/2016 08:55 AM, Laurent Vivier wrote:
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
>  scripts/coccinelle/exit.cocci | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>  create mode 100644 scripts/coccinelle/exit.cocci
> 

Script itself is fine. Whether to apply it throughout the tree is a
cosmetic question, but I'm in favor of it; and the script will help us
keep the tree clean. Do we need/want to update HACKING to mention our
new enforced style as well, later in the series?

Reviewed-by: Eric Blake <eblake@redhat.com>

However, Coccinelle doesn't seem to catch comments; your series has
missed at least the 'exit(1)' in the comments of include/qapi/error.h.

> diff --git a/scripts/coccinelle/exit.cocci b/scripts/coccinelle/exit.cocci
> new file mode 100644
> index 0000000..73386c0
> --- /dev/null
> +++ b/scripts/coccinelle/exit.cocci
> @@ -0,0 +1,12 @@
> +// replace exit(0) by exit(EXIT_SUCCESS)
> +//         exit(1) by exit(EXIT_FAILURE)
> +
> +@@
> +@@
> +(
> +- exit(0)
> ++ exit(EXIT_SUCCESS)
> +|
> +- exit(1)
> ++ exit(EXIT_FAILURE)
> +)
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 15:27 ` Daniel P. Berrange
@ 2016-09-16 15:39   ` Eric Blake
  0 siblings, 0 replies; 43+ messages in thread
From: Eric Blake @ 2016-09-16 15:39 UTC (permalink / raw)
  To: Daniel P. Berrange, Laurent Vivier; +Cc: qemu-trivial, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1088 bytes --]

On 09/16/2016 10:27 AM, Daniel P. Berrange wrote:
> On Fri, Sep 16, 2016 at 03:55:51PM +0200, Laurent Vivier wrote:
>> This series is the result of coccinelle patch
>> scripts/coccinelle/exit.cocci
>> provided by the first patch of the series.
>>
>> It replaces exit(0) by exit(EXIT_SUCCESS)
>> and exit(1) by exit(EXIT_FAILURE).
> 
> Some places use '_exit' and should have had the same
> change applied AFAICT.

And _Exit(), if we use it.

> 
>> All other exit() are not modified as we don't want
>> to change the behavior.
> 
> IMHO, modifying the other exit() calls is precisely
> what would make this series useful.
> 
> eg there's a bunch of places which arbitrarily use
> '-1' instead of '1' as the value for no good reason.

What's more, exit(-1) is awful to use; it results in an exit status of
255 due to truncation on Linux; and further has weird effects on
xargs(1) (which special-cases a status of 255, differently than a status
of 1).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 14:47 ` Peter Maydell
@ 2016-09-16 15:39   ` Daniel P. Berrange
  2016-09-16 15:45     ` Peter Maydell
  0 siblings, 1 reply; 43+ messages in thread
From: Daniel P. Berrange @ 2016-09-16 15:39 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Laurent Vivier, QEMU Trivial, QEMU Developers

On Fri, Sep 16, 2016 at 03:47:37PM +0100, Peter Maydell wrote:
> On 16 September 2016 at 14:55, Laurent Vivier <lvivier@redhat.com> wrote:
> > This series is the result of coccinelle patch
> > scripts/coccinelle/exit.cocci
> > provided by the first patch of the series.
> >
> > It replaces exit(0) by exit(EXIT_SUCCESS)
> > and exit(1) by exit(EXIT_FAILURE).
> >
> > All other exit() are not modified as we don't want
> > to change the behavior.
> >
> > In some cases, I've added manually a line break to comply
> > with the maximum line length.
> 
> >  182 files changed, 734 insertions(+), 715 deletions(-)
> 
> You don't say why this is a useful change to make, and it's an
> awful lot of churn for a stylistic issue...

Currently QEMU uses a mix of at least

  exit(EXIT_SUCCESS)
  exit(EXIT_FAILURE)
  exit(1)
  exit(-1)
  _exit(1)
  _exit(0);

so this series has the potential giving us more consistency style
and behaviour, across our code. By not fixing the up the usage of -1,
or fixing the _exit() usage, the series feels incomplete to me though.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 15:39   ` Daniel P. Berrange
@ 2016-09-16 15:45     ` Peter Maydell
  2016-09-19  9:21       ` Markus Armbruster
                         ` (2 more replies)
  0 siblings, 3 replies; 43+ messages in thread
From: Peter Maydell @ 2016-09-16 15:45 UTC (permalink / raw)
  To: Daniel P. Berrange; +Cc: Laurent Vivier, QEMU Trivial, QEMU Developers

On 16 September 2016 at 16:39, Daniel P. Berrange <berrange@redhat.com> wrote:
> On Fri, Sep 16, 2016 at 03:47:37PM +0100, Peter Maydell wrote:
>> On 16 September 2016 at 14:55, Laurent Vivier <lvivier@redhat.com> wrote:
>> > This series is the result of coccinelle patch
>> > scripts/coccinelle/exit.cocci
>> > provided by the first patch of the series.
>> >
>> > It replaces exit(0) by exit(EXIT_SUCCESS)
>> > and exit(1) by exit(EXIT_FAILURE).
>> >
>> > All other exit() are not modified as we don't want
>> > to change the behavior.
>> >
>> > In some cases, I've added manually a line break to comply
>> > with the maximum line length.
>>
>> >  182 files changed, 734 insertions(+), 715 deletions(-)
>>
>> You don't say why this is a useful change to make, and it's an
>> awful lot of churn for a stylistic issue...
>
> Currently QEMU uses a mix of at least
>
>   exit(EXIT_SUCCESS)
>   exit(EXIT_FAILURE)
>   exit(1)
>   exit(-1)
>   _exit(1)
>   _exit(0);
>
> so this series has the potential giving us more consistency style
> and behaviour, across our code. By not fixing the up the usage of -1,
> or fixing the _exit() usage, the series feels incomplete to me though.

-1 is just a bug which we should fix (as Eric says). I don't
see the point in converting all our 0s and 1s to EXIT_SUCCESS
and EXIT_FAILURE though. (It would be less churn to convert the
uses of EXIT_* to 0 and 1...)

thanks
-- PMM

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 24/26] error, trace: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 24/26] error, trace: " Laurent Vivier
@ 2016-09-16 15:55   ` Eric Blake
  0 siblings, 0 replies; 43+ messages in thread
From: Eric Blake @ 2016-09-16 15:55 UTC (permalink / raw)
  To: Laurent Vivier, qemu-trivial; +Cc: qemu-devel, Markus Armbruster

[-- Attachment #1: Type: text/plain, Size: 532 bytes --]

On 09/16/2016 08:56 AM, Laurent Vivier wrote:
> This patch is the result of coccinelle script
> scripts/coccinelle/exit.cocci
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> CC: Markus Armbruster <armbru@redhat.com>
> ---
>  trace/control.c | 10 +++++-----
>  util/error.c    |  2 +-
>  2 files changed, 6 insertions(+), 6 deletions(-)

Matching comments in error.h should be changed by this patch.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 05/26] ppc: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:55 ` [Qemu-devel] [PATCH 05/26] ppc: " Laurent Vivier
@ 2016-09-19  5:22   ` David Gibson
  0 siblings, 0 replies; 43+ messages in thread
From: David Gibson @ 2016-09-19  5:22 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-trivial, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 39912 bytes --]

On Fri, Sep 16, 2016 at 03:55:56PM +0200, Laurent Vivier wrote:
> This patch is the result of coccinelle script
> scripts/coccinelle/exit.cocci
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> CC: David Gibson <david@gibson.dropbear.id.au>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

> ---
>  device_tree.c               | 18 ++++++++--------
>  hw/intc/xics_kvm.c          |  6 +++---
>  hw/ppc/e500.c               | 14 ++++++------
>  hw/ppc/mac_newworld.c       | 12 +++++------
>  hw/ppc/mac_oldworld.c       | 16 +++++++-------
>  hw/ppc/mpc8544ds.c          |  2 +-
>  hw/ppc/ppc.c                |  4 ++--
>  hw/ppc/ppc405_boards.c      | 16 +++++++-------
>  hw/ppc/ppc440_bamboo.c      | 10 ++++-----
>  hw/ppc/ppc4xx_devs.c        |  2 +-
>  hw/ppc/prep.c               | 12 +++++------
>  hw/ppc/spapr.c              | 52 ++++++++++++++++++++++-----------------------
>  hw/ppc/virtex_ml507.c       |  4 ++--
>  target-ppc/kvm.c            |  6 +++---
>  target-ppc/translate.c      |  2 +-
>  target-ppc/translate_init.c | 28 ++++++++++++------------
>  tcg/ppc/tcg-target.inc.c    |  6 +++---
>  17 files changed, 105 insertions(+), 105 deletions(-)
> 
> diff --git a/device_tree.c b/device_tree.c
> index 6e06320..202cee8 100644
> --- a/device_tree.c
> +++ b/device_tree.c
> @@ -61,13 +61,13 @@ void *create_device_tree(int *sizep)
>      ret = fdt_open_into(fdt, fdt, *sizep);
>      if (ret) {
>          error_report("Unable to copy device tree in memory");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      return fdt;
>  fail:
>      error_report("%s Couldn't create dt: %s", __func__, fdt_strerror(ret));
> -    exit(1);
> +    exit(EXIT_FAILURE);
>  }
>  
>  void *load_device_tree(const char *filename_path, int *sizep)
> @@ -222,7 +222,7 @@ static int findnode_nofail(void *fdt, const char *node_path)
>      if (offset < 0) {
>          error_report("%s Couldn't find node %s: %s", __func__, node_path,
>                       fdt_strerror(offset));
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      return offset;
> @@ -291,7 +291,7 @@ int qemu_fdt_setprop(void *fdt, const char *node_path,
>      if (r < 0) {
>          error_report("%s: Couldn't set %s/%s: %s", __func__, node_path,
>                       property, fdt_strerror(r));
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      return r;
> @@ -306,7 +306,7 @@ int qemu_fdt_setprop_cell(void *fdt, const char *node_path,
>      if (r < 0) {
>          error_report("%s: Couldn't set %s/%s = %#08x: %s", __func__,
>                       node_path, property, val, fdt_strerror(r));
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      return r;
> @@ -328,7 +328,7 @@ int qemu_fdt_setprop_string(void *fdt, const char *node_path,
>      if (r < 0) {
>          error_report("%s: Couldn't set %s/%s = %s: %s", __func__,
>                       node_path, property, string, fdt_strerror(r));
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      return r;
> @@ -380,7 +380,7 @@ uint32_t qemu_fdt_get_phandle(void *fdt, const char *path)
>      if (r == 0) {
>          error_report("%s: Couldn't get phandle for %s: %s", __func__,
>                       path, fdt_strerror(r));
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      return r;
> @@ -425,7 +425,7 @@ int qemu_fdt_nop_node(void *fdt, const char *node_path)
>      if (r < 0) {
>          error_report("%s: Couldn't nop node %s: %s", __func__, node_path,
>                       fdt_strerror(r));
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      return r;
> @@ -454,7 +454,7 @@ int qemu_fdt_add_subnode(void *fdt, const char *name)
>      if (retval < 0) {
>          error_report("FDT: Failed to create subnode %s: %s", name,
>                       fdt_strerror(retval));
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      g_free(dupname);
> diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c
> index c9caefc..82c65e8 100644
> --- a/hw/intc/xics_kvm.c
> +++ b/hw/intc/xics_kvm.c
> @@ -67,7 +67,7 @@ static void icp_get_kvm_state(ICPState *ss)
>      if (ret != 0) {
>          error_report("Unable to retrieve KVM interrupt controller state"
>                  " for CPU %ld: %s", kvm_arch_vcpu_id(ss->cs), strerror(errno));
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      ss->xirr = state >> KVM_REG_PPC_ICP_XISR_SHIFT;
> @@ -164,7 +164,7 @@ static void ics_get_kvm_state(ICSState *ics)
>          if (ret != 0) {
>              error_report("Unable to retrieve KVM interrupt controller state"
>                      " for IRQ %d: %s", i + ics->offset, strerror(errno));
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>  
>          irq->server = state & KVM_XICS_DESTINATION_MASK;
> @@ -353,7 +353,7 @@ static void xics_kvm_cpu_setup(XICSState *xics, PowerPCCPU *cpu)
>      if (ret < 0) {
>          error_report("Unable to connect CPU%ld to kernel XICS: %s",
>                       kvm_arch_vcpu_id(cs), strerror(errno));
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      ss->cap_irq_xics_enabled = true;
>  }
> diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
> index 0cd534d..5b4dc56 100644
> --- a/hw/ppc/e500.c
> +++ b/hw/ppc/e500.c
> @@ -209,7 +209,7 @@ static int sysbus_device_create_devtree(SysBusDevice *sbdev, void *opaque)
>      if (!matched) {
>          error_report("Device %s is not supported by this machine yet.",
>                       qdev_fw_name(DEVICE(sbdev)));
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      return 0;
> @@ -754,7 +754,7 @@ static qemu_irq *ppce500_init_mpic(MachineState *machine, PPCE500Params *params,
>          if (machine_kernel_irqchip_required(machine) && !dev) {
>              error_reportf_err(err,
>                                "kernel_irqchip requested but unavailable: ");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>  
> @@ -824,7 +824,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
>          cpu = cpu_ppc_init(machine->cpu_model);
>          if (cpu == NULL) {
>              fprintf(stderr, "Unable to initialize CPU!\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          env = &cpu->env;
>          cs = CPU(cpu);
> @@ -972,7 +972,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
>          if (kernel_size < 0) {
>              fprintf(stderr, "qemu: could not load kernel '%s'\n",
>                      machine->kernel_filename);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>  
>          cur_base += kernel_size;
> @@ -987,7 +987,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
>          if (initrd_size < 0) {
>              fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
>                      machine->initrd_filename);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>  
>          cur_base = initrd_base + initrd_size;
> @@ -1028,7 +1028,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
>                                    NULL, NULL);
>          if (kernel_size < 0) {
>              fprintf(stderr, "qemu: could not load firmware '%s'\n", filename);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>      g_free(filename);
> @@ -1041,7 +1041,7 @@ void ppce500_init(MachineState *machine, PPCE500Params *params)
>                                         kernel_base, kernel_size);
>      if (dt_size < 0) {
>          fprintf(stderr, "couldn't load device tree\n");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      assert(dt_size < DTB_MAX_SIZE);
>  
> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
> index 7d25106..72ff9ad 100644
> --- a/hw/ppc/mac_newworld.c
> +++ b/hw/ppc/mac_newworld.c
> @@ -196,7 +196,7 @@ static void ppc_core99_init(MachineState *machine)
>          cpu = cpu_ppc_init(machine->cpu_model);
>          if (cpu == NULL) {
>              fprintf(stderr, "Unable to find PowerPC CPU definition\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          env = &cpu->env;
>  
> @@ -231,7 +231,7 @@ static void ppc_core99_init(MachineState *machine)
>      }
>      if (bios_size < 0 || bios_size > BIOS_SIZE) {
>          error_report("could not load PowerPC bios '%s'", bios_name);
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      if (linux_boot) {
> @@ -258,7 +258,7 @@ static void ppc_core99_init(MachineState *machine)
>                                                ram_size - kernel_base);
>          if (kernel_size < 0) {
>              error_report("could not load kernel '%s'", kernel_filename);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          /* load initrd */
>          if (initrd_filename) {
> @@ -268,7 +268,7 @@ static void ppc_core99_init(MachineState *machine)
>              if (initrd_size < 0) {
>                  error_report("could not load initial ram disk '%s'",
>                               initrd_filename);
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>              cmdline_base = round_page(initrd_base + initrd_size);
>          } else {
> @@ -294,7 +294,7 @@ static void ppc_core99_init(MachineState *machine)
>          }
>          if (ppc_boot_device == '\0') {
>              fprintf(stderr, "No valid boot device for Mac99 machine\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>  
> @@ -350,7 +350,7 @@ static void ppc_core99_init(MachineState *machine)
>  #endif /* defined(TARGET_PPC64) */
>          default:
>              error_report("Bus model not supported on mac99 machine");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>  
> diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
> index 4479487..01196fe 100644
> --- a/hw/ppc/mac_oldworld.c
> +++ b/hw/ppc/mac_oldworld.c
> @@ -116,7 +116,7 @@ static void ppc_heathrow_init(MachineState *machine)
>          cpu = cpu_ppc_init(machine->cpu_model);
>          if (cpu == NULL) {
>              fprintf(stderr, "Unable to find PowerPC CPU definition\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          env = &cpu->env;
>  
> @@ -130,7 +130,7 @@ static void ppc_heathrow_init(MachineState *machine)
>          fprintf(stderr,
>                  "qemu: Too much memory for this machine: %d MB, maximum 2047 MB\n",
>                  ((unsigned int)ram_size / (1 << 20)));
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      memory_region_allocate_system_memory(ram, NULL, "ppc_heathrow.ram",
> @@ -158,7 +158,7 @@ static void ppc_heathrow_init(MachineState *machine)
>      }
>      if (bios_size < 0 || bios_size > BIOS_SIZE) {
>          error_report("could not load PowerPC bios '%s'", bios_name);
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      if (linux_boot) {
> @@ -184,7 +184,7 @@ static void ppc_heathrow_init(MachineState *machine)
>                                                ram_size - kernel_base);
>          if (kernel_size < 0) {
>              error_report("could not load kernel '%s'", kernel_filename);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          /* load initrd */
>          if (initrd_filename) {
> @@ -194,7 +194,7 @@ static void ppc_heathrow_init(MachineState *machine)
>              if (initrd_size < 0) {
>                  error_report("could not load initial ram disk '%s'",
>                               initrd_filename);
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>              cmdline_base = round_page(initrd_base + initrd_size);
>          } else {
> @@ -228,7 +228,7 @@ static void ppc_heathrow_init(MachineState *machine)
>          }
>          if (ppc_boot_device == '\0') {
>              fprintf(stderr, "No valid boot device for G3 Beige machine\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>  
> @@ -251,7 +251,7 @@ static void ppc_heathrow_init(MachineState *machine)
>              break;
>          default:
>              error_report("Bus model not supported on OldWorld Mac machine");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>  
> @@ -265,7 +265,7 @@ static void ppc_heathrow_init(MachineState *machine)
>      /* init basic PC hardware */
>      if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
>          error_report("Only 6xx bus is supported on heathrow machine");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      pic = heathrow_pic_init(&pic_mem, 1, heathrow_irqs);
>      pci_bus = pci_grackle_init(0xfec00000, pic,
> diff --git a/hw/ppc/mpc8544ds.c b/hw/ppc/mpc8544ds.c
> index 27b8289..8d646bb 100644
> --- a/hw/ppc/mpc8544ds.c
> +++ b/hw/ppc/mpc8544ds.c
> @@ -43,7 +43,7 @@ static void mpc8544ds_init(MachineState *machine)
>  
>      if (machine->ram_size > 0xc0000000) {
>          error_report("The MPC8544DS board only supports up to 3GB of RAM");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      ppce500_init(machine, &params);
> diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
> index 8945869..478b848 100644
> --- a/hw/ppc/ppc.c
> +++ b/hw/ppc/ppc.c
> @@ -1362,13 +1362,13 @@ void ppc_cpu_parse_features(const char *cpu_model)
>      model_pieces = g_strsplit(cpu_model, ",", 2);
>      if (!model_pieces[0]) {
>          error_report("Invalid/empty CPU model name");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      oc = cpu_class_by_name(TYPE_POWERPC_CPU, model_pieces[0]);
>      if (oc == NULL) {
>          error_report("Unable to find CPU definition: %s", model_pieces[0]);
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      typename = object_class_get_name(oc);
> diff --git a/hw/ppc/ppc405_boards.c b/hw/ppc/ppc405_boards.c
> index 4b2f07a..53d4c73 100644
> --- a/hw/ppc/ppc405_boards.c
> +++ b/hw/ppc/ppc405_boards.c
> @@ -266,13 +266,13 @@ static void ref405ep_init(MachineState *machine)
>              g_free(filename);
>              if (bios_size < 0 || bios_size > BIOS_SIZE) {
>                  error_report("Could not load PowerPC BIOS '%s'", bios_name);
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>              bios_size = (bios_size + 0xfff) & ~0xfff;
>              memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios);
>          } else if (!qtest_enabled() || kernel_filename != NULL) {
>              error_report("Could not load PowerPC BIOS '%s'", bios_name);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          } else {
>              /* Avoid an uninitialized variable warning */
>              bios_size = -1;
> @@ -329,7 +329,7 @@ static void ref405ep_init(MachineState *machine)
>          if (kernel_size < 0) {
>              fprintf(stderr, "qemu: could not load kernel '%s'\n",
>                      kernel_filename);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          printf("Load kernel size %ld at " TARGET_FMT_lx,
>                 kernel_size, kernel_base);
> @@ -341,7 +341,7 @@ static void ref405ep_init(MachineState *machine)
>              if (initrd_size < 0) {
>                  fprintf(stderr, "qemu: could not load initial ram disk '%s'\n",
>                          initrd_filename);
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>          } else {
>              initrd_base = 0;
> @@ -564,13 +564,13 @@ static void taihu_405ep_init(MachineState *machine)
>              g_free(filename);
>              if (bios_size < 0 || bios_size > BIOS_SIZE) {
>                  error_report("Could not load PowerPC BIOS '%s'", bios_name);
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>              bios_size = (bios_size + 0xfff) & ~0xfff;
>              memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios);
>          } else if (!qtest_enabled()) {
>              error_report("Could not load PowerPC BIOS '%s'", bios_name);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          memory_region_set_readonly(bios, true);
>      }
> @@ -613,7 +613,7 @@ static void taihu_405ep_init(MachineState *machine)
>          if (kernel_size < 0) {
>              fprintf(stderr, "qemu: could not load kernel '%s'\n",
>                      kernel_filename);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          /* load initrd */
>          if (initrd_filename) {
> @@ -624,7 +624,7 @@ static void taihu_405ep_init(MachineState *machine)
>                  fprintf(stderr,
>                          "qemu: could not load initial ram disk '%s'\n",
>                          initrd_filename);
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>          } else {
>              initrd_base = 0;
> diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c
> index 5c535b1..26b3f46 100644
> --- a/hw/ppc/ppc440_bamboo.c
> +++ b/hw/ppc/ppc440_bamboo.c
> @@ -189,7 +189,7 @@ static void bamboo_init(MachineState *machine)
>      cpu = cpu_ppc_init(machine->cpu_model);
>      if (cpu == NULL) {
>          fprintf(stderr, "Unable to initialize CPU!\n");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      env = &cpu->env;
>  
> @@ -223,7 +223,7 @@ static void bamboo_init(MachineState *machine)
>      pcibus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
>      if (!pcibus) {
>          fprintf(stderr, "couldn't create PCI controller!\n");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      memory_region_init_alias(isa, NULL, "isa_mmio",
> @@ -265,7 +265,7 @@ static void bamboo_init(MachineState *machine)
>          if (success < 0) {
>              fprintf(stderr, "qemu: could not load kernel '%s'\n",
>                      kernel_filename);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>  
> @@ -277,7 +277,7 @@ static void bamboo_init(MachineState *machine)
>          if (initrd_size < 0) {
>              fprintf(stderr, "qemu: could not load ram disk '%s' at %x\n",
>                      initrd_filename, RAMDISK_ADDR);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>  
> @@ -286,7 +286,7 @@ static void bamboo_init(MachineState *machine)
>          if (bamboo_load_device_tree(FDT_ADDR, ram_size, RAMDISK_ADDR,
>                                      initrd_size, kernel_cmdline) < 0) {
>              fprintf(stderr, "couldn't load device tree\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>  }
> diff --git a/hw/ppc/ppc4xx_devs.c b/hw/ppc/ppc4xx_devs.c
> index e7f413e..0e6312a 100644
> --- a/hw/ppc/ppc4xx_devs.c
> +++ b/hw/ppc/ppc4xx_devs.c
> @@ -60,7 +60,7 @@ PowerPCCPU *ppc4xx_init(const char *cpu_model,
>      if (cpu == NULL) {
>          fprintf(stderr, "Unable to find PowerPC %s CPU definition\n",
>                  cpu_model);
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      env = &cpu->env;
>  
> diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
> index 054af1e..1040ddc 100644
> --- a/hw/ppc/prep.c
> +++ b/hw/ppc/prep.c
> @@ -512,7 +512,7 @@ static void ppc_prep_init(MachineState *machine)
>          cpu = cpu_ppc_init(machine->cpu_model);
>          if (cpu == NULL) {
>              fprintf(stderr, "Unable to find PowerPC CPU definition\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          env = &cpu->env;
>  
> @@ -537,7 +537,7 @@ static void ppc_prep_init(MachineState *machine)
>                                            ram_size - kernel_base);
>          if (kernel_size < 0) {
>              error_report("could not load kernel '%s'", kernel_filename);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          /* load initrd */
>          if (initrd_filename) {
> @@ -547,7 +547,7 @@ static void ppc_prep_init(MachineState *machine)
>              if (initrd_size < 0) {
>                  error_report("could not load initial ram disk '%s'",
>                               initrd_filename);
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>          } else {
>              initrd_base = 0;
> @@ -569,13 +569,13 @@ static void ppc_prep_init(MachineState *machine)
>          }
>          if (ppc_boot_device == '\0') {
>              fprintf(stderr, "No valid boot device for Mac99 machine\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>  
>      if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) {
>          error_report("Only 6xx bus is supported on PREP machine");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      dev = qdev_create(NULL, "raven-pcihost");
> @@ -590,7 +590,7 @@ static void ppc_prep_init(MachineState *machine)
>      pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0");
>      if (pci_bus == NULL) {
>          fprintf(stderr, "Couldn't create PCI host controller.\n");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      sysctrl->contiguous_map_irq = qdev_get_gpio_in(dev, 0);
>  
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index ca77bb0..9019fe4 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -912,20 +912,20 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr,
>      ret = spapr_populate_memory(spapr, fdt);
>      if (ret < 0) {
>          error_report("couldn't setup memory nodes in fdt");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      ret = spapr_populate_vdevice(spapr->vio_bus, fdt);
>      if (ret < 0) {
>          error_report("couldn't setup vio devices in fdt");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      if (object_resolve_path_type("", TYPE_SPAPR_RNG, NULL)) {
>          ret = spapr_rng_populate_dt(fdt);
>          if (ret < 0) {
>              error_report("could not set up rng device in the fdt");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>  
> @@ -933,7 +933,7 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr,
>          ret = spapr_populate_pci_dt(phb, PHANDLE_XICP, fdt);
>          if (ret < 0) {
>              error_report("couldn't setup PCI devices in fdt");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>  
> @@ -950,7 +950,7 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr,
>      if (cb && bootlist) {
>          int offset = fdt_path_offset(fdt, "/chosen");
>          if (offset < 0) {
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          for (i = 0; i < cb; i++) {
>              if (bootlist[i] == '\n') {
> @@ -965,7 +965,7 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr,
>          int offset = fdt_path_offset(fdt, "/chosen");
>  
>          if (offset < 0) {
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          fdt_setprop_string(fdt, offset, "qemu,boot-device", boot_device);
>      }
> @@ -984,7 +984,7 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr,
>                                      SPAPR_DR_CONNECTOR_TYPE_CPU);
>          if (ret < 0) {
>              error_report("Couldn't set up CPU DR device tree properties");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>  
> @@ -993,7 +993,7 @@ static void spapr_finalize_fdt(sPAPRMachineState *spapr,
>      if (fdt_totalsize(fdt) > FDT_MAX_SIZE) {
>          error_report("FDT too big ! 0x%x bytes (max is 0x%x)",
>                       fdt_totalsize(fdt), FDT_MAX_SIZE);
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt));
> @@ -1126,7 +1126,7 @@ static int find_unknown_sysbus_device(SysBusDevice *sbdev, void *opaque)
>      if (!matched) {
>          error_report("Device %s is not supported by this machine yet.",
>                       qdev_fw_name(DEVICE(sbdev)));
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      return 0;
> @@ -1696,12 +1696,12 @@ static void ppc_spapr_init(MachineState *machine)
>          if (smp_cpus % smp_threads) {
>              error_report("smp_cpus (%u) must be multiple of threads (%u)",
>                           smp_cpus, smp_threads);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          if (max_cpus % smp_threads) {
>              error_report("max_cpus (%u) must be multiple of threads (%u)",
>                           max_cpus, smp_threads);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>  
> @@ -1716,7 +1716,7 @@ static void ppc_spapr_init(MachineState *machine)
>  
>      if (rma_alloc_size == -1) {
>          error_report("Unable to create RMA");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      if (rma_alloc_size && (rma_alloc_size < node0_size)) {
> @@ -1749,7 +1749,7 @@ static void ppc_spapr_init(MachineState *machine)
>      if (spapr->rma_size > node0_size) {
>          error_report("Numa node 0 has to span the RMA (%#08"HWADDR_PRIx")",
>                       spapr->rma_size);
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      /* Setup a load limit for the ramdisk leaving room for SLOF and FDT */
> @@ -1776,7 +1776,7 @@ static void ppc_spapr_init(MachineState *machine)
>  
>          if (type == NULL) {
>              error_report("Unable to find sPAPR CPU Core definition");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>  
>          spapr->cores = g_new0(Object *, spapr_max_cores);
> @@ -1804,7 +1804,7 @@ static void ppc_spapr_init(MachineState *machine)
>              PowerPCCPU *cpu = cpu_ppc_init(machine->cpu_model);
>              if (cpu == NULL) {
>                  error_report("Unable to find PowerPC CPU definition");
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>              spapr_cpu_init(spapr, cpu, &error_fatal);
>         }
> @@ -1847,7 +1847,7 @@ static void ppc_spapr_init(MachineState *machine)
>              error_report("Specified number of memory slots %"
>                           PRIu64" exceeds max supported %d",
>                           machine->ram_slots, max_memslots);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>  
>          spapr->hotplug_memory.base = ROUND_UP(machine->ram_size,
> @@ -1865,22 +1865,22 @@ static void ppc_spapr_init(MachineState *machine)
>      filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, "spapr-rtas.bin");
>      if (!filename) {
>          error_report("Could not find LPAR rtas '%s'", "spapr-rtas.bin");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      spapr->rtas_size = get_image_size(filename);
>      if (spapr->rtas_size < 0) {
>          error_report("Could not get size of LPAR rtas '%s'", filename);
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      spapr->rtas_blob = g_malloc(spapr->rtas_size);
>      if (load_image_size(filename, spapr->rtas_blob, spapr->rtas_size) < 0) {
>          error_report("Could not load LPAR rtas '%s'", filename);
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      if (spapr->rtas_size > RTAS_MAX_SIZE) {
>          error_report("RTAS too big ! 0x%zx bytes (max is 0x%x)",
>                       (size_t)spapr->rtas_size, RTAS_MAX_SIZE);
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      g_free(filename);
>  
> @@ -1950,7 +1950,7 @@ static void ppc_spapr_init(MachineState *machine)
>          error_report(
>              "pSeries SLOF firmware requires >= %ldM guest RMA (Real Mode Area memory)",
>              MIN_RMA_SLOF);
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      if (kernel_filename) {
> @@ -1969,7 +1969,7 @@ static void ppc_spapr_init(MachineState *machine)
>          if (kernel_size < 0) {
>              error_report("error loading %s: %s",
>                           kernel_filename, load_elf_strerror(kernel_size));
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>  
>          /* load initrd */
> @@ -1983,7 +1983,7 @@ static void ppc_spapr_init(MachineState *machine)
>              if (initrd_size < 0) {
>                  error_report("could not load initial ram disk '%s'",
>                               initrd_filename);
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>          } else {
>              initrd_base = 0;
> @@ -1997,12 +1997,12 @@ static void ppc_spapr_init(MachineState *machine)
>      filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
>      if (!filename) {
>          error_report("Could not find LPAR firmware '%s'", bios_name);
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      fw_size = load_image_targphys(filename, 0, FW_MAX_SIZE);
>      if (fw_size <= 0) {
>          error_report("Could not load LPAR firmware '%s'", filename);
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      g_free(filename);
>  
> @@ -2042,7 +2042,7 @@ static int spapr_kvm_type(const char *vm_type)
>      }
>  
>      error_report("Unknown kvm-type specified '%s'", vm_type);
> -    exit(1);
> +    exit(EXIT_FAILURE);
>  }
>  
>  /*
> diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c
> index b97d966..fb540a3 100644
> --- a/hw/ppc/virtex_ml507.c
> +++ b/hw/ppc/virtex_ml507.c
> @@ -99,7 +99,7 @@ static PowerPCCPU *ppc440_init_xilinx(ram_addr_t *ram_size,
>      cpu = cpu_ppc_init(cpu_model);
>      if (cpu == NULL) {
>          fprintf(stderr, "Unable to initialize CPU!\n");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      env = &cpu->env;
>  
> @@ -284,7 +284,7 @@ static void virtex_init(MachineState *machine)
>              if (initrd_size < 0) {
>                  error_report("couldn't load ram disk '%s'",
>                               machine->initrd_filename);
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>              high = ROUND_UP(high + initrd_size, 4);
>          }
> diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
> index dcb68b9..231718b 100644
> --- a/target-ppc/kvm.c
> +++ b/target-ppc/kvm.c
> @@ -323,7 +323,7 @@ static long gethugepagesize(const char *mem_path)
>      if (ret != 0) {
>          fprintf(stderr, "Couldn't statfs() memory path: %s\n",
>                  strerror(errno));
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>  #define HUGETLBFS_MAGIC       0x958458f6
> @@ -2063,7 +2063,7 @@ void kvmppc_set_papr(PowerPCCPU *cpu)
>      ret = kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_PAPR, 0);
>      if (ret) {
>          error_report("This vCPU type or KVM version does not support PAPR");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      /* Update the capability flag so we sync the right information
> @@ -2084,7 +2084,7 @@ void kvmppc_set_mpic_proxy(PowerPCCPU *cpu, int mpic_proxy)
>      ret = kvm_vcpu_enable_cap(cs, KVM_CAP_PPC_EPR, 0, mpic_proxy);
>      if (ret && mpic_proxy) {
>          error_report("This KVM version does not support EPR");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  }
>  
> diff --git a/target-ppc/translate.c b/target-ppc/translate.c
> index 618334a..b704676 100644
> --- a/target-ppc/translate.c
> +++ b/target-ppc/translate.c
> @@ -7149,7 +7149,7 @@ void gen_intermediate_code(CPUPPCState *env, struct TranslationBlock *tb)
>              fprintf(stderr, "Opcode %02x %02x %02x %02x (%08x) leaked "
>                      "temporaries\n", opc1(ctx.opcode), opc2(ctx.opcode),
>                      opc3(ctx.opcode), opc4(ctx.opcode), ctx.opcode);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      }
>      if (tb->cflags & CF_LAST_IO)
> diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
> index 407ccb9..b362ae7 100644
> --- a/target-ppc/translate_init.c
> +++ b/target-ppc/translate_init.c
> @@ -656,7 +656,7 @@ static inline void _spr_register(CPUPPCState *env, int num,
>  #endif
>          spr->uea_read != NULL || spr->uea_write != NULL) {
>          printf("Error: Trying to register SPR %d (%03x) twice !\n", num, num);
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  #if defined(PPC_DEBUG_SPR)
>      printf("*** register spr %d (%03x) %s val " TARGET_FMT_lx "\n", num, num,
> @@ -1742,7 +1742,7 @@ static void gen_spr_BookE (CPUPPCState *env, uint64_t ivor_mask)
>          if (ivor_mask & (1ULL << i)) {
>              if (ivor_sprn[i] == SPR_BOOKE_IVORxx) {
>                  fprintf(stderr, "ERROR: IVOR %d SPR is not defined\n", i);
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>              spr_register(env, ivor_sprn[i], ivor_names[i],
>                           SPR_NOACCESS, SPR_NOACCESS,
> @@ -8974,12 +8974,12 @@ static void init_ppc_proc(PowerPCCPU *cpu)
>          default:
>              fprintf(stderr, "PowerPC MSR definition inconsistency\n"
>                      "Should define POWERPC_FLAG_SPE or POWERPC_FLAG_VRE\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      } else if (env->flags & (POWERPC_FLAG_SPE | POWERPC_FLAG_VRE)) {
>          fprintf(stderr, "PowerPC MSR definition inconsistency\n"
>                  "Should not define POWERPC_FLAG_SPE nor POWERPC_FLAG_VRE\n");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      if (env->msr_mask & (1 << 17)) {
>          switch (env->flags & (POWERPC_FLAG_TGPR | POWERPC_FLAG_CE)) {
> @@ -8989,12 +8989,12 @@ static void init_ppc_proc(PowerPCCPU *cpu)
>          default:
>              fprintf(stderr, "PowerPC MSR definition inconsistency\n"
>                      "Should define POWERPC_FLAG_TGPR or POWERPC_FLAG_CE\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      } else if (env->flags & (POWERPC_FLAG_TGPR | POWERPC_FLAG_CE)) {
>          fprintf(stderr, "PowerPC MSR definition inconsistency\n"
>                  "Should not define POWERPC_FLAG_TGPR nor POWERPC_FLAG_CE\n");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      if (env->msr_mask & (1 << 10)) {
>          switch (env->flags & (POWERPC_FLAG_SE | POWERPC_FLAG_DWE |
> @@ -9007,14 +9007,14 @@ static void init_ppc_proc(PowerPCCPU *cpu)
>              fprintf(stderr, "PowerPC MSR definition inconsistency\n"
>                      "Should define POWERPC_FLAG_SE or POWERPC_FLAG_DWE or "
>                      "POWERPC_FLAG_UBLE\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      } else if (env->flags & (POWERPC_FLAG_SE | POWERPC_FLAG_DWE |
>                               POWERPC_FLAG_UBLE)) {
>          fprintf(stderr, "PowerPC MSR definition inconsistency\n"
>                  "Should not define POWERPC_FLAG_SE nor POWERPC_FLAG_DWE nor "
>                  "POWERPC_FLAG_UBLE\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>      }
>      if (env->msr_mask & (1 << 9)) {
>          switch (env->flags & (POWERPC_FLAG_BE | POWERPC_FLAG_DE)) {
> @@ -9024,12 +9024,12 @@ static void init_ppc_proc(PowerPCCPU *cpu)
>          default:
>              fprintf(stderr, "PowerPC MSR definition inconsistency\n"
>                      "Should define POWERPC_FLAG_BE or POWERPC_FLAG_DE\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      } else if (env->flags & (POWERPC_FLAG_BE | POWERPC_FLAG_DE)) {
>          fprintf(stderr, "PowerPC MSR definition inconsistency\n"
>                  "Should not define POWERPC_FLAG_BE nor POWERPC_FLAG_DE\n");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      if (env->msr_mask & (1 << 2)) {
>          switch (env->flags & (POWERPC_FLAG_PX | POWERPC_FLAG_PMM)) {
> @@ -9039,17 +9039,17 @@ static void init_ppc_proc(PowerPCCPU *cpu)
>          default:
>              fprintf(stderr, "PowerPC MSR definition inconsistency\n"
>                      "Should define POWERPC_FLAG_PX or POWERPC_FLAG_PMM\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>      } else if (env->flags & (POWERPC_FLAG_PX | POWERPC_FLAG_PMM)) {
>          fprintf(stderr, "PowerPC MSR definition inconsistency\n"
>                  "Should not define POWERPC_FLAG_PX nor POWERPC_FLAG_PMM\n");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      if ((env->flags & (POWERPC_FLAG_RTC_CLK | POWERPC_FLAG_BUS_CLK)) == 0) {
>          fprintf(stderr, "PowerPC flags inconsistency\n"
>                  "Should define the time-base and decrementer clock source\n");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      /* Allocate TLBs buffer when needed */
>  #if !defined(CONFIG_USER_ONLY)
> @@ -10365,7 +10365,7 @@ static void ppc_cpu_reset(CPUState *s)
>      msr |= (target_ulong)1 << MSR_LE; /* Little-endian user mode */
>      if (!((env->msr_mask >> MSR_LE) & 1)) {
>          fprintf(stderr, "Selected CPU does not support little-endian.\n");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  #endif
>  #endif
> diff --git a/tcg/ppc/tcg-target.inc.c b/tcg/ppc/tcg-target.inc.c
> index eaf1bd9..8377302 100644
> --- a/tcg/ppc/tcg-target.inc.c
> +++ b/tcg/ppc/tcg-target.inc.c
> @@ -2742,7 +2742,7 @@ static void __attribute__((constructor)) tcg_cache_init(void)
>          if (isize == 0) {
>              fprintf(stderr, "getauxval AT_ICACHEBSIZE failed\n");
>          }
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      dcache_bsize = dsize;
>      icache_bsize = isize;
> @@ -2760,7 +2760,7 @@ static void __attribute__((constructor)) tcg_cache_init(void)
>      len = sizeof(cacheline);
>      if (sysctl(name, 2, &cacheline, &len, NULL, 0)) {
>          perror("sysctl CTL_HW HW_CACHELINE failed");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      dcache_bsize = cacheline;
>      icache_bsize = cacheline;
> @@ -2777,7 +2777,7 @@ static void __attribute__((constructor)) tcg_cache_init(void)
>      if (sysctlbyname ("machdep.cacheline_size", &cacheline, &len, NULL, 0)) {
>          fprintf(stderr, "sysctlbyname machdep.cacheline_size failed: %s\n",
>                  strerror(errno));
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      dcache_bsize = cacheline;
>      icache_bsize = cacheline;
> -- 
> 2.5.5
> 

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 15:45     ` Peter Maydell
@ 2016-09-19  9:21       ` Markus Armbruster
  2016-09-19  9:46       ` Laurent Vivier
  2016-09-19 10:32       ` Cornelia Huck
  2 siblings, 0 replies; 43+ messages in thread
From: Markus Armbruster @ 2016-09-19  9:21 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Daniel P. Berrange, Laurent Vivier, QEMU Trivial, QEMU Developers

Peter Maydell <peter.maydell@linaro.org> writes:

> On 16 September 2016 at 16:39, Daniel P. Berrange <berrange@redhat.com> wrote:
>> On Fri, Sep 16, 2016 at 03:47:37PM +0100, Peter Maydell wrote:
>>> On 16 September 2016 at 14:55, Laurent Vivier <lvivier@redhat.com> wrote:
>>> > This series is the result of coccinelle patch
>>> > scripts/coccinelle/exit.cocci
>>> > provided by the first patch of the series.
>>> >
>>> > It replaces exit(0) by exit(EXIT_SUCCESS)
>>> > and exit(1) by exit(EXIT_FAILURE).
>>> >
>>> > All other exit() are not modified as we don't want
>>> > to change the behavior.
>>> >
>>> > In some cases, I've added manually a line break to comply
>>> > with the maximum line length.
>>>
>>> >  182 files changed, 734 insertions(+), 715 deletions(-)
>>>
>>> You don't say why this is a useful change to make, and it's an
>>> awful lot of churn for a stylistic issue...
>>
>> Currently QEMU uses a mix of at least
>>
>>   exit(EXIT_SUCCESS)
>>   exit(EXIT_FAILURE)
>>   exit(1)
>>   exit(-1)
>>   _exit(1)
>>   _exit(0);
>>
>> so this series has the potential giving us more consistency style
>> and behaviour, across our code. By not fixing the up the usage of -1,
>> or fixing the _exit() usage, the series feels incomplete to me though.
>
> -1 is just a bug which we should fix (as Eric says). I don't
> see the point in converting all our 0s and 1s to EXIT_SUCCESS
> and EXIT_FAILURE though. (It would be less churn to convert the
> uses of EXIT_* to 0 and 1...)

Seconded.

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 15:45     ` Peter Maydell
  2016-09-19  9:21       ` Markus Armbruster
@ 2016-09-19  9:46       ` Laurent Vivier
  2016-09-19 10:19         ` Peter Maydell
  2016-09-19 10:32       ` Cornelia Huck
  2 siblings, 1 reply; 43+ messages in thread
From: Laurent Vivier @ 2016-09-19  9:46 UTC (permalink / raw)
  To: Peter Maydell, Daniel P. Berrange; +Cc: QEMU Trivial, QEMU Developers



On 16/09/2016 17:45, Peter Maydell wrote:
> On 16 September 2016 at 16:39, Daniel P. Berrange <berrange@redhat.com> wrote:
>> On Fri, Sep 16, 2016 at 03:47:37PM +0100, Peter Maydell wrote:
>>> On 16 September 2016 at 14:55, Laurent Vivier <lvivier@redhat.com> wrote:
>>>> This series is the result of coccinelle patch
>>>> scripts/coccinelle/exit.cocci
>>>> provided by the first patch of the series.
>>>>
>>>> It replaces exit(0) by exit(EXIT_SUCCESS)
>>>> and exit(1) by exit(EXIT_FAILURE).
>>>>
>>>> All other exit() are not modified as we don't want
>>>> to change the behavior.
>>>>
>>>> In some cases, I've added manually a line break to comply
>>>> with the maximum line length.
>>>
>>>>  182 files changed, 734 insertions(+), 715 deletions(-)
>>>
>>> You don't say why this is a useful change to make, and it's an
>>> awful lot of churn for a stylistic issue...
>>
>> Currently QEMU uses a mix of at least
>>
>>   exit(EXIT_SUCCESS)
>>   exit(EXIT_FAILURE)
>>   exit(1)
>>   exit(-1)
>>   _exit(1)
>>   _exit(0);
>>
>> so this series has the potential giving us more consistency style
>> and behaviour, across our code. By not fixing the up the usage of -1,
>> or fixing the _exit() usage, the series feels incomplete to me though.
> 
> -1 is just a bug which we should fix (as Eric says). I don't
> see the point in converting all our 0s and 1s to EXIT_SUCCESS
> and EXIT_FAILURE though. (It would be less churn to convert the
> uses of EXIT_* to 0 and 1...)

Portability?

https://www.gnu.org/software/libc/manual/html_node/Exit-Status.html

-----------------------------------------------------------------------
Portability note: Some non-POSIX systems use different conventions for
exit status values. For greater portability, you can use the macros
EXIT_SUCCESS and EXIT_FAILURE for the conventional status value for
success and failure, respectively. They are declared in the file stdlib.h.

Macro: int EXIT_SUCCESS
This macro can be used with the exit function to indicate successful
program completion.

On POSIX systems, the value of this macro is 0. On other systems, the
value might be some other (possibly non-constant) integer expression.

Macro: int EXIT_FAILURE
This macro can be used with the exit function to indicate unsuccessful
program completion in a general sense.

On POSIX systems, the value of this macro is 1. On other systems, the
value might be some other (possibly non-constant) integer expression.
Other nonzero status values also indicate failures. Certain programs use
different nonzero status values to indicate particular kinds of
"non-success". For example, diff uses status value 1 to mean that the
files are different, and 2 or more to mean that there was difficulty in
opening the files.
-----------------------------------------------------------------------

What bothers me is some exit() use 0s and 1s, and some others EXIT_
macros. If you want to use 0s and 1s I have no problem with that, I have
just to update the coccinelle script.

Laurent

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-19  9:46       ` Laurent Vivier
@ 2016-09-19 10:19         ` Peter Maydell
  0 siblings, 0 replies; 43+ messages in thread
From: Peter Maydell @ 2016-09-19 10:19 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: Daniel P. Berrange, QEMU Trivial, QEMU Developers

On 19 September 2016 at 10:46, Laurent Vivier <lvivier@redhat.com> wrote:
> -----------------------------------------------------------------------
> Portability note: Some non-POSIX systems use different conventions for
> exit status values. For greater portability, you can use the macros
> EXIT_SUCCESS and EXIT_FAILURE for the conventional status value for
> success and failure, respectively. They are declared in the file stdlib.h.

The only non-POSIX system we support is mingw32, which also uses 0/1
for its exit codes.

The POSIX rationale for exit() also notes that EXIT_SUCCESS is
required to be 0.

Personally I think we should:
 * definitely fix the "exit(-1)" and other exit-with-negative-number
   bugs in the codebase
 * possibly add a checkpatch check for exit-with-negative-constant-arg

If we're going to do anything else then maybe we could change
the EXIT_SUCCESS/EXIT_FAILURE instances in the codebase, but
really I think there are more important inconsistencies to
address (like all the unconverted non-QOM devices).

thanks
-- PMM

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 15:45     ` Peter Maydell
  2016-09-19  9:21       ` Markus Armbruster
  2016-09-19  9:46       ` Laurent Vivier
@ 2016-09-19 10:32       ` Cornelia Huck
  2 siblings, 0 replies; 43+ messages in thread
From: Cornelia Huck @ 2016-09-19 10:32 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Daniel P. Berrange, Laurent Vivier, QEMU Trivial, QEMU Developers

On Fri, 16 Sep 2016 16:45:06 +0100
Peter Maydell <peter.maydell@linaro.org> wrote:

> On 16 September 2016 at 16:39, Daniel P. Berrange <berrange@redhat.com> wrote:
> > On Fri, Sep 16, 2016 at 03:47:37PM +0100, Peter Maydell wrote:
> >> On 16 September 2016 at 14:55, Laurent Vivier <lvivier@redhat.com> wrote:
> >> > This series is the result of coccinelle patch
> >> > scripts/coccinelle/exit.cocci
> >> > provided by the first patch of the series.
> >> >
> >> > It replaces exit(0) by exit(EXIT_SUCCESS)
> >> > and exit(1) by exit(EXIT_FAILURE).
> >> >
> >> > All other exit() are not modified as we don't want
> >> > to change the behavior.
> >> >
> >> > In some cases, I've added manually a line break to comply
> >> > with the maximum line length.
> >>
> >> >  182 files changed, 734 insertions(+), 715 deletions(-)
> >>
> >> You don't say why this is a useful change to make, and it's an
> >> awful lot of churn for a stylistic issue...
> >
> > Currently QEMU uses a mix of at least
> >
> >   exit(EXIT_SUCCESS)
> >   exit(EXIT_FAILURE)
> >   exit(1)
> >   exit(-1)
> >   _exit(1)
> >   _exit(0);
> >
> > so this series has the potential giving us more consistency style
> > and behaviour, across our code. By not fixing the up the usage of -1,
> > or fixing the _exit() usage, the series feels incomplete to me though.
> 
> -1 is just a bug which we should fix (as Eric says). I don't
> see the point in converting all our 0s and 1s to EXIT_SUCCESS
> and EXIT_FAILURE though. (It would be less churn to convert the
> uses of EXIT_* to 0 and 1...)

Agreed.

If we want to make our exit handling more consistent, the first step
would be to examine whether doing an exit() is the right thing to do in
that code path at all. I'm currently aware at least of some exit()s in
the virtio code that need to be converted to real error handling, and
I'd not be surprised if similar things were true for other parts of the
code.

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 16/26] s390: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 16/26] s390: " Laurent Vivier
@ 2016-09-19 11:07   ` Cornelia Huck
  0 siblings, 0 replies; 43+ messages in thread
From: Cornelia Huck @ 2016-09-19 11:07 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-trivial, qemu-devel

On Fri, 16 Sep 2016 15:56:07 +0200
Laurent Vivier <lvivier@redhat.com> wrote:

> This patch is the result of coccinelle script
> scripts/coccinelle/exit.cocci

As stated in my other reply, I'm not convinced that this conversion is
useful, but I did take a look at the exit()s we have in here:

> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> CC: Cornelia Huck <cornelia.huck@de.ibm.com>
> ---
>  target-s390x/cpu.c        |  2 +-
>  target-s390x/kvm.c        | 18 +++++++++---------
>  target-s390x/mmu_helper.c |  2 +-
>  3 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/target-s390x/cpu.c b/target-s390x/cpu.c
> index 2f3c8e2..d4ca6af 100644
> --- a/target-s390x/cpu.c
> +++ b/target-s390x/cpu.c
> @@ -385,7 +385,7 @@ unsigned int s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu)
>      default:
>          error_report("Requested CPU state is not a valid S390 CPU state: %u",
>                       cpu_state);
> -        exit(1);

Can only be hit via programming error in qemu and exiting is the only
thing that really makes sense.

> +        exit(EXIT_FAILURE);
>      }
>      if (kvm_enabled() && cpu->env.cpu_state != cpu_state) {
>          kvm_s390_set_cpu_state(cpu, cpu_state);
> diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
> index dfaf1ca..2b1b908 100644
> --- a/target-s390x/kvm.c
> +++ b/target-s390x/kvm.c
> @@ -920,13 +920,13 @@ static void inject_vcpu_irq_legacy(CPUState *cs, struct kvm_s390_irq *irq)
>      r = s390_kvm_irq_to_interrupt(irq, &kvmint);
>      if (r < 0) {
>          fprintf(stderr, "%s called with bogus interrupt\n", __func__);
> -        exit(1);

Dito, but we probably should convert the fprintf to error_report().

> +        exit(EXIT_FAILURE);
>      }
> 
>      r = kvm_vcpu_ioctl(cs, KVM_S390_INTERRUPT, &kvmint);
>      if (r < 0) {
>          fprintf(stderr, "KVM failed to inject interrupt\n");
> -        exit(1);

There's several reasons why we could hit this:
- qemu programming error
- the kvm module can't get memory... we're probably already dead
- we've hit some internal limit in the kvm module... should not happen
  and is probably a follow-on of a programming error in qemu as well
So I think the exit is fine, but we should still convert to
error_report().

> +        exit(EXIT_FAILURE);
>      }
>  }
> 
> @@ -941,7 +941,7 @@ void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq)
>              return;
>          }
>          error_report("KVM failed to inject interrupt %llx", irq->type);
> -        exit(1);

Dito as for the old injection interface.

> +        exit(EXIT_FAILURE);
>      }
> 
>      inject_vcpu_irq_legacy(cs, irq);
> @@ -955,13 +955,13 @@ static void __kvm_s390_floating_interrupt(struct kvm_s390_irq *irq)
>      r = s390_kvm_irq_to_interrupt(irq, &kvmint);
>      if (r < 0) {
>          fprintf(stderr, "%s called with bogus interrupt\n", __func__);
> -        exit(1);

Same as for vcpu interrupts.

> +        exit(EXIT_FAILURE);
>      }
> 
>      r = kvm_vm_ioctl(kvm_state, KVM_S390_INTERRUPT, &kvmint);
>      if (r < 0) {
>          fprintf(stderr, "KVM failed to inject interrupt\n");
> -        exit(1);

And here as well.

> +        exit(EXIT_FAILURE);
>      }
>  }
> 
> @@ -1905,15 +1905,15 @@ static int handle_intercept(S390CPU *cpu)
>              break;
>          case ICPT_SOFT_INTERCEPT:
>              fprintf(stderr, "KVM unimplemented icpt SOFT\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>              break;
>          case ICPT_IO:
>              fprintf(stderr, "KVM unimplemented icpt IO\n");
> -            exit(1);
> +            exit(EXIT_FAILURE);
>              break;
>          default:
>              fprintf(stderr, "Unknown intercept code: %d\n", icpt_code);
> -            exit(1);
> +            exit(EXIT_FAILURE);

What happened here is that we intercepted with an intercept that we
either don't expect to get or we don't know about. In either case, this
is something the kvm module should have avoided/handled and exit()ing
is probably the best thing to do here as well (or implement support for
an intercept). But this should probably use error_report() as well.

>              break;
>      }
> 
> @@ -2222,7 +2222,7 @@ int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state)
>      default:
>          error_report("Requested CPU state is not a valid S390 CPU state: %u",
>                       cpu_state);
> -        exit(1);

qemu programming error

> +        exit(EXIT_FAILURE);
>      }
> 
>      ret = kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MP_STATE, &mp_state);
> diff --git a/target-s390x/mmu_helper.c b/target-s390x/mmu_helper.c
> index b11a027..dc9960a 100644
> --- a/target-s390x/mmu_helper.c
> +++ b/target-s390x/mmu_helper.c
> @@ -414,7 +414,7 @@ static bool lowprot_enabled(const CPUS390XState *env)
>      default:
>          /* We don't support access register mode */
>          error_report("unsupported addressing mode");
> -        exit(1);

Not implemented - until someone does implement it, exit() looks like
the best way out.

> +        exit(EXIT_FAILURE);
>      }
>  }
> 

All in all, I think our usage of exit() is fine, but some more
error_report() conversions should be done. On the todo list.

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [Qemu-devel] [PATCH 09/26] qemu-user: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE)
  2016-09-16 13:56 ` [Qemu-devel] [PATCH 09/26] qemu-user: " Laurent Vivier
@ 2016-09-21 19:21   ` Riku Voipio
  0 siblings, 0 replies; 43+ messages in thread
From: Riku Voipio @ 2016-09-21 19:21 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-trivial, qemu-devel

On Fri, Sep 16, 2016 at 03:56:00PM +0200, Laurent Vivier wrote:
> This patch is the result of coccinelle script
> scripts/coccinelle/exit.cocci
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> CC: Riku Voipio <riku.voipio@iki.fi>

Acked-by: Riku Voipio <riku.voipio@iki.fi>

> ---
>  bsd-user/main.c      | 20 ++++++++++----------
>  linux-user/main.c    |  4 ++--
>  linux-user/syscall.c |  2 +-
>  3 files changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/bsd-user/main.c b/bsd-user/main.c
> index 0fb08e4..e47e4d7 100644
> --- a/bsd-user/main.c
> +++ b/bsd-user/main.c
> @@ -658,7 +658,7 @@ void cpu_loop(CPUSPARCState *env)
>  #endif
>              printf ("Unhandled trap: 0x%x\n", trapnr);
>              cpu_dump_state(cs, stderr, fprintf, 0);
> -            exit (1);
> +            exit(EXIT_FAILURE);
>          }
>          process_pending_signals (env);
>      }
> @@ -708,7 +708,7 @@ static void usage(void)
>             TARGET_NAME,
>             interp_prefix,
>             x86_stack_size);
> -    exit(1);
> +    exit(EXIT_FAILURE);
>  }
>  
>  THREAD CPUState *thread_cpu;
> @@ -752,7 +752,7 @@ int main(int argc, char **argv)
>  
>      if ((envlist = envlist_create()) == NULL) {
>          (void) fprintf(stderr, "Unable to allocate envlist\n");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>  
>      /* add current environment into the list */
> @@ -793,7 +793,7 @@ int main(int argc, char **argv)
>              envlist_free(envlist);
>              if ((envlist = envlist_create()) == NULL) {
>                  (void) fprintf(stderr, "Unable to allocate envlist\n");
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>          } else if (!strcmp(r, "U")) {
>              r = argv[optind++];
> @@ -815,7 +815,7 @@ int main(int argc, char **argv)
>              if (qemu_host_page_size == 0 ||
>                  (qemu_host_page_size & (qemu_host_page_size - 1)) != 0) {
>                  fprintf(stderr, "page size must be a power of two\n");
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>          } else if (!strcmp(r, "g")) {
>              gdbstub_port = atoi(argv[optind++]);
> @@ -828,7 +828,7 @@ int main(int argc, char **argv)
>  #if defined(cpu_list)
>                      cpu_list(stdout, &fprintf);
>  #endif
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>          } else if (!strcmp(r, "B")) {
>             guest_base = strtol(argv[optind++], NULL, 0);
> @@ -867,7 +867,7 @@ int main(int argc, char **argv)
>          mask = qemu_str_to_log_mask(log_mask);
>          if (!mask) {
>              qemu_print_log_usage(stdout);
> -            exit(1);
> +            exit(EXIT_FAILURE);
>          }
>          qemu_set_log(mask);
>      }
> @@ -878,7 +878,7 @@ int main(int argc, char **argv)
>      filename = argv[optind];
>  
>      if (!trace_init_backends()) {
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      trace_init_file(trace_file);
>  
> @@ -914,7 +914,7 @@ int main(int argc, char **argv)
>      cpu = cpu_init(cpu_model);
>      if (!cpu) {
>          fprintf(stderr, "Unable to find CPU definition\n");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      env = cpu->env_ptr;
>  #if defined(TARGET_SPARC) || defined(TARGET_PPC)
> @@ -1010,7 +1010,7 @@ int main(int argc, char **argv)
>      /* enable 64 bit mode if possible */
>      if (!(env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM)) {
>          fprintf(stderr, "The selected x86 CPU does not support 64 bit mode\n");
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      env->cr[4] |= CR4_PAE_MASK;
>      env->efer |= MSR_EFER_LMA | MSR_EFER_LME;
> diff --git a/linux-user/main.c b/linux-user/main.c
> index 3ad70f8..0ab5360 100644
> --- a/linux-user/main.c
> +++ b/linux-user/main.c
> @@ -4243,7 +4243,7 @@ int main(int argc, char **argv, char **envp)
>      optind = parse_args(argc, argv);
>  
>      if (!trace_init_backends()) {
> -        exit(1);
> +        exit(EXIT_FAILURE);
>      }
>      trace_init_file(trace_file);
>  
> @@ -4700,7 +4700,7 @@ int main(int argc, char **argv, char **envp)
>              if ((env->active_fpu.fcr31_rw_bitmask &
>                    (1 << FCR31_NAN2008)) == 0) {
>                  fprintf(stderr, "ELF binary's NaN mode not supported by CPU\n");
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>              if ((info->elf_flags & EF_MIPS_NAN2008) != 0) {
>                  env->active_fpu.fcr31 |= (1 << FCR31_NAN2008);
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index ca06943..da1f581 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -6513,7 +6513,7 @@ void syscall_init(void)
>              if (arg_type[0] != TYPE_PTR) {
>                  fprintf(stderr, "cannot patch size for ioctl 0x%x\n",
>                          ie->target_cmd);
> -                exit(1);
> +                exit(EXIT_FAILURE);
>              }
>              arg_type++;
>              size = thunk_type_size(arg_type, 0);
> -- 
> 2.5.5
> 

^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2016-09-21 19:21 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-16 13:55 [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) Laurent Vivier
2016-09-16 13:55 ` [Qemu-devel] [PATCH 01/26] coccinelle: " Laurent Vivier
2016-09-16 15:35   ` Eric Blake
2016-09-16 13:55 ` [Qemu-devel] [PATCH 02/26] arm: " Laurent Vivier
2016-09-16 13:55 ` [Qemu-devel] [PATCH 03/26] cris: " Laurent Vivier
2016-09-16 14:41   ` Edgar E. Iglesias
2016-09-16 13:55 ` [Qemu-devel] [PATCH 04/26] block: " Laurent Vivier
2016-09-16 13:55 ` [Qemu-devel] [PATCH 05/26] ppc: " Laurent Vivier
2016-09-19  5:22   ` David Gibson
2016-09-16 13:55 ` [Qemu-devel] [PATCH 06/26] graphics: " Laurent Vivier
2016-09-16 13:55 ` [Qemu-devel] [PATCH 07/26] tests: " Laurent Vivier
2016-09-16 13:55 ` [Qemu-devel] [PATCH 08/26] replay: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 09/26] qemu-user: " Laurent Vivier
2016-09-21 19:21   ` Riku Voipio
2016-09-16 13:56 ` [Qemu-devel] [PATCH 10/26] m68k: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 11/26] pci, virtio: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 12/26] sparc: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 13/26] sh4: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 14/26] x86: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 15/26] mips: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 16/26] s390: " Laurent Vivier
2016-09-19 11:07   ` Cornelia Huck
2016-09-16 13:56 ` [Qemu-devel] [PATCH 17/26] tcg: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 18/26] posix: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 19/26] alpha: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 20/26] common: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 21/26] misc machine: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 22/26] blockdev: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 23/26] core: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 24/26] error, trace: " Laurent Vivier
2016-09-16 15:55   ` Eric Blake
2016-09-16 13:56 ` [Qemu-devel] [PATCH 25/26] hw: " Laurent Vivier
2016-09-16 13:56 ` [Qemu-devel] [PATCH 26/26] net: " Laurent Vivier
2016-09-16 14:41 ` [Qemu-devel] [PATCH 00/26] trivial: " no-reply
2016-09-16 14:47 ` Peter Maydell
2016-09-16 15:39   ` Daniel P. Berrange
2016-09-16 15:45     ` Peter Maydell
2016-09-19  9:21       ` Markus Armbruster
2016-09-19  9:46       ` Laurent Vivier
2016-09-19 10:19         ` Peter Maydell
2016-09-19 10:32       ` Cornelia Huck
2016-09-16 15:27 ` Daniel P. Berrange
2016-09-16 15:39   ` Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.