]> git.alsa-project.org Git - alsa-lib.git/commitdiff
Misc fixes
authorTakashi Iwai <tiwai@suse.de>
Wed, 17 Aug 2005 17:27:16 +0000 (17:27 +0000)
committerTakashi Iwai <tiwai@suse.de>
Wed, 17 Aug 2005 17:27:16 +0000 (17:27 +0000)
Fixes of spots found via valgrind

- non-freed chunks after snd_config_get_ascii()
- zero-fill records (to make valgrind happy)
- compile warning fixes

src/pcm/pcm.c
src/pcm/pcm_direct.c
src/pcm/pcm_dmix.c
src/pcm/pcm_dshare.c
src/pcm/pcm_dsnoop.c
src/pcm/pcm_file.c

index c116f0f4297aaf314e4943703418185db942252c..1f2cba86191b01318249e0219955f26c4869c9cc 100644 (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);
index f69f0df9812b766c3add6aedc1ba952a43cec21c..8ce406bdea9eea33645ec72680baec1e20509d75 100644 (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);
index c9cfdcc0400a8b391d9bf31bed3f3caa93993063..40d072dd1fac32c8cbb09661262eb2aab127caca 100644 (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) {
index 30a57bc766621026c5bca24bddc7b0348dda1b6e..031f8ea5b5bc5e70a51376fd49408f121774d1be 100644 (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) {
index e2da4b71f476925fd10986453063c6b86da27857..4ee52cbb2ba57f7e07023c75bd9e6ac6eed538f7 100644 (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) {
index 93bf8185cf5edfdbbb465add73e39e8818c10bf2..3808aaae33bb9dfe19dec80ea32f7eadafa18789 100644 (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);