1
0
Fork 0
forked from len0rd/rockbox

cleanup code for picky compiler warning options

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17060 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Daniel Stenberg 2008-04-10 21:16:00 +00:00
parent f8f1f3e811
commit afecfe46f3
7 changed files with 54 additions and 46 deletions

View file

@ -32,6 +32,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -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 <n> 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);

View file

@ -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; i<pf->size; ++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);

View file

@ -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)
{

View file

@ -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)
{

View file

@ -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;
};
}

View file

@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@ -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;

View file

@ -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);
}