]> git.alsa-project.org Git - tinycompress.git/commitdiff
cplay: check the values of fread
authorVinod Koul <vinod.koul@intel.com>
Fri, 8 May 2015 10:30:02 +0000 (16:00 +0530)
committerVinod Koul <vinod.koul@intel.com>
Fri, 8 May 2015 10:30:02 +0000 (16:00 +0530)
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 <vinod.koul@intel.com>
src/utils/cplay.c

index c46577a3468af9e4cf1bb0ffe156ba9a65c1b10c..2d1a1760b3ec61838322ebdc62d07d2e742111f1 100644 (file)
@@ -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);