firmware-utils: trx2edips: fix compiler warnings/errors
authorPetr Štetiar <ynezz@true.cz>
Sat, 20 Jul 2019 12:09:22 +0000 (14:09 +0200)
committerPetr Štetiar <ynezz@true.cz>
Tue, 23 Jul 2019 20:07:23 +0000 (22:07 +0200)
trx2edips.c:114:9: error: unused variable ‘res’ [-Werror=unused-variable]
trx2edips.c:142:2: error: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Werror=unused-result]

Signed-off-by: Petr Štetiar <ynezz@true.cz>
tools/firmware-utils/src/trx2edips.c

index f8d068d5020593ab693df2e32c15105c6946ad74..8d33aab55bc2bdbd5ed37958e8392b2c0ffb33ad 100644 (file)
@@ -111,8 +111,7 @@ int main(int argc, char *argv[])
        FILE *fpIn = NULL;
        FILE *fpOut = NULL;
        struct edimax_header eh;
-       size_t res;
-       int length;
+       size_t length;
 
        char *buf;
        struct trx_header *p;
@@ -136,10 +135,14 @@ int main(int argc, char *argv[])
                fprintf(stderr, "malloc of buffers failed\n");
                return EXIT_FAILURE;
        }
-       
+
        rewind(fpIn);
        /* read the whole file*/
-       res = fread(buf, 1, length, fpIn);
+       size_t res = fread(buf, 1, length, fpIn);
+       if (res != length) {
+               fprintf(stderr, "'%s' read failure\n", argv[1]);
+               return EXIT_FAILURE;
+       }
 
        p = (struct trx_header *)buf;
        if (LOAD32_LE(p->magic) != TRX_MAGIC) {