maint: avoid useless "if (foo) free(foo)" pattern
My Coccinelle semantic patch finds a few more, because it also fixes up the equally pointless conditional if (foo) { free(foo); foo = NULL; } Result (feel free to squash it into your patch): Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
parent
ef1e1e0782
commit
012aef0734
@ -234,10 +234,8 @@ static int fifo_empty_elements_number(Exynos4210UartFIFO *q)
|
|||||||
|
|
||||||
static void fifo_reset(Exynos4210UartFIFO *q)
|
static void fifo_reset(Exynos4210UartFIFO *q)
|
||||||
{
|
{
|
||||||
if (q->data != NULL) {
|
|
||||||
g_free(q->data);
|
g_free(q->data);
|
||||||
q->data = NULL;
|
q->data = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
q->data = (uint8_t *)g_malloc0(q->size);
|
q->data = (uint8_t *)g_malloc0(q->size);
|
||||||
|
|
||||||
|
@ -3391,10 +3391,8 @@ static void pci_rtl8139_uninit(PCIDevice *dev)
|
|||||||
{
|
{
|
||||||
RTL8139State *s = RTL8139(dev);
|
RTL8139State *s = RTL8139(dev);
|
||||||
|
|
||||||
if (s->cplus_txbuffer) {
|
|
||||||
g_free(s->cplus_txbuffer);
|
g_free(s->cplus_txbuffer);
|
||||||
s->cplus_txbuffer = NULL;
|
s->cplus_txbuffer = NULL;
|
||||||
}
|
|
||||||
timer_del(s->timer);
|
timer_del(s->timer);
|
||||||
timer_free(s->timer);
|
timer_free(s->timer);
|
||||||
qemu_del_nic(s->nic);
|
qemu_del_nic(s->nic);
|
||||||
|
@ -1460,10 +1460,8 @@ static void spapr_pci_pre_save(void *opaque)
|
|||||||
gpointer key, value;
|
gpointer key, value;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (sphb->msi_devs) {
|
|
||||||
g_free(sphb->msi_devs);
|
g_free(sphb->msi_devs);
|
||||||
sphb->msi_devs = NULL;
|
sphb->msi_devs = NULL;
|
||||||
}
|
|
||||||
sphb->msi_devs_num = g_hash_table_size(sphb->msi);
|
sphb->msi_devs_num = g_hash_table_size(sphb->msi);
|
||||||
if (!sphb->msi_devs_num) {
|
if (!sphb->msi_devs_num) {
|
||||||
return;
|
return;
|
||||||
@ -1490,10 +1488,8 @@ static int spapr_pci_post_load(void *opaque, int version_id)
|
|||||||
sizeof(sphb->msi_devs[i].value));
|
sizeof(sphb->msi_devs[i].value));
|
||||||
g_hash_table_insert(sphb->msi, key, value);
|
g_hash_table_insert(sphb->msi, key, value);
|
||||||
}
|
}
|
||||||
if (sphb->msi_devs) {
|
|
||||||
g_free(sphb->msi_devs);
|
g_free(sphb->msi_devs);
|
||||||
sphb->msi_devs = NULL;
|
sphb->msi_devs = NULL;
|
||||||
}
|
|
||||||
sphb->msi_devs_num = 0;
|
sphb->msi_devs_num = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1169,11 +1169,9 @@ static void sdhci_uninitfn(SDHCIState *s)
|
|||||||
qemu_free_irq(s->eject_cb);
|
qemu_free_irq(s->eject_cb);
|
||||||
qemu_free_irq(s->ro_cb);
|
qemu_free_irq(s->ro_cb);
|
||||||
|
|
||||||
if (s->fifo_buffer) {
|
|
||||||
g_free(s->fifo_buffer);
|
g_free(s->fifo_buffer);
|
||||||
s->fifo_buffer = NULL;
|
s->fifo_buffer = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const VMStateDescription sdhci_vmstate = {
|
const VMStateDescription sdhci_vmstate = {
|
||||||
.name = "sdhci",
|
.name = "sdhci",
|
||||||
|
@ -95,11 +95,9 @@ static void usb_ehci_pci_exit(PCIDevice *dev)
|
|||||||
|
|
||||||
usb_ehci_unrealize(s, DEVICE(dev), NULL);
|
usb_ehci_unrealize(s, DEVICE(dev), NULL);
|
||||||
|
|
||||||
if (s->irq) {
|
|
||||||
g_free(s->irq);
|
g_free(s->irq);
|
||||||
s->irq = NULL;
|
s->irq = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void usb_ehci_pci_reset(DeviceState *dev)
|
static void usb_ehci_pci_reset(DeviceState *dev)
|
||||||
{
|
{
|
||||||
|
@ -139,11 +139,9 @@ static void hbitmap_test_teardown(TestHBitmapData *data,
|
|||||||
hbitmap_free(data->hb);
|
hbitmap_free(data->hb);
|
||||||
data->hb = NULL;
|
data->hb = NULL;
|
||||||
}
|
}
|
||||||
if (data->bits) {
|
|
||||||
g_free(data->bits);
|
g_free(data->bits);
|
||||||
data->bits = NULL;
|
data->bits = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Set a range in the HBitmap and in the shadow "simple" bitmap.
|
/* Set a range in the HBitmap and in the shadow "simple" bitmap.
|
||||||
* The two bitmaps are then tested against each other.
|
* The two bitmaps are then tested against each other.
|
||||||
|
@ -731,10 +731,8 @@ void tb_free(TranslationBlock *tb)
|
|||||||
|
|
||||||
static inline void invalidate_page_bitmap(PageDesc *p)
|
static inline void invalidate_page_bitmap(PageDesc *p)
|
||||||
{
|
{
|
||||||
if (p->code_bitmap) {
|
|
||||||
g_free(p->code_bitmap);
|
g_free(p->code_bitmap);
|
||||||
p->code_bitmap = NULL;
|
p->code_bitmap = NULL;
|
||||||
}
|
|
||||||
p->code_write_count = 0;
|
p->code_write_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
vl.c
2
vl.c
@ -534,11 +534,9 @@ const char *qemu_get_vm_name(void)
|
|||||||
|
|
||||||
static void res_free(void)
|
static void res_free(void)
|
||||||
{
|
{
|
||||||
if (boot_splash_filedata != NULL) {
|
|
||||||
g_free(boot_splash_filedata);
|
g_free(boot_splash_filedata);
|
||||||
boot_splash_filedata = NULL;
|
boot_splash_filedata = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static int default_driver_check(void *opaque, QemuOpts *opts, Error **errp)
|
static int default_driver_check(void *opaque, QemuOpts *opts, Error **errp)
|
||||||
{
|
{
|
||||||
|
@ -169,10 +169,8 @@ static void xen_remap_bucket(MapCacheEntry *entry,
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (entry->valid_mapping != NULL) {
|
|
||||||
g_free(entry->valid_mapping);
|
g_free(entry->valid_mapping);
|
||||||
entry->valid_mapping = NULL;
|
entry->valid_mapping = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < nb_pfn; i++) {
|
for (i = 0; i < nb_pfn; i++) {
|
||||||
pfns[i] = (address_index << (MCACHE_BUCKET_SHIFT-XC_PAGE_SHIFT)) + i;
|
pfns[i] = (address_index << (MCACHE_BUCKET_SHIFT-XC_PAGE_SHIFT)) + i;
|
||||||
|
Loading…
Reference in New Issue
Block a user