tools: firmware-utils: fix compiler warnings
authorhauke <hauke@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Sun, 11 Oct 2015 19:00:41 +0000 (19:00 +0000)
committerhauke <hauke@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Sun, 11 Oct 2015 19:00:41 +0000 (19:00 +0000)
This just fixes a lot of compiler warnings.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@47181 3c298f89-4303-0410-b956-a3cf2f4a3e73

15 files changed:
tools/firmware-utils/src/airlink.c
tools/firmware-utils/src/asustrx.c
tools/firmware-utils/src/imagetag.c
tools/firmware-utils/src/mkbrnimg.c
tools/firmware-utils/src/mkcasfw.c
tools/firmware-utils/src/mkcsysimg.c
tools/firmware-utils/src/mkdniimg.c
tools/firmware-utils/src/mkplanexfw.c
tools/firmware-utils/src/mktplinkfw.c
tools/firmware-utils/src/mktplinkfw2.c
tools/firmware-utils/src/mkzcfw.c
tools/firmware-utils/src/mkzynfw.c
tools/firmware-utils/src/osbridge-crc.c
tools/firmware-utils/src/pc1crypt.c
tools/firmware-utils/src/seama.c

index 560a58d..06c83a0 100644 (file)
@@ -293,7 +293,7 @@ int main(int argc, char **argv)
        *((uint32_t *) & b[0x18]) = 0x0L;
 
        sum = crc32(b, 0x400);
-       printf("CRC32 sum0 - (%x, %x, %x)\n", sum, sum0, 0x400);
+       printf("CRC32 sum0 - (%x, %lx, %x)\n", sum, sum0, 0x400);
        if (EHDR)
                lseek(fd, 0x20, SEEK_SET);
        else
@@ -305,7 +305,7 @@ int main(int argc, char **argv)
        write(fd, &buf[0x18], 0x4);
 
        sum = crc32(buf, l0);
-       printf("CRC32 sum1 - (%x, %x, %x)\n", sum, sum1, l0);
+       printf("CRC32 sum1 - (%x, %lx, %x)\n", sum, sum1, l0);
        if (EHDR)
                lseek(fd, 0xC, SEEK_SET);
        else
@@ -319,7 +319,7 @@ int main(int argc, char **argv)
                unsigned long sum2 = buf[-0x8] | ((uint32_t)buf[-0x7] << 8) | ((uint32_t)buf[-0x6] << 16) | ((uint32_t)buf[-0x5] << 24);
                *((uint32_t *) & buf[-0x8]) = 0L;
                sum = crc32(buf - 0x4, len - 0x4);
-               printf("CRC32 sum2 - (%x, %x, %x)\n", sum, sum2,
+               printf("CRC32 sum2 - (%x, %lx, %lx)\n", sum, sum2,
                       len - 0x4);
                lseek(fd, 0, SEEK_SET);
                *((uint32_t *) & buf[-0x8]) = htonl(sum);
index 80b6b1d..67f2680 100644 (file)
@@ -197,7 +197,7 @@ int main(int argc, char **argv) {
        }
        for (i = 0; i < bytes; i++) {
                if (buf[i]) {
-                       fprintf(stderr, "Input TRX doesn't have last 64 B empty %s\n");
+                       fprintf(stderr, "Input TRX doesn't have last 64 B empty %s\n", out_path);
                        err = -ENOSPC;
                        goto err;
                }
@@ -217,7 +217,7 @@ int main(int argc, char **argv) {
        bytes = sizeof(tail);
        fseek(out, -bytes, SEEK_CUR);
        if (fwrite(&tail, 1, bytes, out) != bytes) {
-               fprintf(stderr, "Couldn't write %zu B to %s\n", bytes);
+               fprintf(stderr, "Couldn't write %zu B to %s\n", bytes, out_path);
                err = -EIO;
                goto err;
        }
@@ -242,7 +242,7 @@ int main(int argc, char **argv) {
        hdr.crc32 = cpu_to_le32(crc32);
        rewind(out);
        if (fwrite(&hdr, 1, bytes, out) != bytes) {
-               fprintf(stderr, "Couldn't write %zu B to %s\n", bytes);
+               fprintf(stderr, "Couldn't write %zu B to %s\n", bytes, out_path);
                err = -EIO;
                goto err;
        }
index f04f98d..6a46a7e 100644 (file)
@@ -15,6 +15,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <netinet/in.h>
+#include <inttypes.h>
 
 #include "bcm_tag.h"
 #include "imagetag_cmdline.h"
@@ -304,7 +305,7 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, \
        sprintf(tag.totalLength, "%lu", imagelen);
 
        if (args->cfe_given) {
-         sprintf(tag.cfeAddress, "%lu", flash_start);
+         sprintf(tag.cfeAddress, "%" PRIu32, flash_start);
          sprintf(tag.cfeLength, "%lu", cfelen);
        } else {
          /* We don't include CFE */
@@ -345,7 +346,7 @@ int tagfile(const char *kernel, const char *rootfs, const char *bin, \
        }
 
        if (args->altinfo_given) {
-         strncpy(&tag.information1[0], args->altinfo_arg, ALTTAGINFO_LEN);
+         strncpy(tag.information1, args->altinfo_arg, TAGINFO1_LEN);
        }
 
        if (args->second_image_flag_given) {
index fde30b2..b7a73ff 100644 (file)
@@ -142,7 +142,7 @@ static void appendfile(int outfd, char *path, int kernel) {
 
        // write padding
        padded_len = ((len + sizeof(footer) + sizeof(padding) - 1) & ~(sizeof(padding) - 1)) - sizeof(footer);
-       fprintf(stderr, "len=%08x padded_len=%08x\n", len, padded_len);
+       fprintf(stderr, "len=%08zx padded_len=%08zx\n", len, padded_len);
        write(outfd, padding, padded_len - len);
 
        // write footer
index 626e77d..5655bf1 100644 (file)
@@ -258,7 +258,7 @@ static struct board_info boards[] = {
 #define ERRS(fmt, ...) do { \
        int save = errno; \
        fflush(0); \
-       fprintf(stderr, "[%s] *** error: " fmt "\n", \
+       fprintf(stderr, "[%s] *** error: " fmt ": %s\n", \
                        progname, ## __VA_ARGS__, strerror(save)); \
 } while (0)
 
@@ -708,7 +708,7 @@ image_writeout(FILE *outfile, struct image_desc *desc)
 
        /* write padding data if neccesary */
        padlen = desc->out_size - desc->file_size;
-       DBG(1,"padding desc, length=%d", padlen);
+       DBG(1,"padding desc, length=%zu", padlen);
        res = write_out_padding(outfile, padlen, desc->padc, &css);
 
        desc->csum = csum_get(&css);
@@ -985,11 +985,11 @@ main(int argc, char *argv[])
                        res = ERR_FATAL;
 
                if (keep_invalid_images == 0) {
-                       WARN("generation of invalid images disabled", ofname);
+                       WARN("generation of invalid images \"%s\" disabled", ofname);
                        goto out;
                }
 
-               WARN("generating invalid image", ofname);
+               WARN("generating invalid image: \"%s\"", ofname);
        }
 
        outfile = fopen(ofname, "w");
index c00096f..77fbbaa 100644 (file)
@@ -199,7 +199,7 @@ static struct board_info boards[] = {
 #define ERRS(fmt, ...) do { \
        int save = errno; \
        fflush(0); \
-       fprintf(stderr, "[%s] *** error: " fmt "\n", progname, ## __VA_ARGS__ \
+       fprintf(stderr, "[%s] *** error: " fmt ": %s\n", progname, ## __VA_ARGS__ \
                , strerror(save)); \
 } while (0)
 
@@ -647,7 +647,7 @@ block_writeout_data(FILE *outfile, struct csys_block *block)
 
        /* write padding data if neccesary */
        padlen = block->size_avail - block->file_size;
-       DBG(1,"padding block, length=%d", padlen);
+       DBG(1,"padding block, length=%zu", padlen);
        res = write_out_padding(outfile, padlen, block->padc, block->css);
 
        return res;
@@ -1122,11 +1122,11 @@ main(int argc, char *argv[])
                        res = ERR_FATAL;
 
                if (keep_invalid_images == 0) {
-                       WARN("generation of invalid images disabled", ofname);
+                       WARN("generation of invalid images \"%s\" disabled", ofname);
                        goto out;
                }
 
-               WARN("generating invalid image", ofname);
+               WARN("generating invalid image: \"%s\"", ofname);
        }
 
        outfile = fopen(ofname, "w");
index 7230f09..852b07d 100644 (file)
@@ -43,7 +43,7 @@ static char *board_id;
 #define ERRS(fmt, ...) do { \
        int save = errno; \
        fflush(0); \
-       fprintf(stderr, "[%s] *** error: " fmt "\n", \
+       fprintf(stderr, "[%s] *** error: " fmt ": %s\n", \
                        progname, ## __VA_ARGS__, strerror(save)); \
 } while (0)
 
index 1bdccb7..0b71f80 100644 (file)
@@ -82,7 +82,7 @@ static struct board_info boards[] = {
 #define ERRS(fmt, ...) do { \
        int save = errno; \
        fflush(0); \
-       fprintf(stderr, "[%s] *** error: " fmt "\n", \
+       fprintf(stderr, "[%s] *** error: " fmt ": %s\n", \
                        progname, ## __VA_ARGS__, strerror(save)); \
 } while (0)
 
index 1302d46..96fd6a0 100644 (file)
@@ -450,7 +450,7 @@ static struct board_info boards[] = {
 #define ERRS(fmt, ...) do { \
        int save = errno; \
        fflush(0); \
-       fprintf(stderr, "[%s] *** error: " fmt "\n", \
+       fprintf(stderr, "[%s] *** error: " fmt ": %s\n", \
                        progname, ## __VA_ARGS__, strerror(save)); \
 } while (0)
 
index 25915e6..9277529 100644 (file)
@@ -189,7 +189,7 @@ static struct board_info boards[] = {
 #define ERRS(fmt, ...) do { \
        int save = errno; \
        fflush(0); \
-       fprintf(stderr, "[%s] *** error: " fmt "\n", \
+       fprintf(stderr, "[%s] *** error: " fmt ": %s\n", \
                        progname, ## __VA_ARGS__, strerror(save)); \
 } while (0)
 
index 7674e70..2326f1f 100644 (file)
@@ -100,7 +100,7 @@ static struct board_info boards[] = {
 #define ERRS(fmt, ...) do { \
        int save = errno; \
        fflush(0); \
-       fprintf(stderr, "[%s] *** error: " fmt "\n", \
+       fprintf(stderr, "[%s] *** error: " fmt ": %s\n", \
                        progname, ## __VA_ARGS__, strerror(save)); \
 } while (0)
 
index 36c176f..ccbabfe 100644 (file)
@@ -27,6 +27,7 @@
 #if defined(__CYGWIN__)
 #  include <byteswap.h>
 #endif
+#include <inttypes.h>
 
 #include "zynos.h"
 
@@ -687,7 +688,7 @@ write_out_file(FILE *outfile, char *name, size_t len, struct csum_state *css)
        FILE *f;
        int res;
 
-       DBG(2, "writing out file, name=%s, len=%d",
+       DBG(2, "writing out file, name=%s, len=%zu",
                name, len);
 
        errno = 0;
@@ -988,7 +989,7 @@ calc_block_offsets(int type, uint32_t *offset)
        uint32_t avail;
        int i, res;
 
-       DBG(1,"calculating block offsets, starting with %lu",
+       DBG(1,"calculating block offsets, starting with %" PRIu32,
                *offset);
 
        res = 0;
index f2e3920..5fd236a 100644 (file)
@@ -51,7 +51,7 @@ static char *ofname;
 #define ERRS(fmt, ...) do { \
        int save = errno; \
        fflush(0); \
-       fprintf(stderr, "[%s] *** error: " fmt "\n", \
+       fprintf(stderr, "[%s] *** error: " fmt ": %s\n", \
                        progname, ## __VA_ARGS__, strerror(save)); \
 } while (0)
 
index 9c2eb83..fe41b3d 100644 (file)
@@ -208,7 +208,7 @@ static int decrypt;
 #define ERRS(fmt, ...) do { \
        int save = errno; \
        fflush(0); \
-       fprintf(stderr, "[%s] *** error: " fmt "\n", \
+       fprintf(stderr, "[%s] *** error: " fmt ": %s\n", \
                        progname, ## __VA_ARGS__, strerror(save)); \
 } while (0)
 
index 944ed3a..05aee8e 100644 (file)
@@ -235,10 +235,10 @@ static int verify_seama(const char * fname, int msg)
                        {
                                printf("SEAMA ==========================================\n");
                                printf("  magic      : %08x\n", ntohl(shdr.magic));
-                               printf("  meta size  : %d bytes\n", msize);
+                               printf("  meta size  : %zu bytes\n", msize);
                                for (i=0; i<msize; i+=(strlen((const char *)&buf[i])+1))
                                        printf("  meta data  : %s\n", &buf[i]);
-                               printf("  image size : %d bytes\n", isize);
+                               printf("  image size : %zu bytes\n", isize);
                        }
 
                        /* verify checksum */
@@ -473,7 +473,7 @@ static void extract_file(const char * output)
                                fread(buf, sizeof(char), msize, ifh);
                                if (match_meta((const char *)buf, msize))
                                {
-                                       printf("SEAMA: found image @ '%s', image size: %d\n", o_images[i], isize);
+                                       printf("SEAMA: found image @ '%s', image size: %zu\n", o_images[i], isize);
                                        /* open output file */
                                        ofh = fopen(output, "w");
                                        if (!ofh) printf("SEAMA: unable to open '%s' for writting.\n",output);