Misc fixes

Fixes of spots found via valgrind

- non-freed chunks after snd_config_get_ascii()
- zero-fill records (to make valgrind happy)
- compile warning fixes
This commit is contained in:
Takashi Iwai 2005-08-17 17:27:16 +00:00
parent 4bb0721a83
commit ea77e08cc6
6 changed files with 20 additions and 5 deletions

View file

@ -1962,8 +1962,7 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
val = NULL;
snd_config_get_ascii(pcm_conf, &val);
SNDERR("Invalid type for PCM %s%sdefinition (id: %s, value: %s)", name ? name : "", name ? " " : "", id, val);
if (val)
free(val);
free(val);
return -EINVAL;
}
err = snd_config_search(pcm_conf, "type", &conf);

View file

@ -198,6 +198,7 @@ static int make_local_socket(const char *filename, int server, mode_t ipc_perm)
if (server)
unlink(filename);
memset(addr, 0, size); /* make valgrind happy */
addr->sun_family = AF_LOCAL;
memcpy(addr->sun_path, filename, l);
@ -456,7 +457,8 @@ int snd_pcm_direct_async(snd_pcm_t *pcm, int sig, pid_t pid)
return snd_timer_async(dmix->timer, sig, pid);
}
static inline void process_timer_event(snd_pcm_direct_t *dmix, snd_timer_tread_t *te)
static inline void process_timer_event(snd_pcm_direct_t *dmix ATTRIBUTE_UNUSED,
snd_timer_tread_t *te ATTRIBUTE_UNUSED)
{
#if 0
printf("te->event = %i\n", te->event);

View file

@ -1080,9 +1080,11 @@ int _snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
}
if (isdigit(*perm) == 0) {
SNDERR("The field ipc_perm must be a valid file permission");
free(perm);
return -EINVAL;
}
ipc_perm = strtol(perm, &endp, 8);
free(perm);
continue;
}
if (strcmp(id, "ipc_gid") == 0) {
@ -1097,12 +1099,14 @@ int _snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
struct group *grp = getgrnam(group);
if (grp == NULL) {
SNDERR("The field ipc_gid must be a valid group (create group %s)", group);
free(group);
return -EINVAL;
}
ipc_gid = grp->gr_gid;
} else {
ipc_perm = strtol(group, &endp, 10);
}
free(group);
continue;
}
if (strcmp(id, "ipc_key_add_uid") == 0) {

View file

@ -865,9 +865,11 @@ int _snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
}
if (isdigit(*perm) == 0) {
SNDERR("The field ipc_perm must be a valid file permission");
free(perm);
return -EINVAL;
}
ipc_perm = strtol(perm, &endp, 8);
free(perm);
continue;
}
if (strcmp(id, "ipc_gid") == 0) {
@ -881,13 +883,15 @@ int _snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
if (isdigit(*group) == 0) {
struct group *grp = getgrnam(group);
if (group == NULL) {
SNDERR("The field ipc_gid must be a valid group (create group %s)", grp);
SNDERR("The field ipc_gid must be a valid group (create group %s)", group);
free(group);
return -EINVAL;
}
ipc_gid = grp->gr_gid;
} else {
ipc_perm = strtol(group, &endp, 10);
}
free(group);
continue;
}
if (strcmp(id, "ipc_key_add_uid") == 0) {

View file

@ -750,9 +750,11 @@ int _snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
}
if (isdigit(*perm) == 0) {
SNDERR("The field ipc_perm must be a valid file permission");
free(perm);
return -EINVAL;
}
ipc_perm = strtol(perm, &endp, 8);
free(perm);
continue;
}
if (strcmp(id, "ipc_gid") == 0) {
@ -766,13 +768,15 @@ int _snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
if (isdigit(*group) == 0) {
struct group *grp = getgrnam(group);
if (group == NULL) {
SNDERR("The field ipc_gid must be a valid group (create group %s)", grp);
SNDERR("The field ipc_gid must be a valid group (create group %s)", group);
free(group);
return -EINVAL;
}
ipc_gid = grp->gr_gid;
} else {
ipc_perm = strtol(group, &endp, 10);
}
free(group);
continue;
}
if (strcmp(id, "ipc_key_add_uid") == 0) {

View file

@ -550,9 +550,11 @@ int _snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
}
if (isdigit(*str) == 0) {
SNDERR("The field perm must be a valid file permission");
free(str);
return -EINVAL;
}
perm = strtol(str, &endp, 8);
free(str);
continue;
}
SNDERR("Unknown field %s", id);