amixer: cleanups for valgrind

Call snd_config_update_free_global() to check the memory
leaks and wrong memory access.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-03-30 13:31:13 +02:00
parent 69276d4a6c
commit 204ae460a1

View file

@ -1772,7 +1772,7 @@ static int exec_stdin(void)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int morehelp, level = 0; int morehelp, retval, level = 0;
int read_stdin = 0; int read_stdin = 0;
static const struct option long_option[] = static const struct option long_option[] =
{ {
@ -1865,39 +1865,46 @@ int main(int argc, char *argv[])
} }
smixer_options.device = card; smixer_options.device = card;
if (read_stdin) if (read_stdin) {
return exec_stdin(); retval = exec_stdin();
goto finish;
}
if (argc - optind <= 0) { if (argc - optind <= 0) {
return selems(LEVEL_BASIC | level) ? 1 : 0; retval = selems(LEVEL_BASIC | level) ? 1 : 0;
goto finish;
} }
if (!strcmp(argv[optind], "help")) { if (!strcmp(argv[optind], "help")) {
return help() ? 1 : 0; retval = help() ? 1 : 0;
} else if (!strcmp(argv[optind], "info")) { } else if (!strcmp(argv[optind], "info")) {
return info() ? 1 : 0; retval = info() ? 1 : 0;
} else if (!strcmp(argv[optind], "controls")) { } else if (!strcmp(argv[optind], "controls")) {
return controls(level) ? 1 : 0; retval = controls(level) ? 1 : 0;
} else if (!strcmp(argv[optind], "contents")) { } else if (!strcmp(argv[optind], "contents")) {
return controls(LEVEL_BASIC | level) ? 1 : 0; retval = controls(LEVEL_BASIC | level) ? 1 : 0;
} else if (!strcmp(argv[optind], "scontrols") || !strcmp(argv[optind], "simple")) { } else if (!strcmp(argv[optind], "scontrols") || !strcmp(argv[optind], "simple")) {
return selems(level) ? 1 : 0; retval = selems(level) ? 1 : 0;
} else if (!strcmp(argv[optind], "scontents")) { } else if (!strcmp(argv[optind], "scontents")) {
return selems(LEVEL_BASIC | level) ? 1 : 0; retval = selems(LEVEL_BASIC | level) ? 1 : 0;
} else if (!strcmp(argv[optind], "sset") || !strcmp(argv[optind], "set")) { } else if (!strcmp(argv[optind], "sset") || !strcmp(argv[optind], "set")) {
return sset(argc - optind - 1, argc - optind > 1 ? argv + optind + 1 : NULL, 0, 0) ? 1 : 0; retval = sset(argc - optind - 1, argc - optind > 1 ? argv + optind + 1 : NULL, 0, 0) ? 1 : 0;
} else if (!strcmp(argv[optind], "sget") || !strcmp(argv[optind], "get")) { } else if (!strcmp(argv[optind], "sget") || !strcmp(argv[optind], "get")) {
return sset(argc - optind - 1, argc - optind > 1 ? argv + optind + 1 : NULL, 1, 0) ? 1 : 0; retval = sset(argc - optind - 1, argc - optind > 1 ? argv + optind + 1 : NULL, 1, 0) ? 1 : 0;
} else if (!strcmp(argv[optind], "cset")) { } else if (!strcmp(argv[optind], "cset")) {
return cset(argc - optind - 1, argc - optind > 1 ? argv + optind + 1 : NULL, 0, 0) ? 1 : 0; retval = cset(argc - optind - 1, argc - optind > 1 ? argv + optind + 1 : NULL, 0, 0) ? 1 : 0;
} else if (!strcmp(argv[optind], "cget")) { } else if (!strcmp(argv[optind], "cget")) {
return cset(argc - optind - 1, argc - optind > 1 ? argv + optind + 1 : NULL, 1, 0) ? 1 : 0; retval = cset(argc - optind - 1, argc - optind > 1 ? argv + optind + 1 : NULL, 1, 0) ? 1 : 0;
} else if (!strcmp(argv[optind], "events")) { } else if (!strcmp(argv[optind], "events")) {
return events(argc - optind - 1, argc - optind > 1 ? argv + optind + 1 : NULL); retval = events(argc - optind - 1, argc - optind > 1 ? argv + optind + 1 : NULL);
} else if (!strcmp(argv[optind], "sevents")) { } else if (!strcmp(argv[optind], "sevents")) {
return sevents(argc - optind - 1, argc - optind > 1 ? argv + optind + 1 : NULL); retval = sevents(argc - optind - 1, argc - optind > 1 ? argv + optind + 1 : NULL);
} else { } else {
fprintf(stderr, "amixer: Unknown command '%s'...\n", argv[optind]); fprintf(stderr, "amixer: Unknown command '%s'...\n", argv[optind]);
retval = 0;
} }
return 0; finish:
snd_config_update_free_global();
return retval;
} }