Skip to contentSkip to conversation

aplay - fix two off by one errors

PATCH Applied Jurgen Kramer 2 participants 2 messages Sep 8, 2013 – Sep 9, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aplay - fix two off by one errors

Attached patch for aplay fixes two off-by-one errors preventing usage of the last available sample format.

diff -uNrp alsa-utils-1.0.27.2/aplay/aplay.c
alsa-utils-1.0.27.2-jk/aplay/aplay.c

aplay/aplay.c +2 -2
@@ -242,7 +242,7 @@ _("Usage: %s [OPTION]... [FILE]...\n"
   )
 		, command);
 	printf(_("Recognized sample formats are:"));
-	for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) {
+	for (k = 0; k <= SND_PCM_FORMAT_LAST; ++k) {
 		const char *s = snd_pcm_format_name(k);
 		if (s)
 			printf(" %s", s);
@@ -1114,7 +1114,7 @@ static void show_available_sample_format
 	snd_pcm_format_t format;
 
 	fprintf(stderr, "Available formats:\n");
-	for (format = 0; format < SND_PCM_FORMAT_LAST; format++) {
+	for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) {
 		if (snd_pcm_hw_params_test_format(handle, params, format) == 0)
 			fprintf(stderr, "- %s\n", snd_pcm_format_name(format));
 	}

Jurgen

aplay/aplay.c +2 -2
diff -uNrp alsa-utils-1.0.27.2/aplay/aplay.c alsa-utils-1.0.27.2-jk/aplay/aplay.c
@@ -242,7 +242,7 @@ _("Usage: %s [OPTION]... [FILE]...\n"
   )
 		, command);
 	printf(_("Recognized sample formats are:"));
-	for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) {
+	for (k = 0; k <= SND_PCM_FORMAT_LAST; ++k) {
 		const char *s = snd_pcm_format_name(k);
 		if (s)
 			printf(" %s", s);
@@ -1114,7 +1114,7 @@ static void show_available_sample_format
 	snd_pcm_format_t format;
 
 	fprintf(stderr, "Available formats:\n");
-	for (format = 0; format < SND_PCM_FORMAT_LAST; format++) {
+	for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) {
 		if (snd_pcm_hw_params_test_format(handle, params, format) == 0)
 			fprintf(stderr, "- %s\n", snd_pcm_format_name(format));
 	}
Applied
#1 lore raw

At Sun, 8 Sep 2013 13:50:51 +0200,

Quoted 28 lines · Jurgen Kramer

Attached patch for aplay fixes two off-by-one errors preventing usage of the last available sample format.

diff -uNrp alsa-utils-1.0.27.2/aplay/aplay.c
alsa-utils-1.0.27.2-jk/aplay/aplay.c

aplay/aplay.c +2 -2
@@ -242,7 +242,7 @@ _("Usage: %s [OPTION]... [FILE]...\n"
   )
 		, command);
 	printf(_("Recognized sample formats are:"));
-	for (k = 0; k < SND_PCM_FORMAT_LAST; ++k) {
+	for (k = 0; k <= SND_PCM_FORMAT_LAST; ++k) {
 		const char *s = snd_pcm_format_name(k);
 		if (s)
 			printf(" %s", s);
@@ -1114,7 +1114,7 @@ static void show_available_sample_format
 	snd_pcm_format_t format;
 
 	fprintf(stderr, "Available formats:\n");
-	for (format = 0; format < SND_PCM_FORMAT_LAST; format++) {
+	for (format = 0; format <= SND_PCM_FORMAT_LAST; format++) {
 		if (snd_pcm_hw_params_test_format(handle, params, format) == 0)
 			fprintf(stderr, "- %s\n", snd_pcm_format_name(format));
 	}
Quoted 1 line

Jurgen

Thanks, applied now.

Takashi