[alsa-devel] [PATCH] cplay: check return value of fread() function and compare it with "number of blocks to read" rather than "size of each block".
Manish Sogi
manish.sogi at samsung.com
Wed Jun 24 09:43:40 CEST 2015
fread() function on success returns the number
of blocks which it reads, so return value should
be compared with "1" because only 1 block having
size equal to sizeof(header) needs to be read.
On success fread will return 1 else error case.
Signed-off-by: Manish Sogi <manish.sogi at samsung.com>
---
src/utils/cplay.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/utils/cplay.c b/src/utils/cplay.c
index 2d1a176..aeea5bb 100644
--- a/src/utils/cplay.c
+++ b/src/utils/cplay.c
@@ -218,7 +218,7 @@ void play_samples(char *name, unsigned int card, unsigned int device,
}
read = fread(&header, sizeof(header), 1, file);
- if (read != sizeof(header)) {
+ if (read != 1) {
fprintf(stderr, "Unable to read header \n");
fclose(file);
exit(EXIT_FAILURE);
--
1.7.9.5
More information about the Alsa-devel
mailing list