firmware-utils: mkzcfw: fix compiler warnings/errors
authorPetr Štetiar <ynezz@true.cz>
Sat, 20 Jul 2019 22:33:32 +0000 (00:33 +0200)
committerPetr Štetiar <ynezz@true.cz>
Tue, 23 Jul 2019 20:07:23 +0000 (22:07 +0200)
mkzcfw.c:130:21: error: unused variable ‘board’ [-Werror=unused-variable]
mkzcfw.c:318:37: error: pointer targets in passing argument 1 of ‘cyg_crc32’ differ in signedness [-Werror=pointer-sign]
mkzcfw.c:338:37: error: pointer targets in passing argument 1 of ‘cyg_crc32’ differ in signedness [-Werror=pointer-sign]
mkzcfw.c:346:41: error: pointer targets in passing argument 1 of ‘cyg_crc32’ differ in signedness [-Werror=pointer-sign]
mkzcfw.c:280:11: error: unused variable ‘crc’ [-Werror=unused-variable]
mkzcfw.c:279:6: error: unused variable ‘writelen’ [-Werror=unused-variable]
mkzcfw.c:366:8: error: unused variable ‘outfile’ [-Werror=unused-variable]
mkzcfw.c:364:6: error: unused variable ‘err’ [-Werror=unused-variable]
mkzcfw.c:176: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/mkzcfw.c

index 2326f1ff5c5a4b4925446712f52720116c2d6bf6..ad46305c87cce7e4528b0d31f282448d9f6b8545 100644 (file)
@@ -127,7 +127,6 @@ static struct board_info *find_board(char *id)
 static void usage(int status)
 {
        FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
-       struct board_info *board;
 
        fprintf(stream, "Usage: %s [OPTIONS...]\n", progname);
        fprintf(stream,
@@ -161,7 +160,7 @@ static int get_file_stat(struct file_info *fdata)
        return 0;
 }
 
-static int read_to_buf(struct file_info *fdata, char *buf)
+static int read_to_buf(struct file_info *fdata, uint8_t *buf)
 {
        FILE *f;
        int ret = EXIT_FAILURE;
@@ -173,8 +172,8 @@ static int read_to_buf(struct file_info *fdata, char *buf)
        }
 
        errno = 0;
-       fread(buf, fdata->file_size, 1, f);
-       if (errno != 0) {
+       ssize_t r = fread(buf, fdata->file_size, 1, f);
+       if (r != 1 || errno != 0) {
                ERRS("unable to read from file \"%s\"", fdata->file_name);
                goto out_close;
        }
@@ -238,7 +237,7 @@ static int check_options(void)
        return 0;
 }
 
-static int write_fw(char *data, int len)
+static int write_fw(uint8_t *data, int len)
 {
        FILE *f;
        int ret = EXIT_FAILURE;
@@ -273,11 +272,9 @@ static int write_fw(char *data, int len)
 static int build_fw(void)
 {
        int buflen;
-       char *buf;
-       char *p;
+       uint8_t *buf;
+       uint8_t *p;
        int ret = EXIT_FAILURE;
-       int writelen = 0;
-       uint32_t crc;
        struct fw_header *hdr;
        struct fw_tail *tail;
 
@@ -361,10 +358,6 @@ static int build_fw(void)
 int main(int argc, char *argv[])
 {
        int ret = EXIT_FAILURE;
-       int err;
-
-       FILE *outfile;
-
        progname = basename(argv[0]);
 
        while ( 1 ) {