[alsa-devel] [PATCH] aplay - fix two off by one errors

Jurgen Kramer gtmkramer at xs4all.nl
Sun Sep 8 13:50:51 CEST 2013


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
--- alsa-utils-1.0.27.2/aplay/aplay.c	2013-07-09 17:28:37.000000000 +0200
+++ alsa-utils-1.0.27.2-jk/aplay/aplay.c	2013-09-08 13:46:23.746825429 +0200
@@ -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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: aplay-fix-off-by-one-errors.patch
Type: text/x-patch
Size: 914 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20130908/206b5c6c/attachment.bin>


More information about the Alsa-devel mailing list