From: Vinod Koul Date: Fri, 8 May 2015 10:30:02 +0000 (+0530) Subject: cplay: check the values of fread X-Git-Tag: v1.1.0~3 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=50c2b03b3d7be9bdf6f7cfdbf730665e3b596086;p=tinycompress.git cplay: check the values of fread This fixes the following warning: cplay.c: In function ‘play_samples’: cplay.c:219:7: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result] fread(&header, sizeof(header), 1, file); Signed-off-by: Vinod Koul --- diff --git a/src/utils/cplay.c b/src/utils/cplay.c index c46577a..2d1a176 100644 --- a/src/utils/cplay.c +++ b/src/utils/cplay.c @@ -207,6 +207,7 @@ void play_samples(char *name, unsigned int card, unsigned int device, char *buffer; int size, num_read, wrote; unsigned int channels, rate, bits; + size_t read; if (verbose) printf("%s: entry\n", __func__); @@ -216,7 +217,12 @@ void play_samples(char *name, unsigned int card, unsigned int device, exit(EXIT_FAILURE); } - fread(&header, sizeof(header), 1, file); + read = fread(&header, sizeof(header), 1, file); + if (read != sizeof(header)) { + fprintf(stderr, "Unable to read header \n"); + fclose(file); + exit(EXIT_FAILURE); + } if (parse_mp3_header(&header, &channels, &rate, &bits) == -1) { fclose(file);