[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".
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@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);
participants (1)
-
Manish Sogi