diff options
author | Michael Stapelberg <michael@stapelberg.de> | 2013-03-19 19:56:44 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2013-03-19 19:56:44 +0100 |
commit | f0cd726bf0dabb20b81b456e93889638a5ed3413 (patch) | |
tree | b035f196a9d4e30f3266f8ab76dff2cd5ba5de5c /src/print_volume.c | |
parent | 8dbadb6d4ec424f782475f6f014e148ebae6d028 (diff) |
print_volume: don’t return, complete the buffer first
Otherwise, i3bar will display “SPEC VIOLATION” because full_text is
missing in the block.
Diffstat (limited to 'src/print_volume.c')
-rw-r--r-- | src/print_volume.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/print_volume.c b/src/print_volume.c index 6a87b1e..d3a9708 100644 --- a/src/print_volume.c +++ b/src/print_volume.c @@ -77,30 +77,30 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * 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 */ @@ -108,7 +108,7 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * 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 */ @@ -116,14 +116,14 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * 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 */ @@ -134,7 +134,7 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * 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 */ @@ -215,6 +215,7 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char * close(mixfd); #endif +out: *outwalk = '\0'; OUTPUT_FULL_TEXT(buffer); |