if (!found) {
if ((hdl = calloc(sizeof(struct mixer_hdl), 1)) == NULL)
- return;
+ goto out;
if ((hdl->device = strdup(device)) == NULL) {
free(hdl);
- return;
+ goto out;
}
if ((hdl->mixer = strdup(mixer)) == NULL) {
free(hdl->device);
free(hdl);
- return;
+ goto out;
}
hdl->mixer_idx = mixer_idx;
snd_mixer_selem_id_malloc(&(hdl->sid));
if (hdl->sid == NULL) {
free_hdl(hdl);
- return;
+ goto out;
}
if ((err = snd_mixer_open(&(hdl->m), 0)) < 0) {
fprintf(stderr, "i3status: ALSA: Cannot open mixer: %s\n", snd_strerror(err));
free_hdl(hdl);
- return;
+ goto out;
}
/* Attach this mixer handle to the given device */
fprintf(stderr, "i3status: ALSA: Cannot attach mixer to device: %s\n", snd_strerror(err));
snd_mixer_close(hdl->m);
free_hdl(hdl);
- return;
+ goto out;
}
/* Register this mixer */
fprintf(stderr, "i3status: ALSA: snd_mixer_selem_register: %s\n", snd_strerror(err));
snd_mixer_close(hdl->m);
free_hdl(hdl);
- return;
+ goto out;
}
if ((err = snd_mixer_load(hdl->m)) < 0) {
fprintf(stderr, "i3status: ALSA: snd_mixer_load: %s\n", snd_strerror(err));
snd_mixer_close(hdl->m);
free_hdl(hdl);
- return;
+ goto out;
}
/* Find the given mixer */
snd_mixer_selem_id_get_name(hdl->sid), snd_mixer_selem_id_get_index(hdl->sid));
snd_mixer_close(hdl->m);
free_hdl(hdl);
- return;
+ goto out;
}
/* Get the volume range to convert the volume later */
close(mixfd);
#endif
+out:
*outwalk = '\0';
OUTPUT_FULL_TEXT(buffer);