summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/alisp/alisp.c12
-rw-r--r--src/conf.c48
-rw-r--r--src/confmisc.c6
-rw-r--r--src/control/control.c6
-rw-r--r--src/control/control_shm.c3
-rw-r--r--src/control/hcontrol.c3
-rw-r--r--src/hwdep/hwdep.c3
-rw-r--r--src/instr/iwffff.c12
-rw-r--r--src/mixer/mixer.c6
-rw-r--r--src/mixer/simple_abst.c3
-rw-r--r--src/mixer/simple_none.c3
-rw-r--r--src/names.c15
-rw-r--r--src/pcm/pcm.c15
-rw-r--r--src/pcm/pcm_adpcm.c6
-rw-r--r--src/pcm/pcm_dmix.c6
-rw-r--r--src/pcm/pcm_dshare.c6
-rw-r--r--src/pcm/pcm_dsnoop.c6
-rw-r--r--src/pcm/pcm_file.c14
-rw-r--r--src/pcm/pcm_hw.c12
-rw-r--r--src/pcm/pcm_ladspa.c30
-rw-r--r--src/pcm/pcm_meter.c25
-rw-r--r--src/pcm/pcm_multi.c17
-rw-r--r--src/pcm/pcm_plug.c3
-rw-r--r--src/pcm/pcm_route.c3
-rw-r--r--src/pcm/pcm_share.c6
-rw-r--r--src/pcm/pcm_shm.c3
-rw-r--r--src/rawmidi/rawmidi.c3
-rw-r--r--src/rawmidi/rawmidi_hw.c7
-rw-r--r--src/rawmidi/rawmidi_virt.c7
-rw-r--r--src/seq/seq.c12
-rw-r--r--src/seq/seq_midi_event.c6
-rw-r--r--src/timer/timer.c3
-rw-r--r--src/timer/timer_query.c3
33 files changed, 108 insertions, 205 deletions
diff --git a/src/alisp/alisp.c b/src/alisp/alisp.c
index f15b9c77..04db6c6e 100644
--- a/src/alisp/alisp.c
+++ b/src/alisp/alisp.c
@@ -165,8 +165,7 @@ static void free_object(struct alisp_object * p)
switch (alisp_get_type(p)) {
case ALISP_OBJ_STRING:
case ALISP_OBJ_IDENTIFIER:
- if (p->value.s)
- free(p->value.s);
+ free(p->value.s);
alisp_set_type(p, ALISP_OBJ_INTEGER);
break;
default:
@@ -523,8 +522,7 @@ static int init_lex(struct alisp_instance *instance)
static void done_lex(struct alisp_instance *instance)
{
- if (instance->token_buffer)
- free(instance->token_buffer);
+ free(instance->token_buffer);
}
static char * extend_buf(struct alisp_instance *instance, char *p)
@@ -1184,8 +1182,7 @@ static struct alisp_object * F_concat(struct alisp_instance *instance, struct al
str1 = realloc(str, (str ? strlen(str) : 0) + strlen(p1->value.s) + 1);
if (str1 == NULL) {
nomem();
- if (str)
- free(str);
+ free(str);
return NULL;
}
if (str == NULL)
@@ -2366,8 +2363,7 @@ static struct alisp_object * eval_func(struct alisp_instance *instance, struct a
}
_end:
- if (eval_objs)
- free(eval_objs);
+ free(eval_objs);
return p4;
} else {
diff --git a/src/conf.c b/src/conf.c
index 3667ac06..10555328 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -980,8 +980,7 @@ static int parse_value(snd_config_t **_n, snd_config_t *father, input_t *input,
if (err < 0)
return err;
}
- if (n->u.string)
- free(n->u.string);
+ free(n->u.string);
n->u.string = s;
*_n = n;
return 0;
@@ -1056,8 +1055,7 @@ static int parse_array_def(snd_config_t *father, input_t *input, int idx, int sk
}
err = 0;
__end:
- if (id)
- free(id);
+ free(id);
return err;
}
@@ -1218,8 +1216,7 @@ static int parse_def(snd_config_t *father, input_t *input, int skip, int overrid
unget_char(c, input);
}
__end:
- if (id)
- free(id);
+ free(id);
return err;
}
@@ -1446,8 +1443,7 @@ int snd_config_substitute(snd_config_t *dst, snd_config_t *src)
if (err < 0)
return err;
}
- if (dst->id)
- free(dst->id);
+ free(dst->id);
dst->id = src->id;
dst->type = src->type;
dst->u = src->u;
@@ -1528,8 +1524,7 @@ int snd_config_set_id(snd_config_t *config, const char *id)
new_id = strdup(id);
if (!new_id)
return -ENOMEM;
- if (config->id)
- free(config->id);
+ free(config->id);
config->id = new_id;
return 0;
}
@@ -1696,16 +1691,14 @@ int snd_config_delete(snd_config_t *config)
break;
}
case SND_CONFIG_TYPE_STRING:
- if (config->u.string)
- free(config->u.string);
+ free(config->u.string);
break;
default:
break;
}
if (config->father)
list_del(&config->list);
- if (config->id)
- free(config->id);
+ free(config->id);
free(config);
return 0;
}
@@ -2023,8 +2016,7 @@ int snd_config_set_string(snd_config_t *config, const char *value)
} else {
new_string = NULL;
}
- if (config->u.string)
- free(config->u.string);
+ free(config->u.string);
config->u.string = new_string;
return 0;
}
@@ -2091,8 +2083,7 @@ int snd_config_set_ascii(snd_config_t *config, const char *ascii)
char *ptr = strdup(ascii);
if (ptr == NULL)
return -ENOMEM;
- if (config->u.string)
- free(config->u.string);
+ free(config->u.string);
config->u.string = ptr;
}
break;
@@ -2702,8 +2693,7 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c
if (err >= 0 && nroot)
err = snd_config_substitute(root, nroot);
}
- if (buf)
- free(buf);
+ free(buf);
if (err < 0)
return err;
return 0;
@@ -2844,11 +2834,10 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t
*dst = NULL;
err = 0;
_err:
- for (idx = 0; idx < fi_count; idx++)
- if (fi[idx].name)
- free(fi[idx].name);
- if (fi)
- free(fi);
+ if (fi)
+ for (idx = 0; idx < fi_count; idx++)
+ free(fi[idx].name);
+ free(fi);
snd_config_delete(n);
return err;
}
@@ -2905,8 +2894,7 @@ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config,
__err:
if (private_data)
snd_config_delete(private_data);
- if (fdriver)
- free(fdriver);
+ free(fdriver);
if (err < 0)
return err;
}
@@ -3108,8 +3096,7 @@ int snd_config_update_free(snd_config_update_t *update)
assert(update);
for (k = 0; k < update->count; k++)
free(update->finfo[k].name);
- if (update->finfo)
- free(update->finfo);
+ free(update->finfo);
free(update);
return 0;
}
@@ -3500,8 +3487,7 @@ static int _snd_config_evaluate(snd_config_t *src,
}
}
_errbuf:
- if (buf)
- free(buf);
+ free(buf);
if (err < 0)
return err;
return 0;
diff --git a/src/confmisc.c b/src/confmisc.c
index 2b5efb14..147ca647 100644
--- a/src/confmisc.c
+++ b/src/confmisc.c
@@ -295,8 +295,7 @@ int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
free(res);
}
__error:
- if (def)
- free(def);
+ free(def);
return err;
}
#ifndef DOC_HIDDEN
@@ -419,8 +418,7 @@ int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
tmp = realloc(res, len + len1 + 1);
if (tmp == NULL) {
free(ptr);
- if (res)
- free(res);
+ free(res);
err = -ENOMEM;
goto __error;
}
diff --git a/src/control/control.c b/src/control/control.c
index cb4d92be..4bf96e57 100644
--- a/src/control/control.c
+++ b/src/control/control.c
@@ -94,8 +94,7 @@ int snd_ctl_close(snd_ctl_t *ctl)
snd_async_del_handler(h);
}
err = ctl->ops->close(ctl);
- if (ctl->name)
- free(ctl->name);
+ free(ctl->name);
if (ctl->dl_handle)
snd_dlclose(ctl->dl_handle);
free(ctl);
@@ -925,8 +924,7 @@ const char *snd_ctl_event_type_name(snd_ctl_event_type_t type)
*/
int snd_ctl_elem_list_alloc_space(snd_ctl_elem_list_t *obj, unsigned int entries)
{
- if (obj->pids)
- free(obj->pids);
+ free(obj->pids);
obj->pids = calloc(entries, sizeof(*obj->pids));
if (!obj->pids) {
obj->space = 0;
diff --git a/src/control/control_shm.c b/src/control/control_shm.c
index 903be396..fbb12366 100644
--- a/src/control/control_shm.c
+++ b/src/control/control_shm.c
@@ -555,8 +555,7 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname
close(sock);
if (ctrl)
shmdt(ctrl);
- if (shm)
- free(shm);
+ free(shm);
return result;
}
diff --git a/src/control/hcontrol.c b/src/control/hcontrol.c
index 635f526f..5d20e740 100644
--- a/src/control/hcontrol.c
+++ b/src/control/hcontrol.c
@@ -606,8 +606,7 @@ int snd_hctl_load(snd_hctl_t *hctl)
}
err = snd_ctl_subscribe_events(hctl->ctl, 1);
_end:
- if (list.pids)
- free(list.pids);
+ free(list.pids);
return err;
}
diff --git a/src/hwdep/hwdep.c b/src/hwdep/hwdep.c
index 6a5e7872..4d4490cd 100644
--- a/src/hwdep/hwdep.c
+++ b/src/hwdep/hwdep.c
@@ -207,8 +207,7 @@ int snd_hwdep_close(snd_hwdep_t *hwdep)
int err;
assert(hwdep);
err = hwdep->ops->close(hwdep);
- if (hwdep->name)
- free(hwdep->name);
+ free(hwdep->name);
free(hwdep);
return err;
}
diff --git a/src/instr/iwffff.c b/src/instr/iwffff.c
index 637045bc..7f15ed03 100644
--- a/src/instr/iwffff.c
+++ b/src/instr/iwffff.c
@@ -382,12 +382,9 @@ int snd_instr_iwffff_close(snd_iwffff_handle_t *handle)
{
if (handle == NULL)
return -EINVAL;
- if (handle->dat_filename)
- free(handle->dat_filename);
- if (handle->fff_filename)
- free(handle->fff_filename);
- if (handle->fff_data)
- free(handle->fff_data);
+ free(handle->dat_filename);
+ free(handle->fff_filename);
+ free(handle->fff_data);
free(handle);
return 0;
}
@@ -396,8 +393,7 @@ static void free_wave(iwffff_wave_t *wave)
{
if (wave == NULL)
return;
- if (wave->address.ptr != NULL)
- free(wave->address.ptr);
+ free(wave->address.ptr);
free(wave);
}
diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c
index 5ef0ba79..d2edeea8 100644
--- a/src/mixer/mixer.c
+++ b/src/mixer/mixer.c
@@ -607,10 +607,8 @@ int snd_mixer_close(snd_mixer_t *mixer)
}
assert(list_empty(&mixer->elems));
assert(mixer->count == 0);
- if (mixer->pelems) {
- free(mixer->pelems);
- mixer->pelems = NULL;
- }
+ free(mixer->pelems);
+ mixer->pelems = NULL;
while (!list_empty(&mixer->slaves)) {
int err;
snd_mixer_slave_t *s;
diff --git a/src/mixer/simple_abst.c b/src/mixer/simple_abst.c
index 789216dc..45aedb05 100644
--- a/src/mixer/simple_abst.c
+++ b/src/mixer/simple_abst.c
@@ -182,8 +182,7 @@ static void private_free(snd_mixer_class_t *class)
snd_hctl_close(priv->hctl);
} else if (priv->ctl)
snd_ctl_close(priv->ctl);
- if (priv->device)
- free(priv->device);
+ free(priv->device);
free(priv);
}
diff --git a/src/mixer/simple_none.c b/src/mixer/simple_none.c
index fdb57f44..43563167 100644
--- a/src/mixer/simple_none.c
+++ b/src/mixer/simple_none.c
@@ -1388,8 +1388,7 @@ int snd_mixer_simple_none_register(snd_mixer_t *mixer,
snd_mixer_class_set_compare(class, snd_mixer_selem_compare);
err = snd_mixer_class_register(class, mixer);
if (err < 0) {
- if (class)
- free(class);
+ free(class);
return err;
}
if (classp)
diff --git a/src/names.c b/src/names.c
index dbbdaa90..652477af 100644
--- a/src/names.c
+++ b/src/names.c
@@ -105,17 +105,14 @@ static int names_parse(snd_config_t *top, const char *iface, snd_devname_t **lis
}
last = dn;
} else {
- if (comment != NULL)
- free(comment);
+ free(comment);
}
}
return 0;
_err:
- if (name)
- free(name);
- if (comment)
- free(comment);
+ free(name);
+ free(comment);
return err;
}
@@ -189,10 +186,8 @@ void snd_names_list_free(snd_devname_t *list)
while (list != NULL) {
next = list->next;
- if (list->name)
- free(list->name);
- if (list->comment)
- free(list->comment);
+ free(list->name);
+ free(list->comment);
free(list);
list = next;
}
diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c
index 0af6f2aa..47f3501f 100644
--- a/src/pcm/pcm.c
+++ b/src/pcm/pcm.c
@@ -2102,10 +2102,8 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
}
if (type_conf)
snd_config_delete(type_conf);
- if (buf)
- free(buf);
- if (buf1)
- free(buf1);
+ free(buf);
+ free(buf1);
return err;
}
@@ -2187,12 +2185,9 @@ int snd_pcm_new(snd_pcm_t **pcmp, snd_pcm_type_t type, const char *name,
int snd_pcm_free(snd_pcm_t *pcm)
{
assert(pcm);
- if (pcm->name)
- free(pcm->name);
- if (pcm->hw.link_dst)
- free(pcm->hw.link_dst);
- if (pcm->appl.link_dst)
- free(pcm->appl.link_dst);
+ free(pcm->name);
+ free(pcm->hw.link_dst);
+ free(pcm->appl.link_dst);
if (pcm->dl_handle)
snd_dlclose(pcm->dl_handle);
free(pcm);
diff --git a/src/pcm/pcm_adpcm.c b/src/pcm/pcm_adpcm.c
index 8350dbec..416c37f4 100644
--- a/src/pcm/pcm_adpcm.c
+++ b/src/pcm/pcm_adpcm.c
@@ -449,10 +449,8 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
static int snd_pcm_adpcm_hw_free(snd_pcm_t *pcm)
{
snd_pcm_adpcm_t *adpcm = pcm->private_data;
- if (adpcm->states) {
- free(adpcm->states);
- adpcm->states = 0;
- }
+ free(adpcm->states);
+ adpcm->states = NULL;
return snd_pcm_hw_free(adpcm->plug.gen.slave);
}
diff --git a/src/pcm/pcm_dmix.c b/src/pcm/pcm_dmix.c
index 41a6bd8f..ed500b85 100644
--- a/src/pcm/pcm_dmix.c
+++ b/src/pcm/pcm_dmix.c
@@ -639,8 +639,7 @@ static int snd_pcm_dmix_close(snd_pcm_t *pcm)
shm_sum_discard(dmix);
snd_pcm_direct_shm_discard(dmix);
snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT);
- if (dmix->bindings)
- free(dmix->bindings);
+ free(dmix->bindings);
pcm->private_data = NULL;
free(dmix);
return 0;
@@ -941,8 +940,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT);
_err_nosem:
if (dmix) {
- if (dmix->bindings)
- free(dmix->bindings);
+ free(dmix->bindings);
free(dmix);
}
if (pcm)
diff --git a/src/pcm/pcm_dshare.c b/src/pcm/pcm_dshare.c
index 2d719dc9..d54b4031 100644
--- a/src/pcm/pcm_dshare.c
+++ b/src/pcm/pcm_dshare.c
@@ -466,8 +466,7 @@ static int snd_pcm_dshare_close(snd_pcm_t *pcm)
snd_pcm_direct_client_discard(dshare);
snd_pcm_direct_shm_discard(dshare);
snd_pcm_direct_semaphore_up(dshare, DIRECT_IPC_SEM_CLIENT);
- if (dshare->bindings)
- free(dshare->bindings);
+ free(dshare->bindings);
pcm->private_data = NULL;
free(dshare);
return 0;
@@ -763,8 +762,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_direct_semaphore_up(dshare, DIRECT_IPC_SEM_CLIENT);
_err_nosem:
if (dshare) {
- if (dshare->bindings)
- free(dshare->bindings);
+ free(dshare->bindings);
free(dshare);
}
if (pcm)
diff --git a/src/pcm/pcm_dsnoop.c b/src/pcm/pcm_dsnoop.c
index d3a2a0b8..fbb9d046 100644
--- a/src/pcm/pcm_dsnoop.c
+++ b/src/pcm/pcm_dsnoop.c
@@ -362,8 +362,7 @@ static int snd_pcm_dsnoop_close(snd_pcm_t *pcm)
snd_pcm_direct_client_discard(dsnoop);
snd_pcm_direct_shm_discard(dsnoop);
snd_pcm_direct_semaphore_up(dsnoop, DIRECT_IPC_SEM_CLIENT);
- if (dsnoop->bindings)
- free(dsnoop->bindings);
+ free(dsnoop->bindings);
pcm->private_data = NULL;
free(dsnoop);
return 0;
@@ -636,8 +635,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
snd_pcm_direct_semaphore_up(dsnoop, DIRECT_IPC_SEM_CLIENT);
_err_nosem:
if (dsnoop) {
- if (dsnoop->bindings)
- free(dsnoop->bindings);
+ free(dsnoop->bindings);
free(dsnoop);
}
if (pcm)
diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c
index 18951cc2..9e419613 100644
--- a/src/pcm/pcm_file.c
+++ b/src/pcm/pcm_file.c
@@ -263,13 +263,10 @@ static snd_pcm_sframes_t snd_pcm_file_mmap_commit(snd_pcm_t *pcm,
static int snd_pcm_file_hw_free(snd_pcm_t *pcm)
{
snd_pcm_file_t *file = pcm->private_data;
- if (file->wbuf) {
- free(file->wbuf);
- if (file->wbuf_areas)
- free(file->wbuf_areas);
- file->wbuf = 0;
- file->wbuf_areas = 0;
- }
+ free(file->wbuf);
+ free(file->wbuf_areas);
+ file->wbuf = NULL;
+ file->wbuf_areas = NULL;
return snd_pcm_hw_free(file->gen.slave);
}
@@ -418,8 +415,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
err = snd_pcm_new(&pcm, SND_PCM_TYPE_FILE, name, slave->stream, slave->mode);
if (err < 0) {
- if (fname)
- free(file->fname);
+ free(file->fname);
free(file);
return err;
}
diff --git a/src/pcm/pcm_hw.c b/src/pcm/pcm_hw.c
index 356576fa..ef725d26 100644
--- a/src/pcm/pcm_hw.c
+++ b/src/pcm/pcm_hw.c
@@ -843,10 +843,8 @@ static int snd_pcm_hw_munmap_status(snd_pcm_t *pcm)
snd_pcm_hw_t *hw = pcm->private_data;
int err;
if (hw->sync_ptr_ioctl) {
- if (hw->sync_ptr) {
- free(hw->sync_ptr);
- hw->sync_ptr = NULL;
- }
+ free(hw->sync_ptr);
+ hw->sync_ptr = NULL;
} else {
if (munmap((void*)hw->mmap_status, page_align(sizeof(*hw->mmap_status))) < 0) {
err = -errno;
@@ -862,10 +860,8 @@ static int snd_pcm_hw_munmap_control(snd_pcm_t *pcm)
snd_pcm_hw_t *hw = pcm->private_data;
int err;
if (hw->sync_ptr_ioctl) {
- if (hw->sync_ptr) {
- free(hw->sync_ptr);
- hw->sync_ptr = NULL;
- }
+ free(hw->sync_ptr);
+ hw->sync_ptr = NULL;
} else {
if (munmap(hw->mmap_control, page_align(sizeof(*hw->mmap_control))) < 0) {
err = -errno;
diff --git a/src/pcm/pcm_ladspa.c b/src/pcm/pcm_ladspa.c
index d4432ae3..52296c05 100644
--- a/src/pcm/pcm_ladspa.c
+++ b/src/pcm/pcm_ladspa.c
@@ -175,10 +175,8 @@ static int snd_pcm_ladspa_find_port_idx(unsigned int *res,
static void snd_pcm_ladspa_free_io(snd_pcm_ladspa_plugin_io_t *io)
{
- if (io->controls)
- free(io->controls);
- if (io->controls_initialized)
- free(io->controls_initialized);
+ free(io->controls);
+ free(io->controls_initialized);
}
static void snd_pcm_ladspa_free_plugins(struct list_head *plugins)
@@ -189,8 +187,7 @@ static void snd_pcm_ladspa_free_plugins(struct list_head *plugins)
snd_pcm_ladspa_free_io(&plugin->output);
if (plugin->dl_handle)
dlclose(plugin->dl_handle);
- if (plugin->filename)
- free(plugin->filename);
+ free(plugin->filename);
list_del(&plugin->list);
free(plugin);
}
@@ -203,8 +200,7 @@ static void snd_pcm_ladspa_free(snd_pcm_ladspa_t *ladspa)
snd_pcm_ladspa_free_plugins(&ladspa->pplugins);
snd_pcm_ladspa_free_plugins(&ladspa->cplugins);
for (idx = 0; idx < 2; idx++) {
- if (ladspa->zero[idx])
- free(ladspa->zero[idx]);
+ free(ladspa->zero[idx]);
ladspa->zero[idx] = NULL;
}
ladspa->allocated = 0;
@@ -317,10 +313,8 @@ static int snd_pcm_ladspa_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params
static void snd_pcm_ladspa_free_eps(snd_pcm_ladspa_eps_t *eps)
{
- if (eps->channels.array)
- free(eps->channels.array);
- if (eps->ports.array)
- free(eps->ports.array);
+ free(eps->channels.array);
+ free(eps->ports.array);
}
static void snd_pcm_ladspa_free_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *ladspa, int cleanup)
@@ -340,14 +334,12 @@ static void snd_pcm_ladspa_free_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *lads
plugin->desc->cleanup(instance->handle);
if (instance->input.m_data) {
for (idx = 0; idx < instance->input.channels.size; idx++)
- if (instance->input.m_data[idx])
- free(instance->input.m_data[idx]);
+ free(instance->input.m_data[idx]);
free(instance->input.m_data);
}
if (instance->output.m_data) {
for (idx = 0; idx < instance->output.channels.size; idx++)
- if (instance->output.m_data[idx])
- free(instance->output.m_data[idx]);
+ free(instance->output.m_data[idx]);
free(instance->output.m_data);
}
list_del(&(instance->list));
@@ -789,10 +781,8 @@ static int snd_pcm_ladspa_allocate_memory(snd_pcm_t *pcm, snd_pcm_ladspa_t *lads
for (idx = 0; idx < instance->output.channels.size; idx++) {
chn = instance->output.channels.array[idx];
if (instance->output.data[idx] == pchannels[chn]) {
- if (instance->output.m_data[idx]) {
- free(instance->output.m_data[idx]);
- instance->output.m_data[idx] = NULL;
- }
+ free(instance->output.m_data[idx]);
+ instance->output.m_data[idx] = NULL;
if (chn < ochannels) {
instance->output.data[idx] = NULL;
} else {
diff --git a/src/pcm/pcm_meter.c b/src/pcm/pcm_meter.c
index b84747c4..8ff5d831 100644
--- a/src/pcm/pcm_meter.c
+++ b/src/pcm/pcm_meter.c
@@ -153,8 +153,7 @@ static int snd_pcm_meter_update_scope(snd_pcm_t *pcm)
static int snd_pcm_scope_remove(snd_pcm_scope_t *scope)
{
- if (scope->name)
- free((void *)scope->name);
+ free(scope->name);
scope->ops->close(scope);
list_del(&scope->list);
free(scope);
@@ -480,12 +479,10 @@ static int snd_pcm_meter_hw_free(snd_pcm_t *pcm)
pthread_mutex_unlock(&meter->running_mutex);
err = pthread_join(meter->thread, 0);
assert(err == 0);
- if (meter->buf) {
- free(meter->buf);
- free(meter->buf_areas);
- meter->buf = 0;
- meter->buf_areas = 0;
- }
+ free(meter->buf);
+ free(meter->buf_areas);
+ meter->buf = NULL;
+ meter->buf_areas = NULL;
return snd_pcm_hw_free(meter->gen.slave);
}
@@ -1028,15 +1025,13 @@ static int s16_enable(snd_pcm_scope_t *scope)
}
s16->buf = malloc(meter->buf_size * 2 * spcm->channels);
if (!s16->buf) {
- if (s16->adpcm_states)
- free(s16->adpcm_states);
+ free(s16->adpcm_states);
return -ENOMEM;
}
a = calloc(spcm->channels, sizeof(*a));
if (!a) {
free(s16->buf);
- if (s16->adpcm_states)
- free(s16->adpcm_states);
+ free(s16->adpcm_states);
return -ENOMEM;
}
s16->buf_areas = a;
@@ -1051,10 +1046,8 @@ static int s16_enable(snd_pcm_scope_t *scope)
static void s16_disable(snd_pcm_scope_t *scope)
{
snd_pcm_scope_s16_t *s16 = scope->private_data;
- if (s16->adpcm_states) {
- free(s16->adpcm_states);
- s16->adpcm_states = NULL;
- }
+ free(s16->adpcm_states);
+ s16->adpcm_states = NULL;
free(s16->buf);
s16->buf = NULL;
free(s16->buf_areas);
diff --git a/src/pcm/pcm_multi.c b/src/pcm/pcm_multi.c
index 9c492f95..22bfd9a4 100644
--- a/src/pcm/pcm_multi.c
+++ b/src/pcm/pcm_multi.c
@@ -790,7 +790,7 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
multi->channels = calloc(channels_count, sizeof(*multi->channels));
if (!multi->channels) {
free(multi->slaves);
- free(multi->channels);
+ free(multi);
return -ENOMEM;
}
for (i = 0; i < slaves_count; ++i) {
@@ -1130,16 +1130,11 @@ _free:
}
free(slaves_conf);
}
- if (slaves_pcm)
- free(slaves_pcm);
- if (slaves_channels)
- free(slaves_channels);
- if (channels_sidx)
- free(channels_sidx);
- if (channels_schannel)
- free(channels_schannel);
- if (slaves_id)
- free(slaves_id);
+ free(slaves_pcm);
+ free(slaves_channels);
+ free(channels_sidx);
+ free(channels_schannel);
+ free(slaves_id);
return err;
}
#ifndef DOC_HIDDEN
diff --git a/src/pcm/pcm_plug.c b/src/pcm/pcm_plug.c
index 15204d75..98ee6835 100644
--- a/src/pcm/pcm_plug.c
+++ b/src/pcm/pcm_plug.c
@@ -62,8 +62,7 @@ static int snd_pcm_plug_close(snd_pcm_t *pcm)
{
snd_pcm_plug_t *plug = pcm->private_data;
int err, result = 0;
- if (plug->ttable)
- free(plug->ttable);
+ free(plug->ttable);
assert(plug->gen.slave == plug->req_slave);
if (plug->gen.close_slave) {
snd_pcm_unlink_hw_ptr(pcm, plug->req_slave);
diff --git a/src/pcm/pcm_route.c b/src/pcm/pcm_route.c
index daddf7c7..a7f7699b 100644
--- a/src/pcm/pcm_route.c
+++ b/src/pcm/pcm_route.c
@@ -513,8 +513,7 @@ static int snd_pcm_route_close(snd_pcm_t *pcm)
if (params->dsts) {
for (dst_channel = 0; dst_channel < params->ndsts; ++dst_channel) {
- if (params->dsts[dst_channel].srcs != NULL)
- free(params->dsts[dst_channel].srcs);
+ free(params->dsts[dst_channel].srcs);
}
free(params->dsts);
}
diff --git a/src/pcm/pcm_share.c b/src/pcm/pcm_share.c
index d73fb8b2..cc65907d 100644
--- a/src/pcm/pcm_share.c
+++ b/src/pcm/pcm_share.c
@@ -1689,10 +1689,8 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name,
speriod_time, sbuffer_time,
channels, channels_map, stream, mode);
_free:
- if (channels_map)
- free(channels_map);
- if (sname)
- free((char *)sname);
+ free(channels_map);
+ free((char *)sname);
return err;
}
#ifndef DOC_HIDDEN
diff --git a/src/pcm/pcm_shm.c b/src/pcm/pcm_shm.c
index 0640c4bb..c9439661 100644
--- a/src/pcm/pcm_shm.c
+++ b/src/pcm/pcm_shm.c
@@ -773,8 +773,7 @@ int snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name,
close(sock);
if (ctrl)
shmdt(ctrl);
- if (shm)
- free(shm);
+ free(shm);
return result;
}
diff --git a/src/rawmidi/rawmidi.c b/src/rawmidi/rawmidi.c
index 2d509097..87ef91c9 100644
--- a/src/rawmidi/rawmidi.c
+++ b/src/rawmidi/rawmidi.c
@@ -342,8 +342,7 @@ int snd_rawmidi_close(snd_rawmidi_t *rawmidi)
int err;
assert(rawmidi);
err = rawmidi->ops->close(rawmidi);
- if (rawmidi->name)
- free(rawmidi->name);
+ free(rawmidi->name);
if (rawmidi->dl_handle)
snd_dlclose(rawmidi->dl_handle);
free(rawmidi);
diff --git a/src/rawmidi/rawmidi_hw.c b/src/rawmidi/rawmidi_hw.c
index b15dadb6..d33bbbe3 100644
--- a/src/rawmidi/rawmidi_hw.c
+++ b/src/rawmidi/rawmidi_hw.c
@@ -316,11 +316,10 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
_nomem:
close(fd);
- if (hw)
- free(hw);
- if (inputp && *inputp)
+ free(hw);
+ if (inputp)
free(*inputp);
- if (outputp && *outputp)
+ if (outputp)
free(*outputp);
return -ENOMEM;
}
diff --git a/src/rawmidi/rawmidi_virt.c b/src/rawmidi/rawmidi_virt.c
index 51123e42..a06476aa 100644
--- a/src/rawmidi/rawmidi_virt.c
+++ b/src/rawmidi/rawmidi_virt.c
@@ -385,11 +385,10 @@ int snd_rawmidi_virtual_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
snd_seq_close(seq_handle);
if (virt->midi_event)
snd_midi_event_free(virt->midi_event);
- if (virt)
- free(virt);
- if (inputp && *inputp)
+ free(virt);
+ if (inputp)
free(*inputp);
- if (outputp && *outputp)
+ if (outputp)
free(*outputp);
return err;
}
diff --git a/src/seq/seq.c b/src/seq/seq.c
index 07954a35..a2424c9a 100644
--- a/src/seq/seq.c
+++ b/src/seq/seq.c
@@ -1029,14 +1029,10 @@ int snd_seq_close(snd_seq_t *seq)
int err;
assert(seq);
err = seq->ops->close(seq);
- if (seq->obuf)
- free(seq->obuf);
- if (seq->ibuf)
- free(seq->ibuf);
- if (seq->tmpbuf)
- free(seq->tmpbuf);
- if (seq->name)
- free(seq->name);
+ free(seq->obuf);
+ free(seq->ibuf);
+ free(seq->tmpbuf);
+ free(seq->name);
free(seq);
return err;
}
diff --git a/src/seq/seq_midi_event.c b/src/seq/seq_midi_event.c
index b1495456..20ba808a 100644
--- a/src/seq/seq_midi_event.c
+++ b/src/seq/seq_midi_event.c
@@ -167,8 +167,7 @@ int snd_midi_event_new(size_t bufsize, snd_midi_event_t **rdev)
void snd_midi_event_free(snd_midi_event_t *dev)
{
if (dev != NULL) {
- if (dev->buf)
- free(dev->buf);
+ free(dev->buf);
free(dev);
}
}
@@ -253,8 +252,7 @@ int snd_midi_event_resize_buffer(snd_midi_event_t *dev, size_t bufsize)
dev->buf = new_buf;
dev->bufsize = bufsize;
reset_encode(dev);
- if (old_buf)
- free(old_buf);
+ free(old_buf);
return 0;
}
diff --git a/src/timer/timer.c b/src/timer/timer.c
index 8b3da1f2..fbb2624e 100644
--- a/src/timer/timer.c
+++ b/src/timer/timer.c
@@ -243,8 +243,7 @@ int snd_timer_close(snd_timer_t *timer)
snd_async_del_handler(h);
}
err = timer->ops->close(timer);
- if (timer->name)
- free(timer->name);
+ free(timer->name);
free(timer);
return err;
}
diff --git a/src/timer/timer_query.c b/src/timer/timer_query.c
index 58c2d5a3..bd88edb6 100644
--- a/src/timer/timer_query.c
+++ b/src/timer/timer_query.c
@@ -197,8 +197,7 @@ int snd_timer_query_close(snd_timer_query_t *timer)
int err;
assert(timer);
err = timer->ops->close(timer);
- if (timer->name)
- free(timer->name);
+ free(timer->name);
free(timer);
return err;
}