OSDN Git Service

Fix build warnings
authorGlenn Kasten <gkasten@google.com>
Thu, 24 Mar 2016 18:43:42 +0000 (11:43 -0700)
committerGlenn Kasten <gkasten@google.com>
Mon, 28 Mar 2016 21:28:28 +0000 (14:28 -0700)
Also fix a memory leak

Change-Id: I21e66d7e5bede3ecf1da497dc8b9e20e6f076d54

alsa_utils/alsa_format.c
audio_route/audio_route.c

index 38f25c4..de8fcf2 100644 (file)
@@ -92,7 +92,6 @@ enum pcm_format get_pcm_format_for_mask(struct pcm_mask* mask)
 
     int slot_index, bit_index, table_index;
     table_index = 0;
-    int num_written = 0;
     for (slot_index = 0; slot_index < num_slots && table_index < table_size; slot_index++) {
         unsigned bit_mask = 1;
         for (bit_index = 0; bit_index < bits_per_slot && table_index < table_size; bit_index++) {
index 99db0ee..90b114d 100644 (file)
@@ -123,6 +123,7 @@ static inline struct mixer_ctl *index_to_ctl(struct audio_route *ar,
     return ar->mixer_state[ctl_index].ctl;
 }
 
+#if 0
 static void path_print(struct audio_route *ar, struct mixer_path *path)
 {
     unsigned int i;
@@ -145,6 +146,7 @@ static void path_print(struct audio_route *ar, struct mixer_path *path)
         }
     }
 }
+#endif
 
 static void path_free(struct audio_route *ar)
 {
@@ -160,6 +162,8 @@ static void path_free(struct audio_route *ar)
         }
     }
     free(ar->mixer_path);
+    ar->mixer_path = NULL;
+    ar->mixer_path_size = 0;
 }
 
 static struct mixer_path *path_get_by_name(struct audio_route *ar,
@@ -392,7 +396,6 @@ static int path_apply(struct audio_route *ar, struct mixer_path *path)
 static int path_reset(struct audio_route *ar, struct mixer_path *path)
 {
     unsigned int i;
-    unsigned int j;
     unsigned int ctl_index;
     struct mixer_ctl *ctl;
     enum mixer_ctl_type type;
@@ -556,7 +559,6 @@ static void end_tag(void *data, const XML_Char *tag_name)
 static int alloc_mixer_state(struct audio_route *ar)
 {
     unsigned int i;
-    unsigned int j;
     unsigned int num_values;
     struct mixer_ctl *ctl;
     enum mixer_ctl_type type;
@@ -838,7 +840,6 @@ struct audio_route *audio_route_init(unsigned int card, const char *xml_path)
     FILE *file;
     int bytes_read;
     void *buf;
-    int i;
     struct audio_route *ar;
 
     ar = calloc(1, sizeof(struct audio_route));
@@ -910,6 +911,7 @@ struct audio_route *audio_route_init(unsigned int card, const char *xml_path)
     return ar;
 
 err_parse:
+    path_free(ar);
     XML_ParserFree(parser);
 err_parser_create:
     fclose(file);
@@ -928,5 +930,6 @@ void audio_route_free(struct audio_route *ar)
 {
     free_mixer_state(ar);
     mixer_close(ar->mixer);
+    path_free(ar);
     free(ar);
 }