From afecfe46f314e9b5ba1d5d1d98d3e521be5f00b0 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 10 Apr 2008 21:16:00 +0000 Subject: cleanup code for picky compiler warning options git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17060 a1c6a512-1295-4272-9138-f99709370657 --- tools/bmp2rb.c | 23 ++++++++++++----------- tools/convbdf.c | 34 ++++++++++++++++++++-------------- tools/gigabeat.c | 4 ++-- tools/gigabeats.c | 4 ++-- tools/iriver.c | 20 ++++++++++---------- tools/mktccboot.c | 3 ++- tools/scramble.c | 12 ++++++------ 7 files changed, 54 insertions(+), 46 deletions(-) (limited to 'tools') diff --git a/tools/bmp2rb.c b/tools/bmp2rb.c index 7848298136..10481917a4 100644 --- a/tools/bmp2rb.c +++ b/tools/bmp2rb.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -140,7 +141,7 @@ int read_bmp_file(char* filename, if (compression != 0) { - debugf("error - Unsupported compression %ld\n", compression); + debugf("error - Unsupported compression %d\n", compression); close(fd); return 3; } @@ -154,7 +155,7 @@ int read_bmp_file(char* filename, numcolors = 1 << depth; if (read(fd, &palette[0], numcolors * sizeof(struct RGBQUAD)) - != numcolors * sizeof(struct RGBQUAD)) + != (int)(numcolors * sizeof(struct RGBQUAD))) { debugf("error - Can't read bitmap's color palette\n"); close(fd); @@ -459,8 +460,8 @@ void generate_c_source(char *id, char* header_dir, int width, int height, return; } fprintf(fh, - "#define BMPHEIGHT_%s %ld\n" - "#define BMPWIDTH_%s %ld\n", + "#define BMPHEIGHT_%s %d\n" + "#define BMPWIDTH_%s %d\n", id, height, id, width); if (t_depth <= 8) fprintf(fh, "extern const unsigned char %s[];\n", id); @@ -470,8 +471,8 @@ void generate_c_source(char *id, char* header_dir, int width, int height, fclose(fh); } else { fprintf(f, - "#define BMPHEIGHT_%s %ld\n" - "#define BMPWIDTH_%s %ld\n", + "#define BMPHEIGHT_%s %d\n" + "#define BMPWIDTH_%s %d\n", id, height, id, width); } @@ -497,7 +498,7 @@ void generate_c_source(char *id, char* header_dir, int width, int height, fprintf(f, "\n};\n"); } -void generate_raw_file(char *id, const unsigned short *t_bitmap, +void generate_raw_file(const unsigned short *t_bitmap, int t_width, int t_height, int t_depth) { FILE *f; @@ -559,14 +560,14 @@ void print_usage(void) "\t-r Generate RAW file (little-endian)\n" "\t-f Generate destination format n, default = 0\n" "\t 0 Archos recorder, Ondio, Iriver H1x0 mono\n" - "\t 1 Archos player graphics library\n" + , APPLICATION_NAME); + printf("\t 1 Archos player graphics library\n" "\t 2 Iriver H1x0 4-grey\n" "\t 3 Canonical 8-bit greyscale\n" "\t 4 16-bit packed 5-6-5 RGB (iriver H300)\n" "\t 5 16-bit packed and byte-swapped 5-6-5 RGB (iPod)\n" "\t 6 Greyscale iPod 4-grey\n" - "\t 7 Greyscale X5 remote 4-grey\n" - , APPLICATION_NAME); + "\t 7 Greyscale X5 remote 4-grey\n"); printf("build date: " __DATE__ "\n\n"); } @@ -703,7 +704,7 @@ int main(int argc, char **argv) &t_width, &t_height, &t_depth)) exit(1); if(raw) - generate_raw_file(id, t_bitmap, t_width, t_height, t_depth); + generate_raw_file(t_bitmap, t_width, t_height, t_depth); else generate_c_source(id, header_dir, width, height, t_bitmap, t_width, t_height, t_depth); diff --git a/tools/convbdf.c b/tools/convbdf.c index cd76563003..8e2b4bdcc2 100644 --- a/tools/convbdf.c +++ b/tools/convbdf.c @@ -569,7 +569,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) if (padnibbles <= 0) break; - if (padnibbles >= BITMAP_NIBBLES) + if (padnibbles >= (int)BITMAP_NIBBLES) padnibbles = 0; value = bdf_hexval((unsigned char *)buf, @@ -610,7 +610,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) #ifdef ROTATE l = 0; for (i=0; isize; ++i) { - if (pf->offrot[i] != l) { + if ((int)pf->offrot[i] != l) { encodetable = 1; break; } @@ -785,9 +785,11 @@ int gen_c_source(struct font* pf, char *path) { FILE *ofp; int i, ofr = 0; - int did_syncmsg = 0; time_t t = time(0); +#ifndef ROTATE + int did_syncmsg = 0; bitmap_t *ofs = pf->bits; +#endif char buf[256]; char obuf[256]; char hdr1[] = { @@ -841,13 +843,13 @@ int gen_c_source(struct font* pf, char *path) int width = pf->width ? pf->width[i] : pf->maxwidth; int height = pf->height; bitmap_t *bits; - bitmap_t bitvalue; + bitmap_t bitvalue=0; /* Skip missing glyphs */ if (pf->offset && (pf->offset[i] == (unsigned int)-1)) continue; - bits = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i)); + bits = pf->bits + (pf->offset? (int)pf->offset[i]: (pf->height * i)); fprintf(ofp, "\n/* Character %d (0x%02x):\n width %d", i+pf->firstchar, i+pf->firstchar, width); @@ -885,7 +887,7 @@ int gen_c_source(struct font* pf, char *path) else fprintf(ofp, " */\n"); - bits = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i)); + bits = pf->bits + (pf->offset? (int)pf->offset[i]: (pf->height * i)); #ifdef ROTATE /* pre-rotated into Rockbox bitmap format */ { unsigned char bytemap[512]; @@ -929,7 +931,7 @@ int gen_c_source(struct font* pf, char *path) pf->offset[i] = pf->offset[pf->defaultchar - pf->firstchar]; pf->offrot[i] = pf->offrot[pf->defaultchar - pf->firstchar]; } - fprintf(ofp, " %ld,\t/* (0x%02x) */\n", + fprintf(ofp, " %d,\t/* (0x%02x) */\n", #ifdef ROTATE pf->offrot[i], i+pf->firstchar); #else @@ -993,7 +995,7 @@ int gen_h_header(struct font* pf, char *path) FILE *ofp; time_t t = time(0); char buf[256]; - char hdr1[] = { + char *hdr1 = "/* Generated by convbdf on %s. */\n" "#ifdef HAVE_LCD_BITMAP\n" "\n" @@ -1003,7 +1005,8 @@ int gen_h_header(struct font* pf, char *path) "#define SYSFONT_WIDTH %d\n" "#define SYSFONT_HEIGHT %d\n" "#define SYSFONT_SIZE %d\n" - "#define SYSFONT_ASCENT %d\n" + "#define SYSFONT_ASCENT %d\n"; + char *hdr2 = "#define SYSFONT_DESCENT %d\n" "#define SYSFONT_FIRST_CHAR %d\n" "#define SYSFONT_LAST_CHAR %d\n" @@ -1012,8 +1015,7 @@ int gen_h_header(struct font* pf, char *path) "#define SYSFONT_COPYRIGHT %s\n" "#define SYSFONT_BITS_SIZE %d\n" "\n" - "#endif\n" - }; + "#endif\n"; ofp = fopen(path, "w"); if (!ofp) { @@ -1030,7 +1032,9 @@ int gen_h_header(struct font* pf, char *path) pf->maxwidth, pf->height, pf->size, - pf->ascent, + pf->ascent); + + fprintf(ofp, hdr2, buf, pf->descent, pf->firstchar, pf->firstchar+pf->size-1, @@ -1063,9 +1067,10 @@ static int writeint(FILE *fp, unsigned int l) static int writestr(FILE *fp, char *str, int count) { - return fwrite(str, 1, count, fp) == count; + return (int)fwrite(str, 1, count, fp) == count; } +#ifndef ROTATE static int writestrpad(FILE *fp, char *str, int totlen) { int ret; @@ -1080,6 +1085,7 @@ static int writestrpad(FILE *fp, char *str, int totlen) ret = putc(' ', fp); return ret; } +#endif /* generate .fnt format file from in-core font*/ int gen_fnt_file(struct font* pf, char *path) @@ -1131,7 +1137,7 @@ int gen_fnt_file(struct font* pf, char *path) if (pf->offset && (pf->offset[i] == (unsigned int)-1)) continue; - bits = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i)); + bits = pf->bits + (pf->offset? (int)pf->offset[i]: (pf->height * i)); size = rotleft(bytemap, sizeof(bytemap), bits, width, pf->height); writestr(ofp, (char *)bytemap, size); diff --git a/tools/gigabeat.c b/tools/gigabeat.c index 5a8d01125d..761e8c31a0 100644 --- a/tools/gigabeat.c +++ b/tools/gigabeat.c @@ -33,7 +33,7 @@ static FILE * openinfile( const char * filename ) exit( -1 ); }; return F; -}; +} static FILE * openoutfile( const char * filename ) { @@ -45,7 +45,7 @@ static FILE * openoutfile( const char * filename ) exit( -1 ); }; return F; -}; +} int gigabeat_code(char *infile, char *outfile) { diff --git a/tools/gigabeats.c b/tools/gigabeats.c index 2c5a6286af..66fd885eb2 100644 --- a/tools/gigabeats.c +++ b/tools/gigabeats.c @@ -36,7 +36,7 @@ static FILE * openinfile( const char * filename ) exit( -1 ); }; return F; -}; +} static FILE * openoutfile( const char * filename ) { @@ -48,7 +48,7 @@ static FILE * openoutfile( const char * filename ) exit( -1 ); }; return F; -}; +} static uint32_t calc_csum(const unsigned char* pb, int cb) { diff --git a/tools/iriver.c b/tools/iriver.c index 240f9e36a2..6730fbd8b2 100644 --- a/tools/iriver.c +++ b/tools/iriver.c @@ -49,16 +49,16 @@ static int testheader( const unsigned char * const data ) { const unsigned char * const d = data+16; const char * const * m = models; - int index = 0; + int ind = 0; while( *m ) { - if( memcmp( header[ index ], d, 16 ) == 0 ) - return index; - index++; + if( memcmp( header[ ind ], d, 16 ) == 0 ) + return ind; + ind++; m++; }; return -1; -}; +} static void modifyheader( unsigned char * data ) { @@ -70,7 +70,7 @@ static void modifyheader( unsigned char * data ) h = header_modify; *data++ ^= *h++; }; -}; +} static FILE * openinfile( const char * filename ) { @@ -82,7 +82,7 @@ static FILE * openinfile( const char * filename ) exit( -1 ); }; return F; -}; +} static FILE * openoutfile( const char * filename ) { @@ -94,7 +94,7 @@ static FILE * openoutfile( const char * filename ) exit( -1 ); }; return F; -}; +} int iriver_decode(char *infile_name, char *outfile_name, BOOL modify, enum striptype stripmode ) @@ -256,7 +256,7 @@ int iriver_decode(char *infile_name, char *outfile_name, BOOL modify, }; return 0; -}; +} int iriver_encode(char *infile_name, char *outfile_name, BOOL modify ) { @@ -376,4 +376,4 @@ int iriver_encode(char *infile_name, char *outfile_name, BOOL modify ) fprintf( stderr, "File encoded successfully and checksum table built!\n" ); return 0; -}; +} diff --git a/tools/mktccboot.c b/tools/mktccboot.c index 90b85e8335..fcfd80a676 100644 --- a/tools/mktccboot.c +++ b/tools/mktccboot.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -94,7 +95,7 @@ int main(int argc, char *argv[]) { char *infile, *bootfile, *outfile; int fdin, fdboot,fdout; - int i,n; + int n; int inlength,bootlength; uint32_t ldr; unsigned char* image; diff --git a/tools/scramble.c b/tools/scramble.c index 7efade3419..130ca89ffb 100644 --- a/tools/scramble.c +++ b/tools/scramble.c @@ -99,8 +99,8 @@ void usage(void) "\t-iaudiox5 iAudio X5 format\n" "\t-iaudiox5v iAudio X5V format\n" "\t-iaudiom5 iAudio M5 format\n" - "\t-iaudiom3 iAudio M3 format\n" - "\t-ipod3g ipod firmware partition format (3rd Gen)\n" + "\t-iaudiom3 iAudio M3 format\n"); + printf("\t-ipod3g ipod firmware partition format (3rd Gen)\n" "\t-ipod4g ipod firmware partition format (4th Gen, Mini, Nano, Photo/Color)\n" "\t-ipod5g ipod firmware partition format (5th Gen - aka Video)\n" "\t-creative=X Creative firmware structure format\n" @@ -109,16 +109,16 @@ void usage(void) "\t-mi4v2 PortalPlayer .mi4 format (revision 010201)\n" "\t-mi4v3 PortalPlayer .mi4 format (revision 010301)\n" "\t-mi4r Sandisk Rhapsody .mi4 format\n" - "\t All mi4 options take two optional arguments:\n" - "\t -model=XXXX where XXXX is the model id string\n" + "\t All mi4 options take two optional arguments:\n"); + printf("\t -model=XXXX where XXXX is the model id string\n" "\t -type=XXXX where XXXX is a string indicating the \n" "\t type of binary, eg. RBOS, RBBL\n" "\t-tcc=X Telechips generic firmware format (X values: sum, crc)\n" "\t-add=X Rockbox generic \"add-up\" checksum format\n" "\t (X values: h100, h120, h140, h300, ipco, nano, ipvd, mn2g\n" "\t ip3g, ip4g, mini, iax5, iam5, iam3, h10, h10_5gb,\n" - "\t tpj2, c200, e200, giga, gigs, m100, m500, d2)\n" - "\nNo option results in Archos standard player/recorder format.\n"); + "\t tpj2, c200, e200, giga, gigs, m100, m500, d2)\n"); + printf("\nNo option results in Archos standard player/recorder format.\n"); exit(1); } -- cgit