* [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups
@ 2015-08-26 11:17 Daniel P. Berrange
2015-08-26 11:17 ` [Qemu-devel] [PATCH 1/7] maint: remove double semicolons in many files Daniel P. Berrange
` (8 more replies)
0 siblings, 9 replies; 16+ messages in thread
From: Daniel P. Berrange @ 2015-08-26 11:17 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
This is a series of misc trivial code cleanups that I
originally used to illustrate the use of GNULIB's
syntax-check facility:
http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg06268.html
Since it appears the license of the GNULIB syntax-check
is problematic, this series has separated the fixes out
from the GNULIB additions, to allow for possibility of
merging them as-is.
Daniel P. Berrange (7):
maint: remove double semicolons in many files
maint: remove / fix many doubled words
maint: remove unused include for assert.h
maint: remove unused include for dirent.h
maint: remove unused include for signal.h
maint: remove unused include for strings.h
maint: avoid useless "if (foo) free(foo)" pattern
backends/hostmem-file.c | 4 +---
block/qcow2-cluster.c | 4 ++--
block/qcow2-refcount.c | 2 +-
block/vhdx.c | 2 +-
bsd-user/elfload.c | 4 +---
bsd-user/signal.c | 1 -
disas/ia64.c | 1 -
disas/microblaze.c | 1 -
disas/sparc.c | 3 +--
docs/libcacard.txt | 4 ++--
docs/multiseat.txt | 2 +-
docs/specs/qcow2.txt | 2 +-
docs/specs/rocker.txt | 2 +-
fsdev/virtio-9p-marshal.c | 1 -
hw/arm/vexpress.c | 4 ++--
hw/block/xen_disk.c | 1 -
hw/bt/hci.c | 9 +++------
hw/core/loader.c | 3 +--
hw/core/qdev-properties.c | 4 +---
hw/display/exynos4210_fimd.c | 4 +---
hw/i386/xen/xen_platform.c | 2 --
hw/intc/arm_gic.c | 2 +-
hw/mips/mips_r4k.c | 4 +---
hw/net/fsl_etsec/rings.c | 4 +---
hw/net/rocker/rocker.c | 4 +---
hw/net/rocker/rocker_desc.c | 8 ++------
hw/net/rtl8139.c | 2 +-
hw/net/xen_nic.c | 1 -
hw/nvram/fw_cfg.c | 4 +---
hw/pci-host/prep.c | 4 +---
hw/pci/shpc.c | 1 -
hw/sd/sd.c | 3 +--
hw/tpm/tpm_passthrough.c | 2 --
hw/usb/hcd-xhci.c | 4 +---
hw/usb/host-libusb.c | 2 +-
hw/usb/redirect.c | 2 --
hw/vfio/common.c | 2 +-
hw/vfio/pci.c | 1 -
hw/xen/xen_pt_config_init.c | 4 +---
include/block/block.h | 2 +-
include/exec/memory.h | 2 +-
linux-user/elfload.c | 2 +-
linux-user/signal.c | 1 -
migration/rdma.c | 2 +-
migration/savevm.c | 8 ++------
numa.c | 2 +-
os-win32.c | 1 -
page_cache.c | 1 -
qemu-char.c | 5 +----
qemu-doc.texi | 2 +-
qemu-img.texi | 2 +-
qemu-options.hx | 2 +-
qga/commands-win32.c | 2 +-
target-arm/cpu.h | 4 ++--
target-arm/helper.c | 2 +-
target-arm/translate.c | 2 +-
target-i386/translate.c | 1 -
target-lm32/helper.c | 2 +-
target-microblaze/op_helper.c | 1 -
target-microblaze/translate.c | 2 +-
target-mips/helper.c | 1 -
target-moxie/helper.c | 3 +--
target-moxie/translate.c | 1 -
target-sh4/helper.c | 1 -
target-sh4/op_helper.c | 1 -
target-tricore/helper.c | 1 -
tests/bios-tables-test.c | 36 +++++++++++++-----------------------
tests/tcg/testthread.c | 1 -
tests/test-xbzrle.c | 2 --
ui/spice-display.c | 14 ++++----------
util/bitmap.c | 2 +-
71 files changed, 71 insertions(+), 154 deletions(-)
--
2.4.3
^ permalink raw reply [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 1/7] maint: remove double semicolons in many files
2015-08-26 11:17 [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups Daniel P. Berrange
@ 2015-08-26 11:17 ` Daniel P. Berrange
2015-08-26 11:29 ` Marc-André Lureau
2015-08-26 11:17 ` [Qemu-devel] [PATCH 2/7] maint: remove / fix many doubled words Daniel P. Berrange
` (7 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: Daniel P. Berrange @ 2015-08-26 11:17 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
A number of source files have statements accidentally
terminated by a double semicolon - eg 'foo = bar;;'.
This is harmless but a mistake none the less.
The tcg/ia64/tcg-target.c file is whitelisted because
it has valid use of ';;' in a comment containing assembly
code.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
block/vhdx.c | 2 +-
hw/arm/vexpress.c | 4 ++--
hw/intc/arm_gic.c | 2 +-
numa.c | 2 +-
qga/commands-win32.c | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/block/vhdx.c b/block/vhdx.c
index 0776de7..f05c7a9 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -1454,7 +1454,7 @@ static int vhdx_create_new_metadata(BlockDriverState *bs,
uint32_t offset = 0;
void *buffer = NULL;
void *entry_buffer;
- VHDXMetadataTableHeader *md_table;;
+ VHDXMetadataTableHeader *md_table;
VHDXMetadataTableEntry *md_table_entry;
/* Metadata entries */
diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index da21788..0f8bf1c 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -541,7 +541,7 @@ static void vexpress_common_init(MachineState *machine)
{
VexpressMachineState *vms = VEXPRESS_MACHINE(machine);
VexpressMachineClass *vmc = VEXPRESS_MACHINE_GET_CLASS(machine);
- VEDBoardInfo *daughterboard = vmc->daughterboard;;
+ VEDBoardInfo *daughterboard = vmc->daughterboard;
DeviceState *dev, *sysctl, *pl041;
qemu_irq pic[64];
uint32_t sys_id;
@@ -762,7 +762,7 @@ static void vexpress_a9_class_init(ObjectClass *oc, void *data)
mc->name = TYPE_VEXPRESS_A9_MACHINE;
mc->desc = "ARM Versatile Express for Cortex-A9";
- vmc->daughterboard = &a9_daughterboard;;
+ vmc->daughterboard = &a9_daughterboard;
}
static void vexpress_a15_class_init(ObjectClass *oc, void *data)
diff --git a/hw/intc/arm_gic.c b/hw/intc/arm_gic.c
index a8c5d19..46ebc3f 100644
--- a/hw/intc/arm_gic.c
+++ b/hw/intc/arm_gic.c
@@ -239,7 +239,7 @@ uint32_t gic_acknowledge_irq(GICState *s, int cpu, MemTxAttrs attrs)
* for the case where this GIC supports grouping and the pending interrupt
* is in the wrong group.
*/
- irq = gic_get_current_pending_irq(s, cpu, attrs);;
+ irq = gic_get_current_pending_irq(s, cpu, attrs);
if (irq >= GIC_MAXIRQ) {
DPRINTF("ACK, no pending interrupt or it is hidden: %d\n", irq);
diff --git a/numa.c b/numa.c
index 402804b..eed8f5d 100644
--- a/numa.c
+++ b/numa.c
@@ -280,7 +280,7 @@ static void validate_numa_cpus(void)
bitmap_and(seen_cpus, seen_cpus,
numa_info[i].node_cpu, MAX_CPUMASK_BITS);
error_report("CPU(s) present in multiple NUMA nodes: %s",
- enumerate_cpus(seen_cpus, max_cpus));;
+ enumerate_cpus(seen_cpus, max_cpus));
exit(EXIT_FAILURE);
}
bitmap_or(seen_cpus, seen_cpus,
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index a7822d5..203664c 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -657,7 +657,7 @@ static GuestFilesystemInfo *build_guest_fsinfo(char *guid, Error **errp)
fs->mountpoint = g_strndup(mnt_point, len);
}
fs->type = g_strdup(fs_name);
- fs->disk = build_guest_disk_info(guid, errp);;
+ fs->disk = build_guest_disk_info(guid, errp);
free:
g_free(mnt_point);
return fs;
--
2.4.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 2/7] maint: remove / fix many doubled words
2015-08-26 11:17 [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups Daniel P. Berrange
2015-08-26 11:17 ` [Qemu-devel] [PATCH 1/7] maint: remove double semicolons in many files Daniel P. Berrange
@ 2015-08-26 11:17 ` Daniel P. Berrange
2015-08-26 11:31 ` Marc-André Lureau
2015-08-26 11:17 ` [Qemu-devel] [PATCH 3/7] maint: remove unused include for assert.h Daniel P. Berrange
` (6 subsequent siblings)
8 siblings, 1 reply; 16+ messages in thread
From: Daniel P. Berrange @ 2015-08-26 11:17 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
Many source files have doubled words (eg "the the", "to to",
and so on). Most of these can simply be removed, but a couple
were actual mis-spellings (eg "to to" instead of "to do").
There was even one triple word score "to to to" :-)
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
block/qcow2-cluster.c | 4 ++--
block/qcow2-refcount.c | 2 +-
docs/libcacard.txt | 4 ++--
docs/multiseat.txt | 2 +-
docs/specs/qcow2.txt | 2 +-
docs/specs/rocker.txt | 2 +-
hw/net/rtl8139.c | 2 +-
hw/usb/host-libusb.c | 2 +-
hw/vfio/common.c | 2 +-
include/block/block.h | 2 +-
include/exec/memory.h | 2 +-
linux-user/elfload.c | 2 +-
migration/rdma.c | 2 +-
qemu-doc.texi | 2 +-
qemu-img.texi | 2 +-
qemu-options.hx | 2 +-
target-arm/cpu.h | 4 ++--
target-arm/helper.c | 2 +-
target-arm/translate.c | 2 +-
target-lm32/helper.c | 2 +-
target-microblaze/translate.c | 2 +-
target-moxie/helper.c | 2 +-
util/bitmap.c | 2 +-
23 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index b43f186..61309ae 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -498,7 +498,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t offset,
*cluster_offset = 0;
- /* seek the the l2 offset in the l1 table */
+ /* seek to the l2 offset in the l1 table */
l1_index = offset >> l1_bits;
if (l1_index >= s->l1_size) {
@@ -612,7 +612,7 @@ static int get_cluster_table(BlockDriverState *bs, uint64_t offset,
uint64_t *l2_table = NULL;
int ret;
- /* seek the the l2 offset in the l1 table */
+ /* seek to the l2 offset in the l1 table */
l1_index = offset >> (s->l2_bits + s->cluster_bits);
if (l1_index >= s->l1_size) {
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index b0ee42d..d8f0645 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -1294,7 +1294,7 @@ static int realloc_refcount_array(BDRVQcowState *s, void **array,
/*
* Increases the refcount for a range of clusters in a given refcount table.
* This is used to construct a temporary refcount table out of L1 and L2 tables
- * which can be compared the the refcount table saved in the image.
+ * which can be compared to the refcount table saved in the image.
*
* Modifies the number of errors in res.
*/
diff --git a/docs/libcacard.txt b/docs/libcacard.txt
index 8db421d..499cf7d 100644
--- a/docs/libcacard.txt
+++ b/docs/libcacard.txt
@@ -327,7 +327,7 @@ and applet.
int vcard_emul_get_login_count(VCard *card);
- This function returns the the number of remaining login attempts for this
+ This function returns the number of remaining login attempts for this
card. If the card emulator does not know, or the card does not have a
way of giving this information, this function returns -1.
@@ -421,7 +421,7 @@ functions:
The vcard is the value returned from vcard_new. The type is the
card type emulator that this card should presented to the guest as.
The flags are card type emulator specific options. The certs,
- cert_len, and keys are all arrays of length cert_count. These are the
+ cert_len, and keys are all arrays of length cert_count. These are
the same of the parameters xxxx_card_init() accepts.
Finally the card is associated with its reader by the call:
diff --git a/docs/multiseat.txt b/docs/multiseat.txt
index ebf2446..807518c 100644
--- a/docs/multiseat.txt
+++ b/docs/multiseat.txt
@@ -135,7 +135,7 @@ configuration:
TAG+="seat", ENV{ID_AUTOSEAT}="1"
Patch with this rule has been submitted to upstream udev/systemd, was
-accepted and and should be included in the next systemd release (222).
+accepted and should be included in the next systemd release (222).
So, if your guest has this or a newer version, multiseat will work just
fine without any manual guest configuration.
diff --git a/docs/specs/qcow2.txt b/docs/specs/qcow2.txt
index 121dfc8..f236d8c 100644
--- a/docs/specs/qcow2.txt
+++ b/docs/specs/qcow2.txt
@@ -257,7 +257,7 @@ L2 table entry:
63: 0 for a cluster that is unused or requires COW, 1 if its
refcount is exactly one. This information is only accurate
- in L2 tables that are reachable from the the active L1
+ in L2 tables that are reachable from the active L1
table.
Standard Cluster Descriptor:
diff --git a/docs/specs/rocker.txt b/docs/specs/rocker.txt
index 1c74351..d2a8262 100644
--- a/docs/specs/rocker.txt
+++ b/docs/specs/rocker.txt
@@ -297,7 +297,7 @@ but not fired. If only partial credits are returned, the interrupt remains
masked but the device generates an interrupt, signaling the driver that more
outstanding work is available.
-(* this masking is unrelated to to the MSI-X interrupt mask register)
+(* this masking is unrelated to the MSI-X interrupt mask register)
Endianness
----------
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index edbb61c..78ae4cd 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -43,7 +43,7 @@
* Added rx/tx buffer reset when enabling rx/tx operation
*
* 2010-Feb-04 Frediano Ziglio: Rewrote timer support using QEMU timer only
- * when strictly needed (required for for
+ * when strictly needed (required for
* Darwin)
* 2011-Mar-22 Benjamin Poirier: Implemented VLAN offloading
*/
diff --git a/hw/usb/host-libusb.c b/hw/usb/host-libusb.c
index 11429f5..5e492fd 100644
--- a/hw/usb/host-libusb.c
+++ b/hw/usb/host-libusb.c
@@ -1429,7 +1429,7 @@ static void usb_host_free_streams(USBDevice *udev, USBEndpoint **eps,
* still present in the first place. Attemping to contine where we
* left off is impossible.
*
- * What we are going to to to here is emulate a surprise removal of
+ * What we are going to do here is emulate a surprise removal of
* the usb device passed through, then kick host scan so the device
* will get re-attached (and re-initialized by the guest) in case it
* is still present.
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 85ee9b0..6d21311 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -226,7 +226,7 @@ static int vfio_dma_map(VFIOContainer *container, hwaddr iova,
/*
* Try the mapping, if it fails with EBUSY, unmap the region and try
* again. This shouldn't be necessary, but we sometimes see it in
- * the the VGA ROM space.
+ * the VGA ROM space.
*/
if (ioctl(container->fd, VFIO_IOMMU_MAP_DMA, &map) == 0 ||
(errno == EBUSY && vfio_dma_unmap(container, iova, size) == 0 &&
diff --git a/include/block/block.h b/include/block/block.h
index 37916f7..fe4fcc8 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -23,7 +23,7 @@ typedef struct BlockDriverInfo {
bool is_dirty;
/*
* True if unallocated blocks read back as zeroes. This is equivalent
- * to the the LBPRZ flag in the SCSI logical block provisioning page.
+ * to the LBPRZ flag in the SCSI logical block provisioning page.
*/
bool unallocated_blocks_are_zero;
/*
diff --git a/include/exec/memory.h b/include/exec/memory.h
index b18b351..6a5fc9c 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -324,7 +324,7 @@ void memory_region_unref(MemoryRegion *mr);
* @owner: the object that tracks the region's reference count
* @ops: a structure containing read and write callbacks to be used when
* I/O is performed on the region.
- * @opaque: passed to to the read and write callbacks of the @ops structure.
+ * @opaque: passed to the read and write callbacks of the @ops structure.
* @name: used for debugging; not visible to the user or ABI
* @size: size of the region.
*/
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 1788368..b0a98d5 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -3016,7 +3016,7 @@ static int elf_core_dump(int signr, const CPUArchState *env)
if (dump_write(fd, &elf, sizeof (elf)) != 0)
goto out;
- /* fill in in-memory version of notes */
+ /* fill in the in-memory version of notes */
if (fill_note_info(&info, signr, env) < 0)
goto out;
diff --git a/migration/rdma.c b/migration/rdma.c
index 74876fd..9424834 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -778,7 +778,7 @@ static void qemu_rdma_dump_gid(const char *who, struct rdma_cm_id *id)
*
* If the source VM connects with an IPv4 address without knowing that the
* destination has bound to '[::]' the migration will unconditionally fail
- * unless the management software is explicitly listening on the the IPv4
+ * unless the management software is explicitly listening on the IPv4
* address while using a RoCE-based device.
*
* If the source VM connects with an IPv6 address, then we're OK because we can
diff --git a/qemu-doc.texi b/qemu-doc.texi
index 94af8c0..ed0c755 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -1766,7 +1766,7 @@ Use @code{set architecture i8086} to dump 16 bit code. Then use
Advanced debugging options:
-The default single stepping behavior is step with the IRQs and timer service routines off. It is set this way because when gdb executes a single step it expects to advance beyond the current instruction. With the IRQs and and timer service routines on, a single step might jump into the one of the interrupt or exception vectors instead of executing the current instruction. This means you may hit the same breakpoint a number of times before executing the instruction gdb wants to have executed. Because there are rare circumstances where you want to single step into an interrupt vector the behavior can be controlled from GDB. There are three commands you can query and set the single step behavior:
+The default single stepping behavior is step with the IRQs and timer service routines off. It is set this way because when gdb executes a single step it expects to advance beyond the current instruction. With the IRQs and timer service routines on, a single step might jump into the one of the interrupt or exception vectors instead of executing the current instruction. This means you may hit the same breakpoint a number of times before executing the instruction gdb wants to have executed. Because there are rare circumstances where you want to single step into an interrupt vector the behavior can be controlled from GDB. There are three commands you can query and set the single step behavior:
@table @code
@item maintenance packet qqemu.sstepbits
diff --git a/qemu-img.texi b/qemu-img.texi
index 0a1ab35..55c6be3 100644
--- a/qemu-img.texi
+++ b/qemu-img.texi
@@ -103,7 +103,7 @@ First image format
@item -F
Second image format
@item -s
-Strict mode - fail on on different image size or sector allocation
+Strict mode - fail on different image size or sector allocation
@end table
Parameters to convert subcommand:
diff --git a/qemu-options.hx b/qemu-options.hx
index 77f5853..369ba26 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -3147,7 +3147,7 @@ provide cycle accurate emulation. Modern CPUs contain superscalar out of
order cores with complex cache hierarchies. The number of instructions
executed often has little or no correlation with actual performance.
-@option{align=on} will activate the delay algorithm which will try to
+@option{align=on} will activate the delay algorithm which will try
to synchronise the host clock and the virtual clock. The goal is to
have a guest running at the real frequency imposed by the shift option.
Whenever the guest clock is behind the host clock and if
diff --git a/target-arm/cpu.h b/target-arm/cpu.h
index 2e680da..74f1379 100644
--- a/target-arm/cpu.h
+++ b/target-arm/cpu.h
@@ -172,7 +172,7 @@ typedef struct CPUARMState {
uint32_t GE; /* cpsr[19:16] */
uint32_t thumb; /* cpsr[5]. 0 = arm mode, 1 = thumb mode. */
uint32_t condexec_bits; /* IT bits. cpsr[15:10,26:25]. */
- uint64_t daif; /* exception masks, in the bits they are in in PSTATE */
+ uint64_t daif; /* exception masks, in the bits they are in PSTATE */
uint64_t elr_el[4]; /* AArch64 exception link regs */
uint64_t sp_el[4]; /* AArch64 banked stack pointers */
@@ -1484,7 +1484,7 @@ bool write_list_to_cpustate(ARMCPU *cpu);
*/
bool write_cpustate_to_list(ARMCPU *cpu);
-/* Does the core conform to the the "MicroController" profile. e.g. Cortex-M3.
+/* Does the core conform to the "MicroController" profile. e.g. Cortex-M3.
Note the M in older cores (eg. ARM7TDMI) stands for Multiply. These are
conventional cores (ie. Application or Realtime profile). */
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 1568aa6..04f04a1 100644
--- a/target-arm/helper.c
+++ b/target-arm/helper.c
@@ -2094,7 +2094,7 @@ static void vmsa_ttbcr_raw_write(CPUARMState *env, const ARMCPRegInfo *ri,
}
}
- /* Update the masks corresponding to the the TCR bank being written
+ /* Update the masks corresponding to the TCR bank being written
* Note that we always calculate mask and base_mask, but
* they are only used for short-descriptor tables (ie if EAE is 0);
* for long-descriptor tables the TCR fields are used differently
diff --git a/target-arm/translate.c b/target-arm/translate.c
index 69ac18c..6a3de30 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -8500,7 +8500,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn)
}
/* Perform base writeback before the loaded value to
ensure correct behavior with overlapping index registers.
- ldrd with base writeback is is undefined if the
+ ldrd with base writeback is undefined if the
destination and index registers overlap. */
if (!(insn & (1 << 24))) {
gen_add_datah_offset(s, insn, address_offset, addr);
diff --git a/target-lm32/helper.c b/target-lm32/helper.c
index a88aa5a..e26c133 100644
--- a/target-lm32/helper.c
+++ b/target-lm32/helper.c
@@ -81,7 +81,7 @@ void lm32_watchpoint_insert(CPULM32State *env, int idx, target_ulong address,
switch (wp_type) {
case LM32_WP_DISABLED:
- /* nothing to to */
+ /* nothing to do */
break;
case LM32_WP_READ:
flags = BP_CPU | BP_STOP_BEFORE_ACCESS | BP_MEM_READ;
diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c
index f4e969b..e566401 100644
--- a/target-microblaze/translate.c
+++ b/target-microblaze/translate.c
@@ -1027,7 +1027,7 @@ static void dec_load(DisasContext *dc)
tcg_temp_free(v);
if (ex) { /* lwx */
- /* no support for for AXI exclusive so always clear C */
+ /* no support for AXI exclusive so always clear C */
write_carryi(dc, 0);
}
diff --git a/target-moxie/helper.c b/target-moxie/helper.c
index 6c98965..f21e884 100644
--- a/target-moxie/helper.c
+++ b/target-moxie/helper.c
@@ -56,7 +56,7 @@ void helper_raise_exception(CPUMoxieState *env, int ex)
/* Stash the address where the exception occurred. */
cpu_restore_state(cs, GETPC());
env->sregs[5] = env->pc;
- /* Jump the the exception handline routine. */
+ /* Jump to the exception handline routine. */
env->pc = env->sregs[1];
cpu_loop_exit(cs);
}
diff --git a/util/bitmap.c b/util/bitmap.c
index 300a68e..44f0f48 100644
--- a/util/bitmap.c
+++ b/util/bitmap.c
@@ -14,7 +14,7 @@
#include "qemu/atomic.h"
/*
- * bitmaps provide an array of bits, implemented using an an
+ * bitmaps provide an array of bits, implemented using an
* array of unsigned longs. The number of valid bits in a
* given bitmap does _not_ need to be an exact multiple of
* BITS_PER_LONG.
--
2.4.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 3/7] maint: remove unused include for assert.h
2015-08-26 11:17 [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups Daniel P. Berrange
2015-08-26 11:17 ` [Qemu-devel] [PATCH 1/7] maint: remove double semicolons in many files Daniel P. Berrange
2015-08-26 11:17 ` [Qemu-devel] [PATCH 2/7] maint: remove / fix many doubled words Daniel P. Berrange
@ 2015-08-26 11:17 ` Daniel P. Berrange
2015-08-26 11:17 ` [Qemu-devel] [PATCH 4/7] maint: remove unused include for dirent.h Daniel P. Berrange
` (5 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Daniel P. Berrange @ 2015-08-26 11:17 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
A number of files were including assert.h but not using any
of the functions it provides
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
disas/ia64.c | 1 -
hw/i386/xen/xen_platform.c | 2 --
linux-user/signal.c | 1 -
target-microblaze/op_helper.c | 1 -
target-moxie/helper.c | 1 -
target-moxie/translate.c | 1 -
target-sh4/op_helper.c | 1 -
tests/test-xbzrle.c | 1 -
8 files changed, 9 deletions(-)
diff --git a/disas/ia64.c b/disas/ia64.c
index a8fe26c..d7c7bdf 100644
--- a/disas/ia64.c
+++ b/disas/ia64.c
@@ -18,7 +18,6 @@
along with this file; see the file COPYING. If not, see
<http://www.gnu.org/licenses/>. */
-#include <assert.h>
#include <string.h>
#include "disas/bfd.h"
diff --git a/hw/i386/xen/xen_platform.c b/hw/i386/xen/xen_platform.c
index 28b324a..ee45f03 100644
--- a/hw/i386/xen/xen_platform.c
+++ b/hw/i386/xen/xen_platform.c
@@ -23,8 +23,6 @@
* THE SOFTWARE.
*/
-#include <assert.h>
-
#include "hw/hw.h"
#include "hw/i386/pc.h"
#include "hw/ide.h"
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 9d4cef4..502efd9 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -22,7 +22,6 @@
#include <stdarg.h>
#include <unistd.h>
#include <errno.h>
-#include <assert.h>
#include <sys/ucontext.h>
#include <sys/resource.h>
diff --git a/target-microblaze/op_helper.c b/target-microblaze/op_helper.c
index d2b3624..092c4b5 100644
--- a/target-microblaze/op_helper.c
+++ b/target-microblaze/op_helper.c
@@ -18,7 +18,6 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <assert.h>
#include "cpu.h"
#include "exec/helper-proto.h"
#include "qemu/host-utils.h"
diff --git a/target-moxie/helper.c b/target-moxie/helper.c
index f21e884..f91ac28 100644
--- a/target-moxie/helper.c
+++ b/target-moxie/helper.c
@@ -19,7 +19,6 @@
#include <stdio.h>
#include <string.h>
-#include <assert.h>
#include "config.h"
#include "cpu.h"
diff --git a/target-moxie/translate.c b/target-moxie/translate.c
index e3e9139..cc77366 100644
--- a/target-moxie/translate.c
+++ b/target-moxie/translate.c
@@ -26,7 +26,6 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
-#include <assert.h>
#include "cpu.h"
#include "exec/exec-all.h"
diff --git a/target-sh4/op_helper.c b/target-sh4/op_helper.c
index cbc11ae..a312118 100644
--- a/target-sh4/op_helper.c
+++ b/target-sh4/op_helper.c
@@ -16,7 +16,6 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-#include <assert.h>
#include <stdlib.h>
#include "cpu.h"
#include "exec/helper-proto.h"
diff --git a/tests/test-xbzrle.c b/tests/test-xbzrle.c
index db93b0a..b5ee8bb 100644
--- a/tests/test-xbzrle.c
+++ b/tests/test-xbzrle.c
@@ -16,7 +16,6 @@
#include <strings.h>
#include <string.h>
#include <sys/time.h>
-#include <assert.h>
#include "qemu-common.h"
#include "include/migration/migration.h"
--
2.4.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 4/7] maint: remove unused include for dirent.h
2015-08-26 11:17 [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups Daniel P. Berrange
` (2 preceding siblings ...)
2015-08-26 11:17 ` [Qemu-devel] [PATCH 3/7] maint: remove unused include for assert.h Daniel P. Berrange
@ 2015-08-26 11:17 ` Daniel P. Berrange
2015-08-26 11:17 ` [Qemu-devel] [PATCH 5/7] maint: remove unused include for signal.h Daniel P. Berrange
` (4 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Daniel P. Berrange @ 2015-08-26 11:17 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
A number of files were including dirent.h but not using any
of the functions it provides
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
fsdev/virtio-9p-marshal.c | 1 -
hw/tpm/tpm_passthrough.c | 2 --
hw/usb/redirect.c | 1 -
hw/vfio/pci.c | 1 -
qemu-char.c | 1 -
5 files changed, 6 deletions(-)
diff --git a/fsdev/virtio-9p-marshal.c b/fsdev/virtio-9p-marshal.c
index 20f308b..7748d32 100644
--- a/fsdev/virtio-9p-marshal.c
+++ b/fsdev/virtio-9p-marshal.c
@@ -14,7 +14,6 @@
#include <glib.h>
#include <glib/gprintf.h>
#include <sys/types.h>
-#include <dirent.h>
#include <sys/time.h>
#include <utime.h>
#include <sys/uio.h>
diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c
index 79a8f98..be160c1 100644
--- a/hw/tpm/tpm_passthrough.c
+++ b/hw/tpm/tpm_passthrough.c
@@ -22,8 +22,6 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>
*/
-#include <dirent.h>
-
#include "qemu-common.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 25df25f..34cf60d 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -33,7 +33,6 @@
#include "qemu/iov.h"
#include "sysemu/char.h"
-#include <dirent.h>
#include <sys/ioctl.h>
#include <signal.h>
#include <usbredirparser.h>
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 4023d8e..5d02099 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -18,7 +18,6 @@
* Copyright (C) 2008, IBM, Muli Ben-Yehuda (muli@il.ibm.com)
*/
-#include <dirent.h>
#include <linux/vfio.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
diff --git a/qemu-char.c b/qemu-char.c
index d956f8d..fa65159 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -51,7 +51,6 @@
#include <netinet/in.h>
#include <net/if.h>
#include <arpa/inet.h>
-#include <dirent.h>
#include <netdb.h>
#include <sys/select.h>
#ifdef CONFIG_BSD
--
2.4.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 5/7] maint: remove unused include for signal.h
2015-08-26 11:17 [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups Daniel P. Berrange
` (3 preceding siblings ...)
2015-08-26 11:17 ` [Qemu-devel] [PATCH 4/7] maint: remove unused include for dirent.h Daniel P. Berrange
@ 2015-08-26 11:17 ` Daniel P. Berrange
2015-08-26 11:17 ` [Qemu-devel] [PATCH 6/7] maint: remove unused include for strings.h Daniel P. Berrange
` (3 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Daniel P. Berrange @ 2015-08-26 11:17 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
A number of files were including signal.h but not using any
of the functions it provides
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
bsd-user/signal.c | 1 -
hw/block/xen_disk.c | 1 -
hw/net/xen_nic.c | 1 -
hw/usb/redirect.c | 1 -
os-win32.c | 1 -
target-i386/translate.c | 1 -
target-mips/helper.c | 1 -
target-sh4/helper.c | 1 -
target-tricore/helper.c | 1 -
tests/tcg/testthread.c | 1 -
10 files changed, 10 deletions(-)
diff --git a/bsd-user/signal.c b/bsd-user/signal.c
index 445f69e..e4ee2d0 100644
--- a/bsd-user/signal.c
+++ b/bsd-user/signal.c
@@ -21,7 +21,6 @@
#include <string.h>
#include <stdarg.h>
#include <unistd.h>
-#include <signal.h>
#include <errno.h>
#include "qemu.h"
diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index 267d8a8..36d7398 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -24,7 +24,6 @@
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
-#include <signal.h>
#include <inttypes.h>
#include <time.h>
#include <fcntl.h>
diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c
index d7cbfc1..0da16b4 100644
--- a/hw/net/xen_nic.c
+++ b/hw/net/xen_nic.c
@@ -24,7 +24,6 @@
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
-#include <signal.h>
#include <inttypes.h>
#include <fcntl.h>
#include <errno.h>
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 34cf60d..38086cd 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -34,7 +34,6 @@
#include "sysemu/char.h"
#include <sys/ioctl.h>
-#include <signal.h>
#include <usbredirparser.h>
#include <usbredirfilter.h>
diff --git a/os-win32.c b/os-win32.c
index c0daf8e..cc09196 100644
--- a/os-win32.c
+++ b/os-win32.c
@@ -26,7 +26,6 @@
#include <mmsystem.h>
#include <unistd.h>
#include <fcntl.h>
-#include <signal.h>
#include <time.h>
#include <errno.h>
#include <sys/time.h>
diff --git a/target-i386/translate.c b/target-i386/translate.c
index 82e2245..b1a5ad9 100644
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -21,7 +21,6 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
-#include <signal.h>
#include "qemu/host-utils.h"
#include "cpu.h"
diff --git a/target-mips/helper.c b/target-mips/helper.c
index f44edbb..37bba67 100644
--- a/target-mips/helper.c
+++ b/target-mips/helper.c
@@ -21,7 +21,6 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
-#include <signal.h>
#include "cpu.h"
#include "sysemu/kvm.h"
diff --git a/target-sh4/helper.c b/target-sh4/helper.c
index a533f08..dc101cb 100644
--- a/target-sh4/helper.c
+++ b/target-sh4/helper.c
@@ -21,7 +21,6 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
-#include <signal.h>
#include "cpu.h"
diff --git a/target-tricore/helper.c b/target-tricore/helper.c
index f52504c..1808b28 100644
--- a/target-tricore/helper.c
+++ b/target-tricore/helper.c
@@ -20,7 +20,6 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
-#include <signal.h>
#include "cpu.h"
diff --git a/tests/tcg/testthread.c b/tests/tcg/testthread.c
index 2679af1..810ba5d 100644
--- a/tests/tcg/testthread.c
+++ b/tests/tcg/testthread.c
@@ -2,7 +2,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
-#include <signal.h>
#include <unistd.h>
#include <inttypes.h>
#include <pthread.h>
--
2.4.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 6/7] maint: remove unused include for strings.h
2015-08-26 11:17 [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups Daniel P. Berrange
` (4 preceding siblings ...)
2015-08-26 11:17 ` [Qemu-devel] [PATCH 5/7] maint: remove unused include for signal.h Daniel P. Berrange
@ 2015-08-26 11:17 ` Daniel P. Berrange
2015-08-26 11:17 ` [Qemu-devel] [PATCH 7/7] maint: avoid useless "if (foo) free(foo)" pattern Daniel P. Berrange
` (2 subsequent siblings)
8 siblings, 0 replies; 16+ messages in thread
From: Daniel P. Berrange @ 2015-08-26 11:17 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
A number of files were including strings.h but not using any
of the functions it provides
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
disas/microblaze.c | 1 -
hw/pci/shpc.c | 1 -
page_cache.c | 1 -
tests/test-xbzrle.c | 1 -
4 files changed, 4 deletions(-)
diff --git a/disas/microblaze.c b/disas/microblaze.c
index c14ab89..92cd4b1 100644
--- a/disas/microblaze.c
+++ b/disas/microblaze.c
@@ -582,7 +582,6 @@ static const char pvr_register_prefix[] = "rpvr";
#endif /* MICROBLAZE_OPC */
#include "disas/bfd.h"
-#include <strings.h>
#define get_field_rd(instr) get_field(instr, RD_MASK, RD_LOW)
#define get_field_r1(instr) get_field(instr, RA_MASK, RA_LOW)
diff --git a/hw/pci/shpc.c b/hw/pci/shpc.c
index bfb4d31..d34fdf3 100644
--- a/hw/pci/shpc.c
+++ b/hw/pci/shpc.c
@@ -1,5 +1,4 @@
#include "qemu-common.h"
-#include <strings.h>
#include <stdint.h>
#include "qemu/range.h"
#include "qemu/error-report.h"
diff --git a/page_cache.c b/page_cache.c
index cf8878d..a9eb076 100644
--- a/page_cache.c
+++ b/page_cache.c
@@ -15,7 +15,6 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
diff --git a/tests/test-xbzrle.c b/tests/test-xbzrle.c
index b5ee8bb..1cd8cb7 100644
--- a/tests/test-xbzrle.c
+++ b/tests/test-xbzrle.c
@@ -13,7 +13,6 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
-#include <strings.h>
#include <string.h>
#include <sys/time.h>
#include "qemu-common.h"
--
2.4.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* [Qemu-devel] [PATCH 7/7] maint: avoid useless "if (foo) free(foo)" pattern
2015-08-26 11:17 [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups Daniel P. Berrange
` (5 preceding siblings ...)
2015-08-26 11:17 ` [Qemu-devel] [PATCH 6/7] maint: remove unused include for strings.h Daniel P. Berrange
@ 2015-08-26 11:17 ` Daniel P. Berrange
2015-08-26 11:36 ` Marc-André Lureau
2015-08-26 12:02 ` Markus Armbruster
2015-08-26 12:03 ` [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups Markus Armbruster
2015-09-06 10:51 ` Michael Tokarev
8 siblings, 2 replies; 16+ messages in thread
From: Daniel P. Berrange @ 2015-08-26 11:17 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial
The free() and g_free() functions both happily accept
NULL on any platform QEMU builds on. As such putting a
conditional 'if (foo)' check before calls to 'free(foo)'
merely serves to bloat the lines of code.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
backends/hostmem-file.c | 4 +---
bsd-user/elfload.c | 4 +---
disas/sparc.c | 3 +--
hw/bt/hci.c | 9 +++------
hw/core/loader.c | 3 +--
hw/core/qdev-properties.c | 4 +---
hw/display/exynos4210_fimd.c | 4 +---
hw/mips/mips_r4k.c | 4 +---
hw/net/fsl_etsec/rings.c | 4 +---
hw/net/rocker/rocker.c | 4 +---
hw/net/rocker/rocker_desc.c | 8 ++------
hw/nvram/fw_cfg.c | 4 +---
hw/pci-host/prep.c | 4 +---
hw/sd/sd.c | 3 +--
hw/usb/hcd-xhci.c | 4 +---
hw/xen/xen_pt_config_init.c | 4 +---
migration/savevm.c | 8 ++------
qemu-char.c | 4 +---
tests/bios-tables-test.c | 36 +++++++++++++-----------------------
ui/spice-display.c | 14 ++++----------
20 files changed, 39 insertions(+), 93 deletions(-)
diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index 4b55361..e9b6d21 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -83,9 +83,7 @@ static void set_mem_path(Object *o, const char *str, Error **errp)
error_setg(errp, "cannot change property value");
return;
}
- if (fb->mem_path) {
- g_free(fb->mem_path);
- }
+ g_free(fb->mem_path);
fb->mem_path = g_strdup(str);
}
diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
index 2bf57eb..a8ce43d 100644
--- a/bsd-user/elfload.c
+++ b/bsd-user/elfload.c
@@ -1355,9 +1355,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
}
}
if (!bprm->p) {
- if (elf_interpreter) {
- free(elf_interpreter);
- }
+ free(elf_interpreter);
free (elf_phdata);
close(bprm->fd);
return -E2BIG;
diff --git a/disas/sparc.c b/disas/sparc.c
index f4e3565..59a1e36 100644
--- a/disas/sparc.c
+++ b/disas/sparc.c
@@ -2622,8 +2622,7 @@ build_hash_table (const sparc_opcode **opcode_table,
memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));
memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));
- if (hash_buf != NULL)
- free (hash_buf);
+ free(hash_buf);
hash_buf = malloc (sizeof (* hash_buf) * num_opcodes);
for (i = num_opcodes - 1; i >= 0; --i)
{
diff --git a/hw/bt/hci.c b/hw/bt/hci.c
index 7ea3dc6..3fec435 100644
--- a/hw/bt/hci.c
+++ b/hw/bt/hci.c
@@ -1151,8 +1151,7 @@ static void bt_hci_reset(struct bt_hci_s *hci)
hci->event_mask[7] = 0x00;
hci->device.inquiry_scan = 0;
hci->device.page_scan = 0;
- if (hci->device.lmp_name)
- g_free((void *) hci->device.lmp_name);
+ g_free((void *) hci->device.lmp_name);
hci->device.lmp_name = NULL;
hci->device.class[0] = 0x00;
hci->device.class[1] = 0x00;
@@ -1829,8 +1828,7 @@ static void bt_submit_hci(struct HCIInfo *info,
case cmd_opcode_pack(OGF_HOST_CTL, OCF_CHANGE_LOCAL_NAME):
LENGTH_CHECK(change_local_name);
- if (hci->device.lmp_name)
- g_free((void *) hci->device.lmp_name);
+ g_free((void *) hci->device.lmp_name);
hci->device.lmp_name = g_strndup(PARAM(change_local_name, name),
sizeof(PARAM(change_local_name, name)));
bt_hci_event_complete_status(hci, HCI_SUCCESS);
@@ -2231,8 +2229,7 @@ static void bt_hci_done(struct HCIInfo *info)
bt_device_done(&hci->device);
- if (hci->device.lmp_name)
- g_free((void *) hci->device.lmp_name);
+ g_free((void *) hci->device.lmp_name);
/* Be gentle and send DISCONNECT to all connected peers and those
* currently waiting for us to accept or reject a connection request.
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 216eeeb..a96a74e 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -594,8 +594,7 @@ static int load_uboot_image(const char *filename, hwaddr *ep, hwaddr *loadaddr,
ret = hdr->ih_size;
out:
- if (data)
- g_free(data);
+ g_free(data);
close(fd);
return ret;
}
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 04fd80a..33e245e 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -422,9 +422,7 @@ static void set_string(Object *obj, Visitor *v, void *opaque,
error_propagate(errp, local_err);
return;
}
- if (*ptr) {
- g_free(*ptr);
- }
+ g_free(*ptr);
*ptr = str;
}
diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c
index 603ef50..45239e8 100644
--- a/hw/display/exynos4210_fimd.c
+++ b/hw/display/exynos4210_fimd.c
@@ -1354,9 +1354,7 @@ static void exynos4210_fimd_reset(DeviceState *d)
fimd_update_get_alpha(s, w);
}
- if (s->ifb != NULL) {
- g_free(s->ifb);
- }
+ g_free(s->ifb);
s->ifb = NULL;
exynos4210_fimd_invalidate(s);
diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
index f4dcacd..86b2c0b 100644
--- a/hw/mips/mips_r4k.c
+++ b/hw/mips/mips_r4k.c
@@ -252,9 +252,7 @@ void mips_r4k_init(MachineState *machine)
fprintf(stderr, "qemu: Warning, could not load MIPS bios '%s'\n",
bios_name);
}
- if (filename) {
- g_free(filename);
- }
+ g_free(filename);
if (kernel_filename) {
loaderparams.ram_size = ram_size;
diff --git a/hw/net/fsl_etsec/rings.c b/hw/net/fsl_etsec/rings.c
index 68e7b6d..0a5c6cf 100644
--- a/hw/net/fsl_etsec/rings.c
+++ b/hw/net/fsl_etsec/rings.c
@@ -464,9 +464,7 @@ static void rx_init_frame(eTSEC *etsec, const uint8_t *buf, size_t size)
etsec->rx_fcb_size = 0;
}
- if (etsec->rx_buffer != NULL) {
- g_free(etsec->rx_buffer);
- }
+ g_free(etsec->rx_buffer);
/* Do not copy the frame for now */
etsec->rx_buffer = (uint8_t *)buf;
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
index 47d080f..7e7bda4 100644
--- a/hw/net/rocker/rocker.c
+++ b/hw/net/rocker/rocker.c
@@ -265,9 +265,7 @@ err_bad_io:
err_no_mem:
err_bad_attr:
for (i = 0; i < ROCKER_TX_FRAGS_MAX; i++) {
- if (iov[i].iov_base) {
- g_free(iov[i].iov_base);
- }
+ g_free(iov[i].iov_base);
}
return err;
diff --git a/hw/net/rocker/rocker_desc.c b/hw/net/rocker/rocker_desc.c
index 9d896fe..b5c0b4a 100644
--- a/hw/net/rocker/rocker_desc.c
+++ b/hw/net/rocker/rocker_desc.c
@@ -136,9 +136,7 @@ bool desc_ring_set_size(DescRing *ring, uint32_t size)
}
for (i = 0; i < ring->size; i++) {
- if (ring->info[i].buf) {
- g_free(ring->info[i].buf);
- }
+ g_free(ring->info[i].buf);
}
ring->size = size;
@@ -360,9 +358,7 @@ DescRing *desc_ring_alloc(Rocker *r, int index)
void desc_ring_free(DescRing *ring)
{
- if (ring->info) {
- g_free(ring->info);
- }
+ g_free(ring->info);
g_free(ring);
}
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 88481b7..658f8c4 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -187,9 +187,7 @@ static void fw_cfg_bootsplash(FWCfgState *s)
g_free(filename);
return;
}
- if (boot_splash_filedata != NULL) {
- g_free(boot_splash_filedata);
- }
+ g_free(boot_splash_filedata);
boot_splash_filedata = (uint8_t *)file_data;
boot_splash_filedata_size = file_size;
diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
index c63f45d..988907b 100644
--- a/hw/pci-host/prep.c
+++ b/hw/pci-host/prep.c
@@ -328,9 +328,7 @@ static void raven_realize(PCIDevice *d, Error **errp)
if (bios_size < 0 || bios_size > BIOS_SIZE) {
hw_error("qemu: could not load bios image '%s'\n", s->bios_name);
}
- if (filename) {
- g_free(filename);
- }
+ g_free(filename);
}
}
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index a1ff465..3e2a451 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -412,8 +412,7 @@ static void sd_reset(SDState *sd)
sd_set_cardstatus(sd);
sd_set_sdstatus(sd);
- if (sd->wp_groups)
- g_free(sd->wp_groups);
+ g_free(sd->wp_groups);
sd->wp_switch = sd->blk ? blk_is_read_only(sd->blk) : false;
sd->wpgrps_size = sect;
sd->wp_groups = bitmap_new(sd->wpgrps_size);
diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
index c673bed..1c57e20 100644
--- a/hw/usb/hcd-xhci.c
+++ b/hw/usb/hcd-xhci.c
@@ -1453,9 +1453,7 @@ static int xhci_ep_nuke_one_xfer(XHCITransfer *t, TRBCCode report)
t->running_retry = 0;
killed = 1;
}
- if (t->trbs) {
- g_free(t->trbs);
- }
+ g_free(t->trbs);
t->trbs = NULL;
t->trb_count = t->trb_alloced = 0;
diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index dd37be3..ca99783 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -1918,9 +1918,7 @@ void xen_pt_config_delete(XenPCIPassthroughState *s)
if (s->msix) {
xen_pt_msix_delete(s);
}
- if (s->msi) {
- g_free(s->msi);
- }
+ g_free(s->msi);
/* free all register group entry */
QLIST_FOREACH_SAFE(reg_group, &s->reg_grps, entries, next_grp) {
diff --git a/migration/savevm.c b/migration/savevm.c
index 6071215..33e55fe 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -551,9 +551,7 @@ void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) {
if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {
QTAILQ_REMOVE(&savevm_state.handlers, se, entry);
- if (se->compat) {
- g_free(se->compat);
- }
+ g_free(se->compat);
g_free(se->ops);
g_free(se);
}
@@ -612,9 +610,7 @@ void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) {
if (se->vmsd == vmsd && se->opaque == opaque) {
QTAILQ_REMOVE(&savevm_state.handlers, se, entry);
- if (se->compat) {
- g_free(se->compat);
- }
+ g_free(se->compat);
g_free(se);
}
}
diff --git a/qemu-char.c b/qemu-char.c
index fa65159..dd83203 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2710,9 +2710,7 @@ static int tcp_set_msgfds(CharDriverState *chr, int *fds, int num)
TCPCharDriver *s = chr->opaque;
/* clear old pending fd array */
- if (s->write_msgfds) {
- g_free(s->write_msgfds);
- }
+ g_free(s->write_msgfds);
if (num) {
s->write_msgfds = g_malloc(num * sizeof(int));
diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
index 613867a..d21f519 100644
--- a/tests/bios-tables-test.c
+++ b/tests/bios-tables-test.c
@@ -161,31 +161,23 @@ static void free_test_data(test_data *data)
AcpiSdtTable *temp;
int i;
- if (data->rsdt_tables_addr) {
- g_free(data->rsdt_tables_addr);
- }
+ g_free(data->rsdt_tables_addr);
for (i = 0; i < data->tables->len; ++i) {
temp = &g_array_index(data->tables, AcpiSdtTable, i);
- if (temp->aml) {
- g_free(temp->aml);
- }
- if (temp->aml_file) {
- if (!temp->tmp_files_retain &&
- g_strstr_len(temp->aml_file, -1, "aml-")) {
- unlink(temp->aml_file);
- }
- g_free(temp->aml_file);
+ g_free(temp->aml);
+ if (temp->aml_file &&
+ !temp->tmp_files_retain &&
+ g_strstr_len(temp->aml_file, -1, "aml-")) {
+ unlink(temp->aml_file);
}
- if (temp->asl) {
- g_free(temp->asl);
- }
- if (temp->asl_file) {
- if (!temp->tmp_files_retain) {
- unlink(temp->asl_file);
- }
- g_free(temp->asl_file);
+ g_free(temp->aml_file);
+ g_free(temp->asl);
+ if (temp->asl_file &&
+ !temp->tmp_files_retain) {
+ unlink(temp->asl_file);
}
+ g_free(temp->asl_file);
}
g_array_free(data->tables, false);
@@ -420,9 +412,7 @@ static void dump_aml_files(test_data *data, bool rebuild)
close(fd);
- if (aml_file) {
- g_free(aml_file);
- }
+ g_free(aml_file);
}
}
diff --git a/ui/spice-display.c b/ui/spice-display.c
index 0360abf..77c8cba 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -737,9 +737,7 @@ static void display_mouse_set(DisplayChangeListener *dcl,
qemu_mutex_lock(&ssd->lock);
ssd->ptr_x = x;
ssd->ptr_y = y;
- if (ssd->ptr_move) {
- g_free(ssd->ptr_move);
- }
+ g_free(ssd->ptr_move);
ssd->ptr_move = qemu_spice_create_cursor_update(ssd, NULL, on);
qemu_mutex_unlock(&ssd->lock);
}
@@ -752,13 +750,9 @@ static void display_mouse_define(DisplayChangeListener *dcl,
qemu_mutex_lock(&ssd->lock);
ssd->hot_x = c->hot_x;
ssd->hot_y = c->hot_y;
- if (ssd->ptr_move) {
- g_free(ssd->ptr_move);
- ssd->ptr_move = NULL;
- }
- if (ssd->ptr_define) {
- g_free(ssd->ptr_define);
- }
+ g_free(ssd->ptr_move);
+ ssd->ptr_move = NULL;
+ g_free(ssd->ptr_define);
ssd->ptr_define = qemu_spice_create_cursor_update(ssd, c, 0);
qemu_mutex_unlock(&ssd->lock);
}
--
2.4.3
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 1/7] maint: remove double semicolons in many files
2015-08-26 11:17 ` [Qemu-devel] [PATCH 1/7] maint: remove double semicolons in many files Daniel P. Berrange
@ 2015-08-26 11:29 ` Marc-André Lureau
0 siblings, 0 replies; 16+ messages in thread
From: Marc-André Lureau @ 2015-08-26 11:29 UTC (permalink / raw)
To: Daniel P. Berrange; +Cc: qemu-trivial, QEMU
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 2/7] maint: remove / fix many doubled words
2015-08-26 11:17 ` [Qemu-devel] [PATCH 2/7] maint: remove / fix many doubled words Daniel P. Berrange
@ 2015-08-26 11:31 ` Marc-André Lureau
0 siblings, 0 replies; 16+ messages in thread
From: Marc-André Lureau @ 2015-08-26 11:31 UTC (permalink / raw)
To: Daniel P. Berrange; +Cc: qemu-trivial, QEMU
nice :)
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 7/7] maint: avoid useless "if (foo) free(foo)" pattern
2015-08-26 11:17 ` [Qemu-devel] [PATCH 7/7] maint: avoid useless "if (foo) free(foo)" pattern Daniel P. Berrange
@ 2015-08-26 11:36 ` Marc-André Lureau
2015-08-26 12:02 ` Markus Armbruster
1 sibling, 0 replies; 16+ messages in thread
From: Marc-André Lureau @ 2015-08-26 11:36 UTC (permalink / raw)
To: Daniel P. Berrange; +Cc: qemu-trivial, QEMU
Hi
On Wed, Aug 26, 2015 at 1:17 PM, Daniel P. Berrange <berrange@redhat.com> wrote:
> The free() and g_free() functions both happily accept
> NULL on any platform QEMU builds on. As such putting a
> conditional 'if (foo)' check before calls to 'free(foo)'
> merely serves to bloat the lines of code.
>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
> backends/hostmem-file.c | 4 +---
> bsd-user/elfload.c | 4 +---
> disas/sparc.c | 3 +--
> hw/bt/hci.c | 9 +++------
> hw/core/loader.c | 3 +--
> hw/core/qdev-properties.c | 4 +---
> hw/display/exynos4210_fimd.c | 4 +---
> hw/mips/mips_r4k.c | 4 +---
> hw/net/fsl_etsec/rings.c | 4 +---
> hw/net/rocker/rocker.c | 4 +---
> hw/net/rocker/rocker_desc.c | 8 ++------
> hw/nvram/fw_cfg.c | 4 +---
> hw/pci-host/prep.c | 4 +---
> hw/sd/sd.c | 3 +--
> hw/usb/hcd-xhci.c | 4 +---
> hw/xen/xen_pt_config_init.c | 4 +---
> migration/savevm.c | 8 ++------
> qemu-char.c | 4 +---
> tests/bios-tables-test.c | 36 +++++++++++++-----------------------
> ui/spice-display.c | 14 ++++----------
> 20 files changed, 39 insertions(+), 93 deletions(-)
>
> diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
> index 4b55361..e9b6d21 100644
> --- a/backends/hostmem-file.c
> +++ b/backends/hostmem-file.c
> @@ -83,9 +83,7 @@ static void set_mem_path(Object *o, const char *str, Error **errp)
> error_setg(errp, "cannot change property value");
> return;
> }
> - if (fb->mem_path) {
> - g_free(fb->mem_path);
> - }
> + g_free(fb->mem_path);
> fb->mem_path = g_strdup(str);
> }
>
> diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
> index 2bf57eb..a8ce43d 100644
> --- a/bsd-user/elfload.c
> +++ b/bsd-user/elfload.c
> @@ -1355,9 +1355,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
> }
> }
> if (!bprm->p) {
> - if (elf_interpreter) {
> - free(elf_interpreter);
> - }
> + free(elf_interpreter);
> free (elf_phdata);
> close(bprm->fd);
> return -E2BIG;
> diff --git a/disas/sparc.c b/disas/sparc.c
> index f4e3565..59a1e36 100644
> --- a/disas/sparc.c
> +++ b/disas/sparc.c
> @@ -2622,8 +2622,7 @@ build_hash_table (const sparc_opcode **opcode_table,
>
> memset (hash_table, 0, HASH_SIZE * sizeof (hash_table[0]));
> memset (hash_count, 0, HASH_SIZE * sizeof (hash_count[0]));
> - if (hash_buf != NULL)
> - free (hash_buf);
> + free(hash_buf);
> hash_buf = malloc (sizeof (* hash_buf) * num_opcodes);
> for (i = num_opcodes - 1; i >= 0; --i)
> {
> diff --git a/hw/bt/hci.c b/hw/bt/hci.c
> index 7ea3dc6..3fec435 100644
> --- a/hw/bt/hci.c
> +++ b/hw/bt/hci.c
> @@ -1151,8 +1151,7 @@ static void bt_hci_reset(struct bt_hci_s *hci)
> hci->event_mask[7] = 0x00;
> hci->device.inquiry_scan = 0;
> hci->device.page_scan = 0;
> - if (hci->device.lmp_name)
> - g_free((void *) hci->device.lmp_name);
> + g_free((void *) hci->device.lmp_name);
> hci->device.lmp_name = NULL;
> hci->device.class[0] = 0x00;
> hci->device.class[1] = 0x00;
> @@ -1829,8 +1828,7 @@ static void bt_submit_hci(struct HCIInfo *info,
> case cmd_opcode_pack(OGF_HOST_CTL, OCF_CHANGE_LOCAL_NAME):
> LENGTH_CHECK(change_local_name);
>
> - if (hci->device.lmp_name)
> - g_free((void *) hci->device.lmp_name);
> + g_free((void *) hci->device.lmp_name);
> hci->device.lmp_name = g_strndup(PARAM(change_local_name, name),
> sizeof(PARAM(change_local_name, name)));
> bt_hci_event_complete_status(hci, HCI_SUCCESS);
> @@ -2231,8 +2229,7 @@ static void bt_hci_done(struct HCIInfo *info)
>
> bt_device_done(&hci->device);
>
> - if (hci->device.lmp_name)
> - g_free((void *) hci->device.lmp_name);
> + g_free((void *) hci->device.lmp_name);
>
> /* Be gentle and send DISCONNECT to all connected peers and those
> * currently waiting for us to accept or reject a connection request.
> diff --git a/hw/core/loader.c b/hw/core/loader.c
> index 216eeeb..a96a74e 100644
> --- a/hw/core/loader.c
> +++ b/hw/core/loader.c
> @@ -594,8 +594,7 @@ static int load_uboot_image(const char *filename, hwaddr *ep, hwaddr *loadaddr,
> ret = hdr->ih_size;
>
> out:
> - if (data)
> - g_free(data);
> + g_free(data);
> close(fd);
> return ret;
> }
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 04fd80a..33e245e 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -422,9 +422,7 @@ static void set_string(Object *obj, Visitor *v, void *opaque,
> error_propagate(errp, local_err);
> return;
> }
> - if (*ptr) {
> - g_free(*ptr);
> - }
> + g_free(*ptr);
> *ptr = str;
> }
>
> diff --git a/hw/display/exynos4210_fimd.c b/hw/display/exynos4210_fimd.c
> index 603ef50..45239e8 100644
> --- a/hw/display/exynos4210_fimd.c
> +++ b/hw/display/exynos4210_fimd.c
> @@ -1354,9 +1354,7 @@ static void exynos4210_fimd_reset(DeviceState *d)
> fimd_update_get_alpha(s, w);
> }
>
> - if (s->ifb != NULL) {
> - g_free(s->ifb);
> - }
> + g_free(s->ifb);
> s->ifb = NULL;
>
> exynos4210_fimd_invalidate(s);
> diff --git a/hw/mips/mips_r4k.c b/hw/mips/mips_r4k.c
> index f4dcacd..86b2c0b 100644
> --- a/hw/mips/mips_r4k.c
> +++ b/hw/mips/mips_r4k.c
> @@ -252,9 +252,7 @@ void mips_r4k_init(MachineState *machine)
> fprintf(stderr, "qemu: Warning, could not load MIPS bios '%s'\n",
> bios_name);
> }
> - if (filename) {
> - g_free(filename);
> - }
> + g_free(filename);
>
> if (kernel_filename) {
> loaderparams.ram_size = ram_size;
> diff --git a/hw/net/fsl_etsec/rings.c b/hw/net/fsl_etsec/rings.c
> index 68e7b6d..0a5c6cf 100644
> --- a/hw/net/fsl_etsec/rings.c
> +++ b/hw/net/fsl_etsec/rings.c
> @@ -464,9 +464,7 @@ static void rx_init_frame(eTSEC *etsec, const uint8_t *buf, size_t size)
> etsec->rx_fcb_size = 0;
> }
>
> - if (etsec->rx_buffer != NULL) {
> - g_free(etsec->rx_buffer);
> - }
> + g_free(etsec->rx_buffer);
>
> /* Do not copy the frame for now */
> etsec->rx_buffer = (uint8_t *)buf;
> diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
> index 47d080f..7e7bda4 100644
> --- a/hw/net/rocker/rocker.c
> +++ b/hw/net/rocker/rocker.c
> @@ -265,9 +265,7 @@ err_bad_io:
> err_no_mem:
> err_bad_attr:
> for (i = 0; i < ROCKER_TX_FRAGS_MAX; i++) {
> - if (iov[i].iov_base) {
> - g_free(iov[i].iov_base);
> - }
> + g_free(iov[i].iov_base);
> }
>
> return err;
> diff --git a/hw/net/rocker/rocker_desc.c b/hw/net/rocker/rocker_desc.c
> index 9d896fe..b5c0b4a 100644
> --- a/hw/net/rocker/rocker_desc.c
> +++ b/hw/net/rocker/rocker_desc.c
> @@ -136,9 +136,7 @@ bool desc_ring_set_size(DescRing *ring, uint32_t size)
> }
>
> for (i = 0; i < ring->size; i++) {
> - if (ring->info[i].buf) {
> - g_free(ring->info[i].buf);
> - }
> + g_free(ring->info[i].buf);
> }
>
> ring->size = size;
> @@ -360,9 +358,7 @@ DescRing *desc_ring_alloc(Rocker *r, int index)
>
> void desc_ring_free(DescRing *ring)
> {
> - if (ring->info) {
> - g_free(ring->info);
> - }
> + g_free(ring->info);
> g_free(ring);
> }
>
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 88481b7..658f8c4 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -187,9 +187,7 @@ static void fw_cfg_bootsplash(FWCfgState *s)
> g_free(filename);
> return;
> }
> - if (boot_splash_filedata != NULL) {
> - g_free(boot_splash_filedata);
> - }
> + g_free(boot_splash_filedata);
> boot_splash_filedata = (uint8_t *)file_data;
> boot_splash_filedata_size = file_size;
>
> diff --git a/hw/pci-host/prep.c b/hw/pci-host/prep.c
> index c63f45d..988907b 100644
> --- a/hw/pci-host/prep.c
> +++ b/hw/pci-host/prep.c
> @@ -328,9 +328,7 @@ static void raven_realize(PCIDevice *d, Error **errp)
> if (bios_size < 0 || bios_size > BIOS_SIZE) {
> hw_error("qemu: could not load bios image '%s'\n", s->bios_name);
> }
> - if (filename) {
> - g_free(filename);
> - }
> + g_free(filename);
> }
> }
>
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index a1ff465..3e2a451 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -412,8 +412,7 @@ static void sd_reset(SDState *sd)
> sd_set_cardstatus(sd);
> sd_set_sdstatus(sd);
>
> - if (sd->wp_groups)
> - g_free(sd->wp_groups);
> + g_free(sd->wp_groups);
> sd->wp_switch = sd->blk ? blk_is_read_only(sd->blk) : false;
> sd->wpgrps_size = sect;
> sd->wp_groups = bitmap_new(sd->wpgrps_size);
> diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c
> index c673bed..1c57e20 100644
> --- a/hw/usb/hcd-xhci.c
> +++ b/hw/usb/hcd-xhci.c
> @@ -1453,9 +1453,7 @@ static int xhci_ep_nuke_one_xfer(XHCITransfer *t, TRBCCode report)
> t->running_retry = 0;
> killed = 1;
> }
> - if (t->trbs) {
> - g_free(t->trbs);
> - }
> + g_free(t->trbs);
>
> t->trbs = NULL;
> t->trb_count = t->trb_alloced = 0;
> diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
> index dd37be3..ca99783 100644
> --- a/hw/xen/xen_pt_config_init.c
> +++ b/hw/xen/xen_pt_config_init.c
> @@ -1918,9 +1918,7 @@ void xen_pt_config_delete(XenPCIPassthroughState *s)
> if (s->msix) {
> xen_pt_msix_delete(s);
> }
> - if (s->msi) {
> - g_free(s->msi);
> - }
> + g_free(s->msi);
>
> /* free all register group entry */
> QLIST_FOREACH_SAFE(reg_group, &s->reg_grps, entries, next_grp) {
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 6071215..33e55fe 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -551,9 +551,7 @@ void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque)
> QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) {
> if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) {
> QTAILQ_REMOVE(&savevm_state.handlers, se, entry);
> - if (se->compat) {
> - g_free(se->compat);
> - }
> + g_free(se->compat);
> g_free(se->ops);
> g_free(se);
> }
> @@ -612,9 +610,7 @@ void vmstate_unregister(DeviceState *dev, const VMStateDescription *vmsd,
> QTAILQ_FOREACH_SAFE(se, &savevm_state.handlers, entry, new_se) {
> if (se->vmsd == vmsd && se->opaque == opaque) {
> QTAILQ_REMOVE(&savevm_state.handlers, se, entry);
> - if (se->compat) {
> - g_free(se->compat);
> - }
> + g_free(se->compat);
> g_free(se);
> }
> }
> diff --git a/qemu-char.c b/qemu-char.c
> index fa65159..dd83203 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -2710,9 +2710,7 @@ static int tcp_set_msgfds(CharDriverState *chr, int *fds, int num)
> TCPCharDriver *s = chr->opaque;
>
> /* clear old pending fd array */
> - if (s->write_msgfds) {
> - g_free(s->write_msgfds);
> - }
> + g_free(s->write_msgfds);
>
> if (num) {
> s->write_msgfds = g_malloc(num * sizeof(int));
> diff --git a/tests/bios-tables-test.c b/tests/bios-tables-test.c
> index 613867a..d21f519 100644
> --- a/tests/bios-tables-test.c
> +++ b/tests/bios-tables-test.c
> @@ -161,31 +161,23 @@ static void free_test_data(test_data *data)
> AcpiSdtTable *temp;
> int i;
>
> - if (data->rsdt_tables_addr) {
> - g_free(data->rsdt_tables_addr);
> - }
> + g_free(data->rsdt_tables_addr);
>
> for (i = 0; i < data->tables->len; ++i) {
> temp = &g_array_index(data->tables, AcpiSdtTable, i);
> - if (temp->aml) {
> - g_free(temp->aml);
> - }
> - if (temp->aml_file) {
> - if (!temp->tmp_files_retain &&
> - g_strstr_len(temp->aml_file, -1, "aml-")) {
> - unlink(temp->aml_file);
> - }
> - g_free(temp->aml_file);
> + g_free(temp->aml);
> + if (temp->aml_file &&
> + !temp->tmp_files_retain &&
> + g_strstr_len(temp->aml_file, -1, "aml-")) {
> + unlink(temp->aml_file);
> }
> - if (temp->asl) {
> - g_free(temp->asl);
> - }
> - if (temp->asl_file) {
> - if (!temp->tmp_files_retain) {
> - unlink(temp->asl_file);
> - }
> - g_free(temp->asl_file);
> + g_free(temp->aml_file);
> + g_free(temp->asl);
> + if (temp->asl_file &&
> + !temp->tmp_files_retain) {
> + unlink(temp->asl_file);
> }
> + g_free(temp->asl_file);
> }
>
> g_array_free(data->tables, false);
> @@ -420,9 +412,7 @@ static void dump_aml_files(test_data *data, bool rebuild)
>
> close(fd);
>
> - if (aml_file) {
> - g_free(aml_file);
> - }
> + g_free(aml_file);
> }
> }
>
> diff --git a/ui/spice-display.c b/ui/spice-display.c
> index 0360abf..77c8cba 100644
> --- a/ui/spice-display.c
> +++ b/ui/spice-display.c
> @@ -737,9 +737,7 @@ static void display_mouse_set(DisplayChangeListener *dcl,
> qemu_mutex_lock(&ssd->lock);
> ssd->ptr_x = x;
> ssd->ptr_y = y;
> - if (ssd->ptr_move) {
> - g_free(ssd->ptr_move);
> - }
> + g_free(ssd->ptr_move);
> ssd->ptr_move = qemu_spice_create_cursor_update(ssd, NULL, on);
> qemu_mutex_unlock(&ssd->lock);
> }
> @@ -752,13 +750,9 @@ static void display_mouse_define(DisplayChangeListener *dcl,
> qemu_mutex_lock(&ssd->lock);
> ssd->hot_x = c->hot_x;
> ssd->hot_y = c->hot_y;
> - if (ssd->ptr_move) {
> - g_free(ssd->ptr_move);
> - ssd->ptr_move = NULL;
> - }
> - if (ssd->ptr_define) {
> - g_free(ssd->ptr_define);
> - }
> + g_free(ssd->ptr_move);
> + ssd->ptr_move = NULL;
> + g_free(ssd->ptr_define);
> ssd->ptr_define = qemu_spice_create_cursor_update(ssd, c, 0);
> qemu_mutex_unlock(&ssd->lock);
> }
> --
> 2.4.3
>
>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 7/7] maint: avoid useless "if (foo) free(foo)" pattern
2015-08-26 11:17 ` [Qemu-devel] [PATCH 7/7] maint: avoid useless "if (foo) free(foo)" pattern Daniel P. Berrange
2015-08-26 11:36 ` Marc-André Lureau
@ 2015-08-26 12:02 ` Markus Armbruster
2015-08-26 12:53 ` Eric Blake
1 sibling, 1 reply; 16+ messages in thread
From: Markus Armbruster @ 2015-08-26 12:02 UTC (permalink / raw)
To: Daniel P. Berrange; +Cc: qemu-trivial, qemu-devel
"Daniel P. Berrange" <berrange@redhat.com> writes:
> The free() and g_free() functions both happily accept
> NULL on any platform QEMU builds on.
Do systems where free(NULL) doesn't work even exist? Even C89
guarantees it does nothing.
> As such putting a
> conditional 'if (foo)' check before calls to 'free(foo)'
> merely serves to bloat the lines of code.
>
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
My Coccinelle semantic patch finds a few more, because it also fixes up
the equally pointless conditional
if (foo) {
free(foo);
foo = NULL;
}
@@
expression E;
@@
- if (E != NULL) {
- g_free(E);
- }
+ g_free(E);
@@
expression E;
@@
- if (E != NULL) {
- g_free(E);
- E = NULL;
- }
+ g_free(E);
+ E = NULL;
@@
expression E;
type T;
@@
- if (E != NULL) {
- g_free((T)E);
- }
+ g_free((T)E);
@@
expression E;
type T;
@@
- if (E != NULL) {
- g_free((T)E);
- E = NULL;
- }
+ g_free((T)E);
+ E = NULL;
Result (feel free to squash it into your patch):
diff --git a/hw/char/exynos4210_uart.c b/hw/char/exynos4210_uart.c
index 7614e58..215f962 100644
--- a/hw/char/exynos4210_uart.c
+++ b/hw/char/exynos4210_uart.c
@@ -234,10 +234,8 @@ static int fifo_empty_elements_number(Exynos4210UartFIFO *q)
static void fifo_reset(Exynos4210UartFIFO *q)
{
- if (q->data != NULL) {
- g_free(q->data);
- q->data = NULL;
- }
+ g_free(q->data);
+ q->data = NULL;
q->data = (uint8_t *)g_malloc0(q->size);
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 78ae4cd..5742a24 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -3438,10 +3438,8 @@ static void pci_rtl8139_uninit(PCIDevice *dev)
{
RTL8139State *s = RTL8139(dev);
- if (s->cplus_txbuffer) {
- g_free(s->cplus_txbuffer);
- s->cplus_txbuffer = NULL;
- }
+ g_free(s->cplus_txbuffer);
+ s->cplus_txbuffer = NULL;
timer_del(s->timer);
timer_free(s->timer);
qemu_del_nic(s->nic);
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index a8f79d8..a2feb4c 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1460,10 +1460,8 @@ static void spapr_pci_pre_save(void *opaque)
gpointer key, value;
int i;
- if (sphb->msi_devs) {
- g_free(sphb->msi_devs);
- sphb->msi_devs = NULL;
- }
+ g_free(sphb->msi_devs);
+ sphb->msi_devs = NULL;
sphb->msi_devs_num = g_hash_table_size(sphb->msi);
if (!sphb->msi_devs_num) {
return;
@@ -1490,10 +1488,8 @@ static int spapr_pci_post_load(void *opaque, int version_id)
sizeof(sphb->msi_devs[i].value));
g_hash_table_insert(sphb->msi, key, value);
}
- if (sphb->msi_devs) {
- g_free(sphb->msi_devs);
- sphb->msi_devs = NULL;
- }
+ g_free(sphb->msi_devs);
+ sphb->msi_devs = NULL;
sphb->msi_devs_num = 0;
return 0;
diff --git a/hw/sd/sdhci.c b/hw/sd/sdhci.c
index e63367b..65304cf 100644
--- a/hw/sd/sdhci.c
+++ b/hw/sd/sdhci.c
@@ -1169,10 +1169,8 @@ static void sdhci_uninitfn(SDHCIState *s)
qemu_free_irq(s->eject_cb);
qemu_free_irq(s->ro_cb);
- if (s->fifo_buffer) {
- g_free(s->fifo_buffer);
- s->fifo_buffer = NULL;
- }
+ g_free(s->fifo_buffer);
+ s->fifo_buffer = NULL;
}
const VMStateDescription sdhci_vmstate = {
diff --git a/hw/usb/hcd-ehci-pci.c b/hw/usb/hcd-ehci-pci.c
index 7afa5f9..16fb845 100644
--- a/hw/usb/hcd-ehci-pci.c
+++ b/hw/usb/hcd-ehci-pci.c
@@ -95,10 +95,8 @@ static void usb_ehci_pci_exit(PCIDevice *dev)
usb_ehci_unrealize(s, DEVICE(dev), NULL);
- if (s->irq) {
- g_free(s->irq);
- s->irq = NULL;
- }
+ g_free(s->irq);
+ s->irq = NULL;
}
static void usb_ehci_pci_reset(DeviceState *dev)
diff --git a/tests/test-hbitmap.c b/tests/test-hbitmap.c
index 161eeb4..abcea0c 100644
--- a/tests/test-hbitmap.c
+++ b/tests/test-hbitmap.c
@@ -139,10 +139,8 @@ static void hbitmap_test_teardown(TestHBitmapData *data,
hbitmap_free(data->hb);
data->hb = NULL;
}
- if (data->bits) {
- g_free(data->bits);
- data->bits = NULL;
- }
+ g_free(data->bits);
+ data->bits = NULL;
}
/* Set a range in the HBitmap and in the shadow "simple" bitmap.
diff --git a/translate-all.c b/translate-all.c
index 9c46ffa..ffe75ed 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -731,10 +731,8 @@ void tb_free(TranslationBlock *tb)
static inline void invalidate_page_bitmap(PageDesc *p)
{
- if (p->code_bitmap) {
- g_free(p->code_bitmap);
- p->code_bitmap = NULL;
- }
+ g_free(p->code_bitmap);
+ p->code_bitmap = NULL;
p->code_write_count = 0;
}
diff --git a/vl.c b/vl.c
index 584ca88..72a3f81 100644
--- a/vl.c
+++ b/vl.c
@@ -534,10 +534,8 @@ const char *qemu_get_vm_name(void)
static void res_free(void)
{
- if (boot_splash_filedata != NULL) {
- g_free(boot_splash_filedata);
- boot_splash_filedata = NULL;
- }
+ g_free(boot_splash_filedata);
+ boot_splash_filedata = NULL;
}
static int default_driver_check(void *opaque, QemuOpts *opts, Error **errp)
diff --git a/xen-mapcache.c b/xen-mapcache.c
index 8cefd0c..97fece2 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -169,10 +169,8 @@ static void xen_remap_bucket(MapCacheEntry *entry,
exit(-1);
}
}
- if (entry->valid_mapping != NULL) {
- g_free(entry->valid_mapping);
- entry->valid_mapping = NULL;
- }
+ g_free(entry->valid_mapping);
+ entry->valid_mapping = NULL;
for (i = 0; i < nb_pfn; i++) {
pfns[i] = (address_index << (MCACHE_BUCKET_SHIFT-XC_PAGE_SHIFT)) + i;
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups
2015-08-26 11:17 [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups Daniel P. Berrange
` (6 preceding siblings ...)
2015-08-26 11:17 ` [Qemu-devel] [PATCH 7/7] maint: avoid useless "if (foo) free(foo)" pattern Daniel P. Berrange
@ 2015-08-26 12:03 ` Markus Armbruster
2015-09-06 10:51 ` Michael Tokarev
8 siblings, 0 replies; 16+ messages in thread
From: Markus Armbruster @ 2015-08-26 12:03 UTC (permalink / raw)
To: Daniel P. Berrange; +Cc: qemu-trivial, qemu-devel
"Daniel P. Berrange" <berrange@redhat.com> writes:
> This is a series of misc trivial code cleanups that I
> originally used to illustrate the use of GNULIB's
> syntax-check facility:
>
> http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg06268.html
>
> Since it appears the license of the GNULIB syntax-check
> is problematic, this series has separated the fixes out
> from the GNULIB additions, to allow for possibility of
> merging them as-is.
Series
Reviewed-by: Markus Armbruster <armbru@redhat.com>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 7/7] maint: avoid useless "if (foo) free(foo)" pattern
2015-08-26 12:02 ` Markus Armbruster
@ 2015-08-26 12:53 ` Eric Blake
2015-08-26 16:09 ` Markus Armbruster
0 siblings, 1 reply; 16+ messages in thread
From: Eric Blake @ 2015-08-26 12:53 UTC (permalink / raw)
To: Markus Armbruster, Daniel P. Berrange; +Cc: qemu-trivial, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1342 bytes --]
On 08/26/2015 06:02 AM, Markus Armbruster wrote:
> "Daniel P. Berrange" <berrange@redhat.com> writes:
>
>> The free() and g_free() functions both happily accept
>> NULL on any platform QEMU builds on.
>
> Do systems where free(NULL) doesn't work even exist? Even C89
> guarantees it does nothing.
Solaris 4 was the last (pre-C89) system I am aware of that didn't like
free(NULL). Ancient history nowadays.
>
> My Coccinelle semantic patch finds a few more, because it also fixes up
> the equally pointless conditional
>
> if (foo) {
> free(foo);
> foo = NULL;
> }
The assignment to foo is not pointless, but removing the conditional is
indeed nice. gnulib's perl script is a lot weaker than coccinelle,
obviously :)
>
> @@
> expression E;
> @@
> - if (E != NULL) {
> - g_free(E);
> - E = NULL;
> - }
> + g_free(E);
> + E = NULL;
This only checks for g_free() before assignment to NULL; are there any
uses of raw free() that do the same?
> Result (feel free to squash it into your patch):
>
Whether squashed in or separate, these additional changes and the
original patch are:
Reviewed-by: Eric Blake <eblake@redhat.com>
--
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] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 7/7] maint: avoid useless "if (foo) free(foo)" pattern
2015-08-26 12:53 ` Eric Blake
@ 2015-08-26 16:09 ` Markus Armbruster
0 siblings, 0 replies; 16+ messages in thread
From: Markus Armbruster @ 2015-08-26 16:09 UTC (permalink / raw)
To: Eric Blake; +Cc: qemu-trivial, qemu-devel
Eric Blake <eblake@redhat.com> writes:
> On 08/26/2015 06:02 AM, Markus Armbruster wrote:
>> "Daniel P. Berrange" <berrange@redhat.com> writes:
>>
>>> The free() and g_free() functions both happily accept
>>> NULL on any platform QEMU builds on.
>>
>> Do systems where free(NULL) doesn't work even exist? Even C89
>> guarantees it does nothing.
>
> Solaris 4 was the last (pre-C89) system I am aware of that didn't like
> free(NULL). Ancient history nowadays.
>
>>
>> My Coccinelle semantic patch finds a few more, because it also fixes up
>> the equally pointless conditional
>>
>> if (foo) {
>> free(foo);
>> foo = NULL;
>> }
>
> The assignment to foo is not pointless, but removing the conditional is
> indeed nice. gnulib's perl script is a lot weaker than coccinelle,
> obviously :)
I only called the conditional pointless :)
>>
>> @@
>> expression E;
>> @@
>> - if (E != NULL) {
>> - g_free(E);
>> - E = NULL;
>> - }
>> + g_free(E);
>> + E = NULL;
>
> This only checks for g_free() before assignment to NULL; are there any
> uses of raw free() that do the same?
Running Coccinelle again... wait... wait... yes, but only in
libdecnumber/, which we stole from GCC. Not sure we want to mess with
it. Patch appended anyway.
>> Result (feel free to squash it into your patch):
>>
>
> Whether squashed in or separate, these additional changes and the
> original patch are:
> Reviewed-by: Eric Blake <eblake@redhat.com>
diff --git a/libdecnumber/decNumber.c b/libdecnumber/decNumber.c
index 58211e7..c5b5f66 100644
--- a/libdecnumber/decNumber.c
+++ b/libdecnumber/decNumber.c
@@ -779,7 +779,7 @@ decNumber * decNumberFromString(decNumber *dn, const char chars[],
/* decNumberShow(dn); */
} while(0); /* [for break] */
- if (allocres!=NULL) free(allocres); /* drop any storage used */
+ free(allocres); /* drop any storage used */
if (status!=0) decStatus(dn, status, set);
return dn;
} /* decNumberFromString */
@@ -1038,8 +1038,8 @@ decNumber * decNumberCompareTotalMag(decNumber *res, const decNumber *lhs,
decCompareOp(res, lhs, rhs, set, COMPTOTAL, &status);
} while(0); /* end protected */
- if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
- if (allocbufb!=NULL) free(allocbufb); /* .. */
+ free(allocbufa); /* drop any storage used */
+ free(allocbufb); /* .. */
if (status!=0) decStatus(res, status, set);
return res;
} /* decNumberCompareTotalMag */
@@ -1142,7 +1142,7 @@ decNumber * decNumberExp(decNumber *res, const decNumber *rhs,
} while(0); /* end protected */
#if DECSUBSET
- if (allocrhs !=NULL) free(allocrhs); /* drop any storage used */
+ free(allocrhs); /* drop any storage used */
#endif
/* apply significant status */
if (status!=0) decStatus(res, status, set);
@@ -1237,7 +1237,7 @@ decNumber * decNumberFMA(decNumber *res, const decNumber *lhs,
decAddOp(res, acc, fhs, set, 0, &status);
} while(0); /* end protected */
- if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
+ free(allocbufa); /* drop any storage used */
if (status!=0) decStatus(res, status, set);
#if DECCHECK
decCheckInexact(res, set);
@@ -1364,7 +1364,7 @@ decNumber * decNumberLn(decNumber *res, const decNumber *rhs,
} while(0); /* end protected */
#if DECSUBSET
- if (allocrhs !=NULL) free(allocrhs); /* drop any storage used */
+ free(allocrhs); /* drop any storage used */
#endif
/* apply significant status */
if (status!=0) decStatus(res, status, set);
@@ -1577,10 +1577,10 @@ decNumber * decNumberLog10(decNumber *res, const decNumber *rhs,
decDivideOp(res, a, b, &aset, DIVIDE, &status); /* into result */
} while(0); /* [for break] */
- if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
- if (allocbufb!=NULL) free(allocbufb); /* .. */
+ free(allocbufa); /* drop any storage used */
+ free(allocbufb); /* .. */
#if DECSUBSET
- if (allocrhs !=NULL) free(allocrhs); /* .. */
+ free(allocrhs); /* .. */
#endif
/* apply significant status */
if (status!=0) decStatus(res, status, set);
@@ -2320,11 +2320,11 @@ decNumber * decNumberPower(decNumber *res, const decNumber *lhs,
#endif
} while(0); /* end protected */
- if (allocdac!=NULL) free(allocdac); /* drop any storage used */
- if (allocinv!=NULL) free(allocinv); /* .. */
+ free(allocdac); /* drop any storage used */
+ free(allocinv); /* .. */
#if DECSUBSET
- if (alloclhs!=NULL) free(alloclhs); /* .. */
- if (allocrhs!=NULL) free(allocrhs); /* .. */
+ free(alloclhs); /* .. */
+ free(allocrhs); /* .. */
#endif
if (status!=0) decStatus(res, status, set);
#if DECCHECK
@@ -2415,7 +2415,7 @@ decNumber * decNumberReduce(decNumber *res, const decNumber *rhs,
} while(0); /* end protected */
#if DECSUBSET
- if (allocrhs !=NULL) free(allocrhs); /* .. */
+ free(allocrhs); /* .. */
#endif
if (status!=0) decStatus(res, status, set);/* then report status */
return res;
@@ -3169,11 +3169,11 @@ decNumber * decNumberSquareRoot(decNumber *res, const decNumber *rhs,
decNumberCopy(res, a); /* a is now the result */
} while(0); /* end protected */
- if (allocbuff!=NULL) free(allocbuff); /* drop any storage used */
- if (allocbufa!=NULL) free(allocbufa); /* .. */
- if (allocbufb!=NULL) free(allocbufb); /* .. */
+ free(allocbuff); /* drop any storage used */
+ free(allocbufa); /* .. */
+ free(allocbufb); /* .. */
#if DECSUBSET
- if (allocrhs !=NULL) free(allocrhs); /* .. */
+ free(allocrhs); /* .. */
#endif
if (status!=0) decStatus(res, status, set);/* then report status */
#if DECCHECK
@@ -4187,10 +4187,10 @@ static decNumber * decAddOp(decNumber *res, const decNumber *lhs,
}
} while(0); /* end protected */
- if (allocacc!=NULL) free(allocacc); /* drop any storage used */
+ free(allocacc); /* drop any storage used */
#if DECSUBSET
- if (allocrhs!=NULL) free(allocrhs); /* .. */
- if (alloclhs!=NULL) free(alloclhs); /* .. */
+ free(allocrhs); /* .. */
+ free(alloclhs); /* .. */
#endif
return res;
} /* decAddOp */
@@ -4839,11 +4839,11 @@ static decNumber * decDivideOp(decNumber *res,
#endif
} while(0); /* end protected */
- if (varalloc!=NULL) free(varalloc); /* drop any storage used */
- if (allocacc!=NULL) free(allocacc); /* .. */
+ free(varalloc); /* drop any storage used */
+ free(allocacc); /* .. */
#if DECSUBSET
- if (allocrhs!=NULL) free(allocrhs); /* .. */
- if (alloclhs!=NULL) free(alloclhs); /* .. */
+ free(allocrhs); /* .. */
+ free(alloclhs); /* .. */
#endif
return res;
} /* decDivideOp */
@@ -5184,14 +5184,14 @@ static decNumber * decMultiplyOp(decNumber *res, const decNumber *lhs,
decFinish(res, set, &residue, status); /* final cleanup */
} while(0); /* end protected */
- if (allocacc!=NULL) free(allocacc); /* drop any storage used */
+ free(allocacc); /* drop any storage used */
#if DECSUBSET
- if (allocrhs!=NULL) free(allocrhs); /* .. */
- if (alloclhs!=NULL) free(alloclhs); /* .. */
+ free(allocrhs); /* .. */
+ free(alloclhs); /* .. */
#endif
#if FASTMUL
- if (allocrhi!=NULL) free(allocrhi); /* .. */
- if (alloclhi!=NULL) free(alloclhi); /* .. */
+ free(allocrhi); /* .. */
+ free(alloclhi); /* .. */
#endif
return res;
} /* decMultiplyOp */
@@ -5540,9 +5540,9 @@ static decNumber *decExpOp(decNumber *res, const decNumber *rhs,
decFinish(res, set, &residue, status); /* cleanup/set flags */
} while(0); /* end protected */
- if (allocrhs !=NULL) free(allocrhs); /* drop any storage used */
- if (allocbufa!=NULL) free(allocbufa); /* .. */
- if (allocbuft!=NULL) free(allocbuft); /* .. */
+ free(allocrhs); /* drop any storage used */
+ free(allocbufa); /* .. */
+ free(allocbuft); /* .. */
/* [status is handled by caller] */
return res;
} /* decExpOp */
@@ -5852,8 +5852,8 @@ static decNumber *decLnOp(decNumber *res, const decNumber *rhs,
decFinish(res, set, &residue, status); /* cleanup/set flags */
} while(0); /* end protected */
- if (allocbufa!=NULL) free(allocbufa); /* drop any storage used */
- if (allocbufb!=NULL) free(allocbufb); /* .. */
+ free(allocbufa); /* drop any storage used */
+ free(allocbufb); /* .. */
/* [status is handled by caller] */
return res;
} /* decLnOp */
@@ -6017,8 +6017,8 @@ static decNumber * decQuantizeOp(decNumber *res, const decNumber *lhs,
} while(0); /* end protected */
#if DECSUBSET
- if (allocrhs!=NULL) free(allocrhs); /* drop any storage used */
- if (alloclhs!=NULL) free(alloclhs); /* .. */
+ free(allocrhs); /* drop any storage used */
+ free(alloclhs); /* .. */
#endif
return res;
} /* decQuantizeOp */
@@ -6200,8 +6200,8 @@ static decNumber *decCompareOp(decNumber *res, const decNumber *lhs,
}
}
#if DECSUBSET
- if (allocrhs!=NULL) free(allocrhs); /* free any storage used */
- if (alloclhs!=NULL) free(alloclhs); /* .. */
+ free(allocrhs); /* free any storage used */
+ free(alloclhs); /* .. */
#endif
return res;
} /* decCompareOp */
@@ -6335,7 +6335,7 @@ static Int decUnitCompare(const Unit *a, Int alength,
result=(*u==0 ? 0 : +1);
}
/* clean up and return the result */
- if (allocacc!=NULL) free(allocacc); /* drop any storage used */
+ free(allocacc); /* drop any storage used */
return result;
} /* decUnitCompare */
^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups
2015-08-26 11:17 [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups Daniel P. Berrange
` (7 preceding siblings ...)
2015-08-26 12:03 ` [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups Markus Armbruster
@ 2015-09-06 10:51 ` Michael Tokarev
8 siblings, 0 replies; 16+ messages in thread
From: Michael Tokarev @ 2015-09-06 10:51 UTC (permalink / raw)
To: Daniel P. Berrange, qemu-devel; +Cc: qemu-trivial, Markus Armbruster
26.08.2015 14:17, Daniel P. Berrange wrote:
> This is a series of misc trivial code cleanups that I
> originally used to illustrate the use of GNULIB's
> syntax-check facility:
>
> http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg06268.html
>
> Since it appears the license of the GNULIB syntax-check
> is problematic, this series has separated the fixes out
> from the GNULIB additions, to allow for possibility of
> merging them as-is.
Applied all 7 to -trivial.
With additional patch by Markus being 8/7 ;)
Nice work, thank you!
/mjt
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2015-09-06 10:51 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-26 11:17 [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups Daniel P. Berrange
2015-08-26 11:17 ` [Qemu-devel] [PATCH 1/7] maint: remove double semicolons in many files Daniel P. Berrange
2015-08-26 11:29 ` Marc-André Lureau
2015-08-26 11:17 ` [Qemu-devel] [PATCH 2/7] maint: remove / fix many doubled words Daniel P. Berrange
2015-08-26 11:31 ` Marc-André Lureau
2015-08-26 11:17 ` [Qemu-devel] [PATCH 3/7] maint: remove unused include for assert.h Daniel P. Berrange
2015-08-26 11:17 ` [Qemu-devel] [PATCH 4/7] maint: remove unused include for dirent.h Daniel P. Berrange
2015-08-26 11:17 ` [Qemu-devel] [PATCH 5/7] maint: remove unused include for signal.h Daniel P. Berrange
2015-08-26 11:17 ` [Qemu-devel] [PATCH 6/7] maint: remove unused include for strings.h Daniel P. Berrange
2015-08-26 11:17 ` [Qemu-devel] [PATCH 7/7] maint: avoid useless "if (foo) free(foo)" pattern Daniel P. Berrange
2015-08-26 11:36 ` Marc-André Lureau
2015-08-26 12:02 ` Markus Armbruster
2015-08-26 12:53 ` Eric Blake
2015-08-26 16:09 ` Markus Armbruster
2015-08-26 12:03 ` [Qemu-devel] [PATCH 0/7] Misc trivial code cleanups Markus Armbruster
2015-09-06 10:51 ` Michael Tokarev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).