coverity fixes

This commit is contained in:
Jaroslav Kysela 2016-01-12 16:25:42 +01:00
parent 0f4f48d377
commit df20aa2a1e
5 changed files with 8 additions and 3 deletions

View file

@ -93,6 +93,7 @@ static int make_inet_socket(int port)
return result; return result;
} }
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(port); addr.sin_port = htons(port);
addr.sin_addr.s_addr = INADDR_ANY; addr.sin_addr.s_addr = INADDR_ANY;

View file

@ -411,7 +411,7 @@ int snd_ctl_elem_add_enumerated(snd_ctl_t *ctl, const snd_ctl_elem_id_t *id,
bytes = 0; bytes = 0;
for (i = 0; i < items; ++i) for (i = 0; i < items; ++i)
bytes += strlen(names[i]) + 1; bytes += strlen(names[i]) + 1;
buf = malloc(bytes); buf = bytes ? malloc(bytes) : NULL;
if (!buf) if (!buf)
return -ENOMEM; return -ENOMEM;
info->value.enumerated.names_ptr = (uintptr_t)buf; info->value.enumerated.names_ptr = (uintptr_t)buf;

View file

@ -62,7 +62,7 @@ static long get_integer(const char **ptr, long min, long max)
val = strtol(s, &p, 0); val = strtol(s, &p, 0);
if (*p == '.') { if (*p == '.') {
p++; p++;
strtol(p, &p, 10); (void)strtol(p, &p, 10);
} }
if (*p == '%') { if (*p == '%') {
val = (long)convert_prange1(strtod(s, NULL), min, max); val = (long)convert_prange1(strtod(s, NULL), min, max);
@ -90,7 +90,7 @@ static long long get_integer64(const char **ptr, long long min, long long max)
val = strtol(s, &p, 0); val = strtol(s, &p, 0);
if (*p == '.') { if (*p == '.') {
p++; p++;
strtol(p, &p, 10); (void)strtol(p, &p, 10);
} }
if (*p == '%') { if (*p == '%') {
val = (long long)convert_prange1(strtod(s, NULL), min, max); val = (long long)convert_prange1(strtod(s, NULL), min, max);

View file

@ -559,6 +559,8 @@ int snd_device_name_hint(int card, const char *iface, void ***hints)
if (err < 0) if (err < 0)
return err; return err;
err = snd_config_copy(&local_config_rw, local_config); err = snd_config_copy(&local_config_rw, local_config);
if (err < 0)
return err;
list.list = NULL; list.list = NULL;
list.count = list.allocated = 0; list.count = list.allocated = 0;
list.siface = iface; list.siface = iface;

View file

@ -888,6 +888,8 @@ static int snd_pcm_multi_set_chmap(snd_pcm_t *pcm, const snd_pcm_chmap_t *map)
slave_maps[i] = calloc(multi->slaves[i].channels_count + 1, slave_maps[i] = calloc(multi->slaves[i].channels_count + 1,
sizeof(int)); sizeof(int));
if (!slave_maps[i]) { if (!slave_maps[i]) {
for (i++; i < multi->slaves_count; i++)
slave_maps[i] = NULL;
err = -ENOMEM; err = -ENOMEM;
goto error; goto error;
} }