mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2026-02-08 10:06:19 -05:00
coverity.com fixes - initial round
This commit tries to fix a bunch of issues found by coverity.com. Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
f0679e5de2
commit
47f4f9b73b
40 changed files with 283 additions and 133 deletions
|
|
@ -770,7 +770,7 @@ static int remap_map_elem_write(snd_ctl_remap_t *priv, snd_ctl_elem_value_t *con
|
|||
}
|
||||
for (src_index = 1; src_index < mctl->src_channels; src_index++) {
|
||||
dst = mctl->channel_map[base_idx + src_index];
|
||||
if ((unsigned long)dst < ARRAY_SIZE(control->value.integer.value)) {
|
||||
if ((unsigned long)dst < ARRAY_SIZE(control->value.integer64.value)) {
|
||||
changes |= control2.value.integer64.value[dst] != control->value.integer64.value[index];
|
||||
control2.value.integer64.value[dst] = control->value.integer64.value[index];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ static int snd_ctl_shm_action_fd(snd_ctl_t *ctl, int *fd)
|
|||
{
|
||||
snd_ctl_shm_t *shm = ctl->private_data;
|
||||
int err;
|
||||
char buf[1];
|
||||
char buf[1] = {0};
|
||||
volatile snd_ctl_shm_ctrl_t *ctrl = shm->ctrl;
|
||||
err = write(shm->socket, buf, 1);
|
||||
if (err != 1)
|
||||
|
|
@ -483,6 +483,11 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname
|
|||
result = -EINVAL;
|
||||
goto _err;
|
||||
}
|
||||
if (ans.result < INT_MIN || ans.result > INT_MAX) {
|
||||
snd_error(CONTROL, "invalid data error");
|
||||
result = -EINVAL;
|
||||
goto _err;
|
||||
}
|
||||
result = ans.result;
|
||||
if (result < 0)
|
||||
goto _err;
|
||||
|
|
@ -519,7 +524,8 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname
|
|||
return 0;
|
||||
|
||||
_err:
|
||||
close(sock);
|
||||
if (sock >= 0)
|
||||
close(sock);
|
||||
if (ctrl)
|
||||
shmdt(ctrl);
|
||||
free(shm);
|
||||
|
|
|
|||
|
|
@ -587,7 +587,7 @@ int snd_device_name_hint(int card, const char *iface, void ***hints)
|
|||
struct hint_list list;
|
||||
char ehints[24];
|
||||
const char *str;
|
||||
snd_config_t *conf, *local_config = NULL, *local_config_rw = NULL;
|
||||
snd_config_t *conf, *local_config = NULL, *local_config_rw;
|
||||
snd_config_update_t *local_config_update = NULL;
|
||||
snd_config_iterator_t i, next;
|
||||
int err;
|
||||
|
|
@ -628,6 +628,8 @@ int snd_device_name_hint(int card, const char *iface, void ***hints)
|
|||
err = get_card_name(&list, card);
|
||||
if (err >= 0)
|
||||
err = add_card(local_config, local_config_rw, &list, card);
|
||||
if (err < 0)
|
||||
goto __error;
|
||||
} else {
|
||||
add_software_devices(local_config, local_config_rw, &list);
|
||||
err = snd_card_next(&card);
|
||||
|
|
@ -669,10 +671,8 @@ int snd_device_name_hint(int card, const char *iface, void ***hints)
|
|||
else
|
||||
*hints = (void **)list.list;
|
||||
free(list.cardname);
|
||||
if (local_config_rw)
|
||||
snd_config_delete(local_config_rw);
|
||||
if (local_config)
|
||||
snd_config_delete(local_config);
|
||||
snd_config_delete(local_config_rw);
|
||||
snd_config_delete(local_config);
|
||||
if (local_config_update)
|
||||
snd_config_update_free(local_config_update);
|
||||
return err;
|
||||
|
|
|
|||
|
|
@ -221,10 +221,12 @@ static int snd_config_get_ctl_elem_enumerated(snd_config_t *n, snd_ctl_t *ctl,
|
|||
unsigned int idx, items;
|
||||
switch (snd_config_get_type(n)) {
|
||||
case SND_CONFIG_TYPE_INTEGER:
|
||||
snd_config_get_integer(n, &val);
|
||||
if (snd_config_get_integer(n, &val) < 0)
|
||||
return -1;
|
||||
return val;
|
||||
case SND_CONFIG_TYPE_STRING:
|
||||
snd_config_get_string(n, &str);
|
||||
if (snd_config_get_string(n, &str) < 0)
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
|
|
@ -586,8 +588,7 @@ static int add_elem(snd_sctl_t *h, snd_config_t *_conf, snd_config_t *private_da
|
|||
if (err != -ENOMEM && optional)
|
||||
err = 0; /* ignore the error */
|
||||
}
|
||||
if (conf)
|
||||
snd_config_delete(conf);
|
||||
snd_config_delete(conf);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue