diff options
-rw-r--r-- | backends/rng-random.c | 6 | ||||
-rwxr-xr-x | configure | 2 | ||||
-rw-r--r-- | hw/block/pflash_cfi02.c | 1 | ||||
-rw-r--r-- | hw/core/qdev.c | 4 | ||||
-rw-r--r-- | hw/i386/acpi-build.c | 22 | ||||
-rw-r--r-- | hw/isa/vt82c686.c | 41 | ||||
-rw-r--r-- | hw/nvram/fw_cfg.c | 1 | ||||
-rw-r--r-- | hw/timer/hpet.c | 2 | ||||
-rw-r--r-- | hw/tpm/tpm_passthrough.c | 4 | ||||
-rw-r--r-- | hw/usb/host-libusb.c | 2 | ||||
-rw-r--r-- | hw/virtio/virtio-bus.c | 2 | ||||
-rw-r--r-- | include/hw/virtio/virtio.h | 3 | ||||
-rw-r--r-- | include/qemu/typedefs.h | 105 | ||||
-rw-r--r-- | qapi-schema.json | 2 | ||||
-rw-r--r-- | qemu-char.c | 4 | ||||
-rw-r--r-- | qmp-commands.hx | 4 | ||||
-rwxr-xr-x | scripts/get_maintainer.pl | 45 | ||||
-rw-r--r-- | target-s390x/helper.c | 6 | ||||
-rw-r--r-- | util/hbitmap.c | 4 | ||||
-rw-r--r-- | util/iov.c | 4 | ||||
-rw-r--r-- | util/uri.c | 94 |
21 files changed, 143 insertions, 215 deletions
diff --git a/backends/rng-random.c b/backends/rng-random.c index 601d9dc0c2..4f85a8ea49 100644 --- a/backends/rng-random.c +++ b/backends/rng-random.c @@ -88,11 +88,7 @@ static char *rng_random_get_filename(Object *obj, Error **errp) { RndRandom *s = RNG_RANDOM(obj); - if (s->filename) { - return g_strdup(s->filename); - } - - return NULL; + return g_strdup(s->filename); } static void rng_random_set_filename(Object *obj, const char *filename, @@ -2727,7 +2727,7 @@ fi if test "$modules" = yes; then shacmd_probe="sha1sum sha1 shasum" for c in $shacmd_probe; do - if which $c >/dev/null 2>&1; then + if has $c; then shacmd="$c" break fi diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c index 8513a17e9f..389b4aa1f4 100644 --- a/hw/block/pflash_cfi02.c +++ b/hw/block/pflash_cfi02.c @@ -744,6 +744,7 @@ static void pflash_cfi02_class_init(ObjectClass *klass, void *data) dc->realize = pflash_cfi02_realize; dc->props = pflash_cfi02_properties; + set_bit(DEVICE_CATEGORY_STORAGE, dc->categories); } static const TypeInfo pflash_cfi02_info = { diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 35fd00d26c..901f289860 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -1141,9 +1141,7 @@ static void device_finalize(Object *obj) NamedGPIOList *ngl, *next; DeviceState *dev = DEVICE(obj); - if (dev->opts) { - qemu_opts_del(dev->opts); - } + qemu_opts_del(dev->opts); QLIST_FOREACH_SAFE(ngl, &dev->gpios, node, next) { QLIST_REMOVE(ngl, node); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index b37a397820..a4d0c0c8bf 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -68,6 +68,14 @@ #define ACPI_BUILD_TABLE_SIZE 0x20000 +/* #define DEBUG_ACPI_BUILD */ +#ifdef DEBUG_ACPI_BUILD +#define ACPI_BUILD_DPRINTF(fmt, ...) \ + do {printf("ACPI_BUILD: " fmt, ## __VA_ARGS__); } while (0) +#else +#define ACPI_BUILD_DPRINTF(fmt, ...) +#endif + typedef struct AcpiCpuInfo { DECLARE_BITMAP(found_cpus, ACPI_CPU_HOTPLUG_ID_LIMIT); } AcpiCpuInfo; @@ -246,8 +254,6 @@ static void acpi_get_pci_info(PcPciInfo *info) #define ACPI_BUILD_APPNAME6 "BOCHS " #define ACPI_BUILD_APPNAME4 "BXPC" -#define ACPI_BUILD_DPRINTF(level, fmt, ...) do {} while (0) - #define ACPI_BUILD_TABLE_FILE "etc/acpi/tables" #define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp" #define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log" @@ -273,12 +279,12 @@ build_header(GArray *linker, GArray *table_data, static inline GArray *build_alloc_array(void) { - return g_array_new(false, true /* clear */, 1); + return g_array_new(false, true /* clear */, 1); } static inline void build_free_array(GArray *array) { - g_array_free(array, true); + g_array_free(array, true); } static inline void build_prepend_byte(GArray *array, uint8_t val) @@ -1569,7 +1575,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) table_offsets = g_array_new(false, true /* clear */, sizeof(uint32_t)); - ACPI_BUILD_DPRINTF(3, "init ACPI tables\n"); + ACPI_BUILD_DPRINTF("init ACPI tables\n"); bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE, 64 /* Ensure FACS is aligned */, @@ -1750,17 +1756,17 @@ void acpi_setup(PcGuestInfo *guest_info) AcpiBuildState *build_state; if (!guest_info->fw_cfg) { - ACPI_BUILD_DPRINTF(3, "No fw cfg. Bailing out.\n"); + ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n"); return; } if (!guest_info->has_acpi_build) { - ACPI_BUILD_DPRINTF(3, "ACPI build disabled. Bailing out.\n"); + ACPI_BUILD_DPRINTF("ACPI build disabled. Bailing out.\n"); return; } if (!acpi_enabled) { - ACPI_BUILD_DPRINTF(3, "ACPI disabled. Bailing out.\n"); + ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n"); return; } diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index e0c235c3c2..223b947939 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -50,13 +50,13 @@ typedef struct VT82C686BState { static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data, unsigned size) { - int can_write; SuperIOConfig *superio_conf = opaque; DPRINTF("superio_ioport_writeb address 0x%x val 0x%x\n", addr, data); if (addr == 0x3f0) { superio_conf->index = data & 0xff; } else { + bool can_write = true; /* 0x3f1 */ switch (superio_conf->index) { case 0x00 ... 0xdf: @@ -68,30 +68,27 @@ static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data, case 0xf7: case 0xf9 ... 0xfb: case 0xfd ... 0xff: - can_write = 0; + can_write = false; break; - default: - can_write = 1; - - if (can_write) { - switch (superio_conf->index) { - case 0xe7: - if ((data & 0xff) != 0xfe) { - DPRINTF("chage uart 1 base. unsupported yet\n"); - } - break; - case 0xe8: - if ((data & 0xff) != 0xbe) { - DPRINTF("chage uart 2 base. unsupported yet\n"); - } - break; - - default: - superio_conf->config[superio_conf->index] = data & 0xff; - } + case 0xe7: + if ((data & 0xff) != 0xfe) { + DPRINTF("change uart 1 base. unsupported yet\n"); + can_write = false; + } + break; + case 0xe8: + if ((data & 0xff) != 0xbe) { + DPRINTF("change uart 2 base. unsupported yet\n"); + can_write = false; } + break; + default: + break; + + } + if (can_write) { + superio_conf->config[superio_conf->index] = data & 0xff; } - superio_conf->config[superio_conf->index] = data & 0xff; } } diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index a7122ee56b..c4b78ed36c 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -621,7 +621,6 @@ static void fw_cfg_realize(DeviceState *dev, Error **errp) FWCfgState *s = FW_CFG(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); - if (s->ctl_iobase + 1 == s->data_iobase) { sysbus_add_io(sbd, s->ctl_iobase, &s->comb_iomem); } else { diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c index e160e8facc..d8bc231e5b 100644 --- a/hw/timer/hpet.c +++ b/hw/timer/hpet.c @@ -1,5 +1,5 @@ /* - * High Precisition Event Timer emulation + * High Precision Event Timer emulation * * Copyright (c) 2007 Alexander Graf * Copyright (c) 2008 IBM Corporation diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index 56e9e0f8a2..2bf3c6fd61 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -400,9 +400,7 @@ static int tpm_passthrough_handle_device_opts(QemuOpts *opts, TPMBackend *tb) const char *value; value = qemu_opt_get(opts, "cancel-path"); - if (value) { - tb->cancel_path = g_strdup(value); - } + tb->cancel_path = g_strdup(value); value = qemu_opt_get(opts, "path"); if (!value) { diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c index a5f9dab0cd..cff4f7cd51 100644 --- a/hw/usb/host-libusb.c +++ b/hw/usb/host-libusb.c @@ -1237,7 +1237,7 @@ static void usb_host_handle_control(USBDevice *udev, USBPacket *p, /* Fix up USB-3 ep0 maxpacket size to allow superspeed connected devices * to work redirected to a not superspeed capable hcd */ if (udev->speed == USB_SPEED_SUPER && - !((udev->port->speedmask & USB_SPEED_MASK_SUPER)) && + !(udev->port->speedmask & USB_SPEED_MASK_SUPER) && request == 0x8006 && value == 0x100 && index == 0) { r->usb3ep0quirk = true; } diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c index eb77019267..dfd2d8c772 100644 --- a/hw/virtio/virtio-bus.c +++ b/hw/virtio/virtio-bus.c @@ -58,7 +58,7 @@ void virtio_bus_reset(VirtioBusState *bus) { VirtIODevice *vdev = virtio_bus_get_device(bus); - DPRINTF("%s: reset device.\n", qbus->name); + DPRINTF("%s: reset device.\n", BUS(bus)->name); if (vdev != NULL) { virtio_reset(vdev); } diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 0726d76f49..f24997d218 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -230,9 +230,6 @@ int virtio_set_features(VirtIODevice *vdev, uint32_t val); /* Base devices. */ typedef struct VirtIOBlkConf VirtIOBlkConf; struct virtio_net_conf; -VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf, - struct virtio_net_conf *net, - uint32_t host_features); typedef struct virtio_serial_conf virtio_serial_conf; typedef struct VirtIOSCSIConf VirtIOSCSIConf; typedef struct VirtIORNGConf VirtIORNGConf; diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index 34751778a3..57ff47f284 100644 --- a/include/qemu/typedefs.h +++ b/include/qemu/typedefs.h @@ -3,80 +3,75 @@ /* A load of opaque types so that device init declarations don't have to pull in all the real definitions. */ -typedef struct QEMUTimer QEMUTimer; -typedef struct QEMUTimerListGroup QEMUTimerListGroup; -typedef struct QEMUFile QEMUFile; -typedef struct QEMUBH QEMUBH; - -typedef struct AioContext AioContext; - -typedef struct Visitor Visitor; - struct Monitor; -typedef struct Monitor Monitor; -typedef struct MigrationParams MigrationParams; - -typedef struct Property Property; -typedef struct PropertyInfo PropertyInfo; -typedef struct CompatProperty CompatProperty; -typedef struct DeviceState DeviceState; -typedef struct BusState BusState; -typedef struct BusClass BusClass; +/* Please keep this list in alphabetical order */ +typedef struct AdapterInfo AdapterInfo; typedef struct AddressSpace AddressSpace; -typedef struct MemoryRegion MemoryRegion; -typedef struct MemoryRegionSection MemoryRegionSection; -typedef struct MemoryListener MemoryListener; - -typedef struct MemoryMappingList MemoryMappingList; - -typedef struct QEMUMachine QEMUMachine; -typedef struct MachineClass MachineClass; -typedef struct MachineState MachineState; -typedef struct NICInfo NICInfo; -typedef struct HCIInfo HCIInfo; +typedef struct AioContext AioContext; typedef struct AudioState AudioState; typedef struct BlockBackend BlockBackend; typedef struct BlockDriverState BlockDriverState; -typedef struct DriveInfo DriveInfo; -typedef struct DisplayState DisplayState; +typedef struct BusClass BusClass; +typedef struct BusState BusState; +typedef struct CharDriverState CharDriverState; +typedef struct CompatProperty CompatProperty; +typedef struct DeviceState DeviceState; typedef struct DisplayChangeListener DisplayChangeListener; +typedef struct DisplayState DisplayState; typedef struct DisplaySurface DisplaySurface; -typedef struct PixelFormat PixelFormat; -typedef struct QemuConsole QemuConsole; -typedef struct CharDriverState CharDriverState; -typedef struct MACAddr MACAddr; -typedef struct NetClientState NetClientState; +typedef struct DriveInfo DriveInfo; +typedef struct EventNotifier EventNotifier; +typedef struct FWCfgState FWCfgState; +typedef struct HCIInfo HCIInfo; typedef struct I2CBus I2CBus; +typedef struct I2SCodec I2SCodec; typedef struct ISABus ISABus; typedef struct ISADevice ISADevice; -typedef struct SMBusDevice SMBusDevice; -typedef struct PCIHostState PCIHostState; -typedef struct PCIExpressHost PCIExpressHost; +typedef struct MACAddr MACAddr; +typedef struct MachineClass MachineClass; +typedef struct MachineState MachineState; +typedef struct MemoryListener MemoryListener; +typedef struct MemoryMappingList MemoryMappingList; +typedef struct MemoryRegion MemoryRegion; +typedef struct MemoryRegionSection MemoryRegionSection; +typedef struct MigrationParams MigrationParams; +typedef struct Monitor Monitor; +typedef struct MouseTransformInfo MouseTransformInfo; +typedef struct MSIMessage MSIMessage; +typedef struct NetClientState NetClientState; +typedef struct NICInfo NICInfo; +typedef struct PcGuestInfo PcGuestInfo; +typedef struct PCIBridge PCIBridge; typedef struct PCIBus PCIBus; typedef struct PCIDevice PCIDevice; -typedef struct PCIExpressDevice PCIExpressDevice; -typedef struct PCIBridge PCIBridge; -typedef struct PCIEAERMsg PCIEAERMsg; -typedef struct PCIEAERLog PCIEAERLog; typedef struct PCIEAERErr PCIEAERErr; +typedef struct PCIEAERLog PCIEAERLog; +typedef struct PCIEAERMsg PCIEAERMsg; typedef struct PCIEPort PCIEPort; typedef struct PCIESlot PCIESlot; -typedef struct MSIMessage MSIMessage; -typedef struct SerialState SerialState; +typedef struct PCIExpressDevice PCIExpressDevice; +typedef struct PCIExpressHost PCIExpressHost; +typedef struct PCIHostState PCIHostState; typedef struct PCMCIACardState PCMCIACardState; -typedef struct MouseTransformInfo MouseTransformInfo; -typedef struct uWireSlave uWireSlave; -typedef struct I2SCodec I2SCodec; -typedef struct SSIBus SSIBus; -typedef struct EventNotifier EventNotifier; -typedef struct VirtIODevice VirtIODevice; +typedef struct PixelFormat PixelFormat; +typedef struct PropertyInfo PropertyInfo; +typedef struct Property Property; +typedef struct QEMUBH QEMUBH; +typedef struct QemuConsole QemuConsole; +typedef struct QEMUFile QEMUFile; +typedef struct QEMUMachine QEMUMachine; typedef struct QEMUSGList QEMUSGList; typedef struct QEMUSizedBuffer QEMUSizedBuffer; -typedef struct SHPCDevice SHPCDevice; -typedef struct FWCfgState FWCfgState; -typedef struct PcGuestInfo PcGuestInfo; +typedef struct QEMUTimerListGroup QEMUTimerListGroup; +typedef struct QEMUTimer QEMUTimer; typedef struct Range Range; -typedef struct AdapterInfo AdapterInfo; +typedef struct SerialState SerialState; +typedef struct SHPCDevice SHPCDevice; +typedef struct SMBusDevice SMBusDevice; +typedef struct SSIBus SSIBus; +typedef struct uWireSlave uWireSlave; +typedef struct VirtIODevice VirtIODevice; +typedef struct Visitor Visitor; #endif /* QEMU_TYPEDEFS_H */ diff --git a/qapi-schema.json b/qapi-schema.json index 9ffdcf8e85..563b4ad98a 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1533,7 +1533,7 @@ # # Change the VNC server password. # -# @target: the new password to use with VNC authentication +# @password: the new password to use with VNC authentication # # Since: 1.1 # diff --git a/qemu-char.c b/qemu-char.c index a8b01da3ee..ef84b53681 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -3825,9 +3825,7 @@ void qemu_chr_delete(CharDriverState *chr) } g_free(chr->filename); g_free(chr->label); - if (chr->opts) { - qemu_opts_del(chr->opts); - } + qemu_opts_del(chr->opts); g_free(chr); } diff --git a/qmp-commands.hx b/qmp-commands.hx index d4b00101c7..33487820a4 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -3820,13 +3820,13 @@ Press left mouse button. -> { "execute": "x-input-send-event", "arguments": { "console": 0, "events": [ { "type": "btn", - "data" : { "down": true, "button": "Left" } } } } + "data" : { "down": true, "button": "Left" } } ] } } <- { "return": {} } -> { "execute": "x-input-send-event", "arguments": { "console": 0, "events": [ { "type": "btn", - "data" : { "down": false, "button": "Left" } } } } + "data" : { "down": false, "button": "Left" } } ] } } <- { "return": {} } Example (2): diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index af68c6c92d..f39630eb3d 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl @@ -23,7 +23,6 @@ my $email_usename = 1; my $email_maintainer = 1; my $email_list = 1; my $email_subscriber_list = 0; -my $email_git_penguin_chiefs = 0; my $email_git = 0; my $email_git_all_signature_types = 0; my $email_git_blame = 0; @@ -60,21 +59,6 @@ my $exit = 0; my %commit_author_hash; my %commit_signer_hash; -my @penguin_chief = (); -push(@penguin_chief, "Linus Torvalds:torvalds\@linux-foundation.org"); -#Andrew wants in on most everything - 2009/01/14 -#push(@penguin_chief, "Andrew Morton:akpm\@linux-foundation.org"); - -my @penguin_chief_names = (); -foreach my $chief (@penguin_chief) { - if ($chief =~ m/^(.*):(.*)/) { - my $chief_name = $1; - my $chief_addr = $2; - push(@penguin_chief_names, $chief_name); - } -} -my $penguin_chiefs = "\(" . join("|", @penguin_chief_names) . "\)"; - # Signature types of people who are either # a) responsible for the code in question, or # b) familiar enough with it to give relevant feedback @@ -187,7 +171,6 @@ if (!GetOptions( 'git-blame!' => \$email_git_blame, 'git-blame-signatures!' => \$email_git_blame_signatures, 'git-fallback!' => \$email_git_fallback, - 'git-chief-penguins!' => \$email_git_penguin_chiefs, 'git-min-signatures=i' => \$email_git_min_signatures, 'git-max-maintainers=i' => \$email_git_max_maintainers, 'git-min-percent=i' => \$email_git_min_percent, @@ -256,7 +239,7 @@ if ($sections) { if ($email && ($email_maintainer + $email_list + $email_subscriber_list + - $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) { + $email_git + $email_git_blame) == 0) { die "$P: Please select at least 1 email option\n"; } @@ -671,19 +654,6 @@ sub get_maintainers { } } - foreach my $chief (@penguin_chief) { - if ($chief =~ m/^(.*):(.*)/) { - my $email_address; - - $email_address = format_email($1, $2, $email_usename); - if ($email_git_penguin_chiefs) { - push(@email_to, [$email_address, 'chief penguin']); - } else { - @email_to = grep($_->[0] !~ /${email_address}/, @email_to); - } - } - } - foreach my $email (@file_emails) { my ($name, $address) = parse_email($email); @@ -740,7 +710,6 @@ MAINTAINER field selection options: --git-all-signature-types => include signers regardless of signature type or use only ${signature_pattern} signers (default: $email_git_all_signature_types) --git-fallback => use git when no exact MAINTAINERS pattern (default: $email_git_fallback) - --git-chief-penguins => include ${penguin_chiefs} --git-min-signatures => number of signatures required (default: $email_git_min_signatures) --git-max-maintainers => maximum maintainers to add (default: $email_git_max_maintainers) --git-min-percent => minimum percentage of commits required (default: $email_git_min_percent) @@ -1281,10 +1250,6 @@ sub vcs_find_signers { save_commits_by_author(@lines) if ($interactive); save_commits_by_signer(@lines) if ($interactive); - if (!$email_git_penguin_chiefs) { - @signatures = grep(!/${penguin_chiefs}/i, @signatures); - } - my ($types_ref, $signers_ref) = extract_formatted_signatures(@signatures); return ($commits, @$signers_ref); @@ -1296,10 +1261,6 @@ sub vcs_find_author { @lines = &{$VCS_cmds{"execute_cmd"}}($cmd); - if (!$email_git_penguin_chiefs) { - @lines = grep(!/${penguin_chiefs}/i, @lines); - } - return @lines if !@lines; my @authors = (); @@ -1925,10 +1886,6 @@ sub vcs_file_blame { @lines = &{$VCS_cmds{"execute_cmd"}}($cmd); - if (!$email_git_penguin_chiefs) { - @lines = grep(!/${penguin_chiefs}/i, @lines); - } - last if !@lines; my @authors = (); diff --git a/target-s390x/helper.c b/target-s390x/helper.c index 09aec7b42e..96a4f22734 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -648,7 +648,7 @@ static void do_ext_interrupt(CPUS390XState *env) cpu_abort(CPU(cpu), "Ext int w/o ext mask\n"); } - if (env->ext_index < 0 || env->ext_index > MAX_EXT_QUEUE) { + if (env->ext_index < 0 || env->ext_index >= MAX_EXT_QUEUE) { cpu_abort(CPU(cpu), "Ext queue overrun: %d\n", env->ext_index); } @@ -696,7 +696,7 @@ static void do_io_interrupt(CPUS390XState *env) if (env->io_index[isc] < 0) { continue; } - if (env->io_index[isc] > MAX_IO_QUEUE) { + if (env->io_index[isc] >= MAX_IO_QUEUE) { cpu_abort(CPU(cpu), "I/O queue overrun for isc %d: %d\n", isc, env->io_index[isc]); } @@ -754,7 +754,7 @@ static void do_mchk_interrupt(CPUS390XState *env) cpu_abort(CPU(cpu), "Machine check w/o mchk mask\n"); } - if (env->mchk_index < 0 || env->mchk_index > MAX_MCHK_QUEUE) { + if (env->mchk_index < 0 || env->mchk_index >= MAX_MCHK_QUEUE) { cpu_abort(CPU(cpu), "Mchk queue overrun: %d\n", env->mchk_index); } diff --git a/util/hbitmap.c b/util/hbitmap.c index b3060e6976..ab139717f5 100644 --- a/util/hbitmap.c +++ b/util/hbitmap.c @@ -373,7 +373,7 @@ void hbitmap_free(HBitmap *hb) HBitmap *hbitmap_alloc(uint64_t size, int granularity) { - HBitmap *hb = g_malloc0(sizeof (struct HBitmap)); + HBitmap *hb = g_new0(struct HBitmap, 1); unsigned i; assert(granularity >= 0 && granularity < 64); @@ -384,7 +384,7 @@ HBitmap *hbitmap_alloc(uint64_t size, int granularity) hb->granularity = granularity; for (i = HBITMAP_LEVELS; i-- > 0; ) { size = MAX((size + BITS_PER_LONG - 1) >> BITS_PER_LEVEL, 1); - hb->levels[i] = g_malloc0(size * sizeof(unsigned long)); + hb->levels[i] = g_new0(unsigned long, size); } /* We necessarily have free bits in level 0 due to the definition diff --git a/util/iov.c b/util/iov.c index 24566c8789..2fb18e6654 100644 --- a/util/iov.c +++ b/util/iov.c @@ -253,7 +253,7 @@ unsigned iov_copy(struct iovec *dst_iov, unsigned int dst_iov_cnt, void qemu_iovec_init(QEMUIOVector *qiov, int alloc_hint) { - qiov->iov = g_malloc(alloc_hint * sizeof(struct iovec)); + qiov->iov = g_new(struct iovec, alloc_hint); qiov->niov = 0; qiov->nalloc = alloc_hint; qiov->size = 0; @@ -277,7 +277,7 @@ void qemu_iovec_add(QEMUIOVector *qiov, void *base, size_t len) if (qiov->niov == qiov->nalloc) { qiov->nalloc = 2 * qiov->nalloc + 1; - qiov->iov = g_realloc(qiov->iov, qiov->nalloc * sizeof(struct iovec)); + qiov->iov = g_renew(struct iovec, qiov->iov, qiov->nalloc); } qiov->iov[qiov->niov].iov_base = base; qiov->iov[qiov->niov].iov_len = len; diff --git a/util/uri.c b/util/uri.c index e348c1768c..918d23516d 100644 --- a/util/uri.c +++ b/util/uri.c @@ -225,7 +225,7 @@ rfc3986_parse_scheme(URI *uri, const char **str) { while (ISA_ALPHA(cur) || ISA_DIGIT(cur) || (*cur == '+') || (*cur == '-') || (*cur == '.')) cur++; if (uri != NULL) { - if (uri->scheme != NULL) g_free(uri->scheme); + g_free(uri->scheme); uri->scheme = g_strndup(*str, cur - *str); } *str = cur; @@ -262,8 +262,7 @@ rfc3986_parse_fragment(URI *uri, const char **str) ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur)))) NEXT(cur); if (uri != NULL) { - if (uri->fragment != NULL) - g_free(uri->fragment); + g_free(uri->fragment); if (uri->cleanup & 2) uri->fragment = g_strndup(*str, cur - *str); else @@ -298,8 +297,7 @@ rfc3986_parse_query(URI *uri, const char **str) ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur)))) NEXT(cur); if (uri != NULL) { - if (uri->query != NULL) - g_free (uri->query); + g_free(uri->query); uri->query = g_strndup (*str, cur - *str); } *str = cur; @@ -360,7 +358,7 @@ rfc3986_parse_user_info(URI *uri, const char **str) NEXT(cur); if (*cur == '@') { if (uri != NULL) { - if (uri->user != NULL) g_free(uri->user); + g_free(uri->user); if (uri->cleanup & 2) uri->user = g_strndup(*str, cur - *str); else @@ -473,9 +471,9 @@ not_ipv4: NEXT(cur); found: if (uri != NULL) { - if (uri->authority != NULL) g_free(uri->authority); + g_free(uri->authority); uri->authority = NULL; - if (uri->server != NULL) g_free(uri->server); + g_free(uri->server); if (cur != host) { if (uri->cleanup & 2) uri->server = g_strndup(host, cur - host); @@ -585,7 +583,7 @@ rfc3986_parse_path_ab_empty(URI *uri, const char **str) if (ret != 0) return(ret); } if (uri != NULL) { - if (uri->path != NULL) g_free(uri->path); + g_free(uri->path); if (*str != cur) { if (uri->cleanup & 2) uri->path = g_strndup(*str, cur - *str); @@ -631,7 +629,7 @@ rfc3986_parse_path_absolute(URI *uri, const char **str) } } if (uri != NULL) { - if (uri->path != NULL) g_free(uri->path); + g_free(uri->path); if (cur != *str) { if (uri->cleanup & 2) uri->path = g_strndup(*str, cur - *str); @@ -673,7 +671,7 @@ rfc3986_parse_path_rootless(URI *uri, const char **str) if (ret != 0) return(ret); } if (uri != NULL) { - if (uri->path != NULL) g_free(uri->path); + g_free(uri->path); if (cur != *str) { if (uri->cleanup & 2) uri->path = g_strndup(*str, cur - *str); @@ -715,7 +713,7 @@ rfc3986_parse_path_no_scheme(URI *uri, const char **str) if (ret != 0) return(ret); } if (uri != NULL) { - if (uri->path != NULL) g_free(uri->path); + g_free(uri->path); if (cur != *str) { if (uri->cleanup & 2) uri->path = g_strndup(*str, cur - *str); @@ -769,7 +767,7 @@ rfc3986_parse_hier_part(URI *uri, const char **str) } else { /* path-empty is effectively empty */ if (uri != NULL) { - if (uri->path != NULL) g_free(uri->path); + g_free(uri->path); uri->path = NULL; } } @@ -812,7 +810,7 @@ rfc3986_parse_relative_ref(URI *uri, const char *str) { } else { /* path-empty is effectively empty */ if (uri != NULL) { - if (uri->path != NULL) g_free(uri->path); + g_free(uri->path); uri->path = NULL; } } @@ -1006,8 +1004,7 @@ URI * uri_new(void) { URI *ret; - ret = (URI *) g_malloc(sizeof(URI)); - memset(ret, 0, sizeof(URI)); + ret = g_new0(URI, 1); return(ret); } @@ -1285,21 +1282,21 @@ static void uri_clean(URI *uri) { if (uri == NULL) return; - if (uri->scheme != NULL) g_free(uri->scheme); + g_free(uri->scheme); uri->scheme = NULL; - if (uri->server != NULL) g_free(uri->server); + g_free(uri->server); uri->server = NULL; - if (uri->user != NULL) g_free(uri->user); + g_free(uri->user); uri->user = NULL; - if (uri->path != NULL) g_free(uri->path); + g_free(uri->path); uri->path = NULL; - if (uri->fragment != NULL) g_free(uri->fragment); + g_free(uri->fragment); uri->fragment = NULL; - if (uri->opaque != NULL) g_free(uri->opaque); + g_free(uri->opaque); uri->opaque = NULL; - if (uri->authority != NULL) g_free(uri->authority); + g_free(uri->authority); uri->authority = NULL; - if (uri->query != NULL) g_free(uri->query); + g_free(uri->query); uri->query = NULL; } @@ -1711,10 +1708,8 @@ uri_resolve(const char *uri, const char *base) { /* * the base fragment must be ignored */ - if (bas->fragment != NULL) { - g_free(bas->fragment); - bas->fragment = NULL; - } + g_free(bas->fragment); + bas->fragment = NULL; val = uri_to_string(bas); goto done; } @@ -1736,24 +1731,21 @@ uri_resolve(const char *uri, const char *base) { goto done; if ((ref->scheme == NULL) && (ref->path == NULL) && ((ref->authority == NULL) && (ref->server == NULL))) { - if (bas->scheme != NULL) - res->scheme = g_strdup(bas->scheme); + res->scheme = g_strdup(bas->scheme); if (bas->authority != NULL) res->authority = g_strdup(bas->authority); else if (bas->server != NULL) { - res->server = g_strdup(bas->server); - if (bas->user != NULL) - res->user = g_strdup(bas->user); - res->port = bas->port; + res->server = g_strdup(bas->server); + res->user = g_strdup(bas->user); + res->port = bas->port; } - if (bas->path != NULL) - res->path = g_strdup(bas->path); - if (ref->query != NULL) + res->path = g_strdup(bas->path); + if (ref->query != NULL) { res->query = g_strdup (ref->query); - else if (bas->query != NULL) - res->query = g_strdup(bas->query); - if (ref->fragment != NULL) - res->fragment = g_strdup(ref->fragment); + } else { + res->query = g_strdup(bas->query); + } + res->fragment = g_strdup(ref->fragment); goto step_7; } @@ -1767,13 +1759,10 @@ uri_resolve(const char *uri, const char *base) { val = uri_to_string(ref); goto done; } - if (bas->scheme != NULL) - res->scheme = g_strdup(bas->scheme); + res->scheme = g_strdup(bas->scheme); - if (ref->query != NULL) - res->query = g_strdup(ref->query); - if (ref->fragment != NULL) - res->fragment = g_strdup(ref->fragment); + res->query = g_strdup(ref->query); + res->fragment = g_strdup(ref->fragment); /* * 4) If the authority component is defined, then the reference is a @@ -1787,20 +1776,17 @@ uri_resolve(const char *uri, const char *base) { res->authority = g_strdup(ref->authority); else { res->server = g_strdup(ref->server); - if (ref->user != NULL) - res->user = g_strdup(ref->user); + res->user = g_strdup(ref->user); res->port = ref->port; } - if (ref->path != NULL) - res->path = g_strdup(ref->path); + res->path = g_strdup(ref->path); goto step_7; } if (bas->authority != NULL) res->authority = g_strdup(bas->authority); else if (bas->server != NULL) { - res->server = g_strdup(bas->server); - if (bas->user != NULL) - res->user = g_strdup(bas->user); + res->server = g_strdup(bas->server); + res->user = g_strdup(bas->user); res->port = bas->port; } |