]> www.infradead.org Git - mtd-utils.git/commitdiff
mtd-utils: clean up compile warnings
authorKevin Cernekee <cernekee@gmail.com>
Mon, 26 Jul 2010 18:37:19 +0000 (11:37 -0700)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Fri, 30 Jul 2010 06:01:44 +0000 (09:01 +0300)
gcc 4.4.3 on x86_64:

libcrc32.c:42: warning: ‘static’ is not at beginning of declaration

libfec.c:120: warning: initialization discards qualifiers from pointer target type
libfec.c:121: warning: initialization discards qualifiers from pointer target type

libfec.c:417: warning: passing argument 2 of ‘my_malloc’ discards qualifiers from pointer target type

recv_image.c:164: warning: comparison of unsigned expression < 0 is always false
recv_image.c:170: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘size_t’
recv_image.c:170: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long unsigned int’

And many more along the same lines.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
compr.h
lib/libcrc32.c
lib/libfec.c
mkfs.jffs2.c
mtd_debug.c
nandtest.c
nftl_format.c
recv_image.c
sumtool.c

diff --git a/compr.h b/compr.h
index 51bf0dd6350b2733872e244601d0689165f5fa9e..4b7980291b15061591b957b67441c4044e13ae28 100644 (file)
--- a/compr.h
+++ b/compr.h
@@ -67,7 +67,7 @@ int jffs2_set_compressor_priority(const char *name, int priority);
 struct jffs2_compressor {
        struct list_head list;
        int priority;             /* used by prirority comr. mode */
-       char *name;
+       const char *name;
        char compr;               /* JFFS2_COMPR_XXX */
        int (*compress)(unsigned char *data_in, unsigned char *cpage_out,
                        uint32_t *srclen, uint32_t *destlen, void *model);
index d556e9165410d09cdbb416ebb26802bd389f2b00..d47a8426b873f2c104fdeab0659f7822e730280b 100644 (file)
@@ -39,7 +39,7 @@
 
 #include <stdint.h>
 
-const static uint32_t crc32_table[256] = {
+static const uint32_t crc32_table[256] = {
        0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
        0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
        0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
index 6d9020fb96025d4f2f1f0f39445a00d57c6ce200..adf2bba1097bc04408cc4e50ad11494cc828d73f 100644 (file)
@@ -114,7 +114,7 @@ typedef unsigned short gf;
  * Primitive polynomials - see Lin & Costello, Appendix A,
  * and  Lee & Messerschmitt, p. 453.
  */
-static char *allPp[] = {    /* GF_BITS polynomial              */
+static const char *allPp[] = {    /* GF_BITS   polynomial              */
     NULL,                  /*  0       no code                 */
     NULL,                  /*  1       no code                 */
     "111",                 /*  2       1+x+x^2                 */
@@ -226,7 +226,7 @@ gf_mul(x,y)
  * one place.
  */
 static void *
-my_malloc(int sz, char *err_string)
+my_malloc(int sz, const char *err_string)
 {
     void *p = malloc( sz );
     if (p == NULL) {
@@ -247,7 +247,7 @@ generate_gf(void)
 {
     int i;
     gf mask;
-    char *Pp =  allPp[GF_BITS] ;
+    const char *Pp =  allPp[GF_BITS] ;
 
     mask = 1;  /* x ** 0 = 1 */
     gf_exp[GF_BITS] = 0; /* will be updated at the end of the 1st loop */
index 4ba71fe634a9ccdb7e50257a3f97d372b137fd8b..181fe9d11a35588a1757128db05cc7692e7fe067 100644 (file)
@@ -1090,7 +1090,7 @@ static uint32_t highest_xseqno = 0;
 
 static struct {
        int xprefix;
-       char *string;
+       const char *string;
        int length;
 } xprefix_tbl[] = {
        { JFFS2_XPREFIX_USER, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN },
@@ -1232,7 +1232,8 @@ static void write_xattr_entry(struct filesystem_entry *e)
        struct jffs2_raw_xref ref;
        struct xattr_entry *xe;
        char xlist[XATTR_BUFFER_SIZE], xvalue[XATTR_BUFFER_SIZE];
-       char *xname, *prefix_str;
+       char *xname;
+       const char *prefix_str;
        int i, xprefix, prefix_len;
        int list_sz, offset, name_len, value_len;
 
@@ -1481,7 +1482,7 @@ static struct option long_options[] = {
        {NULL, 0, NULL, 0}
 };
 
-static char *helptext =
+static const char helptext[] =
 "Usage: mkfs.jffs2 [OPTIONS]\n"
 "Make a JFFS2 file system image from an existing directory tree\n\n"
 "Options:\n"
@@ -1520,7 +1521,7 @@ static char *helptext =
 "  -V, --version           Display version information\n"
 "  -i, --incremental=FILE  Parse FILE and generate appendage output for it\n\n";
 
-static char *revtext = "1.60";
+static const char revtext[] = "1.60";
 
 int load_next_block() {
 
index 4934699a33df4f305ee1838f9759c7f0fae584da..928cb5a70c2b094d567fe7b1bf9fd3f58992fe32 100644 (file)
@@ -158,7 +158,7 @@ retry:
        if (buf != NULL)
                free (buf);
        close (outfd);
-       printf ("Copied %d bytes from address 0x%.8x in flash to %s\n",len,offset,filename);
+       printf ("Copied %zu bytes from address 0x%.8x in flash to %s\n",len,offset,filename);
        return (0);
 
 err2:
@@ -309,7 +309,7 @@ int showinfo (int fd)
                        {
                                if (first)
                                {
-                                       printf (flags[i].name);
+                                       printf ("%s", flags[i].name);
                                        first = 0;
                                }
                                else printf (" | %s",flags[i].name);
index 13e9577a3c16bed906b043132542e6048ae6b372..4d90159f0bd18230681dbbebd7a5a29b0f21ae20 100644 (file)
@@ -70,7 +70,7 @@ int erase_and_write(loff_t ofs, unsigned char *data, unsigned char *rbuf)
        }
        if (len < meminfo.erasesize) {
                printf("\n");
-               fprintf(stderr, "Short write (%d bytes)\n", len);
+               fprintf(stderr, "Short write (%zd bytes)\n", len);
                exit(1);
        }
 
@@ -81,7 +81,7 @@ int erase_and_write(loff_t ofs, unsigned char *data, unsigned char *rbuf)
        if (len < meminfo.erasesize) {
                printf("\n");
                if (len)
-                       fprintf(stderr, "Short read (%d bytes)\n", len);
+                       fprintf(stderr, "Short read (%zd bytes)\n", len);
                else
                        perror("read");
                exit(1);
@@ -263,7 +263,7 @@ int main(int argc, char **argv)
                                if (len < meminfo.erasesize) {
                                        printf("\n");
                                        if (len)
-                                               fprintf(stderr, "Short read (%d bytes)\n", len);
+                                               fprintf(stderr, "Short read (%zd bytes)\n", len);
                                        else
                                                perror("read");
                                        exit(1);
index 42949a0393e88cf5ec309387781e9f430b6bd096..167098a6c7cb1507ef9833c72a0b36f20c660492 100644 (file)
@@ -202,7 +202,8 @@ int main(int argc, char **argv)
        long MediaUnitOff1 = 0, MediaUnitOff2 = 0;
        unsigned char oobbuf[16];
        struct mtd_oob_buf oob = {0, 16, oobbuf};
-       char *mtddevice, *nftl;
+       char *mtddevice;
+       const char *nftl;
        int c, do_inftl = 0, do_bbt = 0;
 
 
index 2be511aa1cfd3c2a52729d672cb8f0848976bfdb..35059b318998d2a37707eb2cd57e619378be3d60 100644 (file)
@@ -39,24 +39,24 @@ int main(int argc, char **argv)
        struct addrinfo *runp;
        int ret;
        int sock;
-       size_t len;
+       ssize_t len;
        int flfd;
        struct mtd_info_user meminfo;
        unsigned char *eb_buf, *decode_buf, **src_pkts;
        int nr_blocks = 0;
        int pkts_per_block;
        int block_nr = -1;
-       uint32_t image_crc;
+       uint32_t image_crc = 0;
        int total_pkts = 0;
        int ignored_pkts = 0;
        loff_t mtdoffset = 0;
        int badcrcs = 0;
        int duplicates = 0;
        int file_mode = 0;
-       struct fec_parms *fec;
+       struct fec_parms *fec = NULL;
        int i;
        struct eraseblock *eraseblocks = NULL;
-       uint32_t start_seq;
+       uint32_t start_seq = 0;
        struct timeval start, now;
        unsigned long fec_time = 0, flash_time = 0, crc_time = 0,
                rflash_time = 0, erase_time = 0, net_time = 0;
@@ -166,7 +166,7 @@ int main(int argc, char **argv)
                        break;
                }
                if (len < sizeof(thispkt)) {
-                       fprintf(stderr, "Wrong length %d bytes (expected %d)\n",
+                       fprintf(stderr, "Wrong length %zd bytes (expected %lu)\n",
                                len, sizeof(thispkt));
                        continue;
                }
index 966e110fbce6795f19ac91f4fe8cadf1c885aeac..11b25b1ca8c215dd32fa3059325c5eadefc7cea2 100644 (file)
--- a/sumtool.c
+++ b/sumtool.c
@@ -88,7 +88,7 @@ static struct option long_options[] = {
        {NULL, 0, NULL, 0}
 };
 
-static char *helptext =
+static const char helptext[] =
 "Usage: sumtool [OPTIONS] -i inputfile -o outputfile\n\n"
 "Convert the input JFFS2 image to a summarized JFFS2 image\n"
 "Summary makes mounting faster - if summary support enabled in your kernel\n\n"
@@ -112,7 +112,7 @@ static char *helptext =
 "                            eraseblock\n\n";
 
 
-static char *revtext = "$Revision: 1.9 $";
+static const char revtext[] = "$Revision: 1.9 $";
 
 static unsigned char ffbuf[16] = {
        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@@ -927,7 +927,7 @@ int main(int argc, char **argv)
                        close(in_fd);
                if(out_fd != -1)
                        close(out_fd);
-               fprintf(stderr,helptext);
+               fprintf(stderr, "%s", helptext);
                error_msg_and_die("You must specify input and output files!\n");
        }