pactl: fix getopt indexing for set-*-volume

When pactl is invoked with any options or the -- specifier, optind will
be > 1. Therefore using a static 3 value is wrong. Use optind+2 as both
offset and count difference.

Bug-Debian: http://bugs.debian.org/774810
This commit is contained in:
Felipe Sateler 2015-01-07 21:01:14 -03:00 committed by David Henningsson
parent ce950b150d
commit 4edc15346b

View file

@ -1897,7 +1897,7 @@ int main(int argc, char *argv[]) {
sink_name = pa_xstrdup(argv[optind+1]); sink_name = pa_xstrdup(argv[optind+1]);
if (parse_volumes(argv+optind+2, argc-3) < 0) if (parse_volumes(argv+optind+2, argc-(optind+2)) < 0)
goto quit; goto quit;
} else if (pa_streq(argv[optind], "set-source-volume")) { } else if (pa_streq(argv[optind], "set-source-volume")) {
@ -1910,7 +1910,7 @@ int main(int argc, char *argv[]) {
source_name = pa_xstrdup(argv[optind+1]); source_name = pa_xstrdup(argv[optind+1]);
if (parse_volumes(argv+optind+2, argc-3) < 0) if (parse_volumes(argv+optind+2, argc-(optind+2)) < 0)
goto quit; goto quit;
} else if (pa_streq(argv[optind], "set-sink-input-volume")) { } else if (pa_streq(argv[optind], "set-sink-input-volume")) {
@ -1926,7 +1926,7 @@ int main(int argc, char *argv[]) {
goto quit; goto quit;
} }
if (parse_volumes(argv+optind+2, argc-3) < 0) if (parse_volumes(argv+optind+2, argc-(optind+2)) < 0)
goto quit; goto quit;
} else if (pa_streq(argv[optind], "set-source-output-volume")) { } else if (pa_streq(argv[optind], "set-source-output-volume")) {
@ -1942,7 +1942,7 @@ int main(int argc, char *argv[]) {
goto quit; goto quit;
} }
if (parse_volumes(argv+optind+2, argc-3) < 0) if (parse_volumes(argv+optind+2, argc-(optind+2)) < 0)
goto quit; goto quit;
} else if (pa_streq(argv[optind], "set-sink-mute")) { } else if (pa_streq(argv[optind], "set-sink-mute")) {