firmware-utils: mkplanexfw: fix compiler warnings/errors
authorPetr Štetiar <ynezz@true.cz>
Mon, 22 Jul 2019 09:48:38 +0000 (11:48 +0200)
committerPetr Štetiar <ynezz@true.cz>
Tue, 23 Jul 2019 20:07:23 +0000 (22:07 +0200)
mkplanexfw.c:108:21: error: unused variable ‘board’ [-Werror=unused-variable]
mkplanexfw.c:233:24: error: pointer targets in passing argument 2 of ‘sha1_update’ differ in signedness [-Werror=pointer-sign]
mkplanexfw.c:251:2: error: label ‘out_flush’ defined but not used [-Werror=unused-label]
mkplanexfw.c:224: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/mkplanexfw.c

index 0b71f80438f38a45b23a34b3c131305d8830ecc3..2a648b8e6abdd7b3c7a5e590e0f19619e031130b 100644 (file)
@@ -105,7 +105,6 @@ static struct board_info *find_board(char *id)
 void usage(int status)
 {
        FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
-       struct board_info *board;
 
        fprintf(stream, "Usage: %s [OPTIONS...]\n", progname);
        fprintf(stream,
@@ -127,7 +126,7 @@ int main(int argc, char *argv[])
        int buflen;
        int err;
        struct stat st;
-       char *buf;
+       uint8_t *buf;
        struct planex_hdr *hdr;
        sha1_context ctx;
        uint32_t seed;
@@ -221,8 +220,8 @@ int main(int argc, char *argv[])
        }
 
        errno = 0;
-       fread(buf +  sizeof(*hdr), st.st_size, 1, infile);
-       if (errno != 0) {
+       size_t r = fread(buf +  sizeof(*hdr), st.st_size, 1, infile);
+       if (r != 1 || errno != 0) {
                ERRS("unable to read from file %s", ifname);
                goto err_close_in;
        }
@@ -248,7 +247,6 @@ int main(int argc, char *argv[])
 
        res = EXIT_SUCCESS;
 
- out_flush:
        fflush(outfile);
 
  err_close_out: