firmware-utils: fix -Wpointer-sign warnings
[openwrt/openwrt.git] / tools / firmware-utils / src / mkrtn56uimg.c
index 973ab28d06ae587d6e2a0712749795798d09b627..689dc8b37553841664b38d179674c636dd13613d 100644 (file)
@@ -17,7 +17,6 @@
 #include <netinet/in.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
-#include <time.h>
 #include <unistd.h>
 #include <zlib.h>
 
@@ -68,7 +67,7 @@ typedef struct image_header {
        uint8_t         ih_type;
        uint8_t         ih_comp;
        union {
-               uint8_t ih_name[IH_NMLEN];
+               char    ih_name[IH_NMLEN];
                asus_t  asus;
        } tail;
 } image_header_t;
@@ -89,13 +88,13 @@ calc_crc(image_header_t *hdr, void *data, uint32_t len)
        /*
         * Calculate payload checksum
         */
-       hdr->ih_dcrc = htonl(crc32(0, data, len));
+       hdr->ih_dcrc = htonl(crc32(0, (Bytef *)data, len));
        hdr->ih_size = htonl(len);
        /*
         * Calculate header checksum
         */
        hdr->ih_hcrc = 0;
-       hdr->ih_hcrc = htonl(crc32(0, hdr, sizeof(image_header_t)));
+       hdr->ih_hcrc = htonl(crc32(0, (Bytef *)hdr, sizeof(image_header_t)));
 }
 
 
@@ -103,7 +102,6 @@ static void
 usage(const char *progname, int status)
 {
        FILE *stream = (status != EXIT_SUCCESS) ? stderr : stdout;
-       int i;
 
        fprintf(stream, "Usage: %s [OPTIONS...]\n", progname);
        fprintf(stream, "\n"
@@ -117,12 +115,12 @@ usage(const char *progname, int status)
 int
 process_image(char *progname, char *filename, op_mode_t opmode)
 {
-       int             fd, len;
-       void            *data, *ptr;
+       int             fd;
+       void            *ptr;
        char            namebuf[IH_NMLEN];
        struct          stat sbuf;
-       uint32_t        checksum, offset_kernel, offset_sqfs, offset_end,
-                               offset_sec_header, offset_eb, offset_image_end;
+       uint32_t        offset_kernel, offset_sqfs, offset_end,
+                       offset_sec_header, offset_eb, offset_image_end;
        squashfs_sb_t *sqs;
        image_header_t *hdr;
 
@@ -166,7 +164,7 @@ process_image(char *progname, char *filename, op_mode_t opmode)
        }
 
        if (opmode == FACTORY) {
-               strncpy(&namebuf, (char *)&hdr->tail.ih_name, IH_NMLEN);
+               strncpy(namebuf, hdr->tail.ih_name, IH_NMLEN);
                hdr->tail.asus.kernel.major = 0;
                hdr->tail.asus.kernel.minor = 0;
                hdr->tail.asus.fs.major = 0;
@@ -231,7 +229,7 @@ process_image(char *progname, char *filename, op_mode_t opmode)
        if (opmode == FACTORY) {
                hdr = ptr+offset_sec_header;
                memcpy(hdr, ptr, sizeof(image_header_t));
-               strncpy((char *)&hdr->tail.ih_name, &namebuf, IH_NMLEN);
+               strncpy(hdr->tail.ih_name, namebuf, IH_NMLEN);
                calc_crc(hdr, ptr+offset_kernel, offset_sqfs - offset_kernel);
                calc_crc((image_header_t *)ptr, ptr+offset_kernel, offset_image_end - offset_kernel);
        } else {
@@ -253,7 +251,8 @@ int
 main(int argc, char **argv)
 {
        int             opt;
-       char            *filename, *progname;
+       char            *filename = NULL;
+       char            *progname;
        op_mode_t       opmode = NONE;
 
        progname = argv[0];