fixed format warnings
authorMatthias Kramm <kramm@quiss.org>
Sat, 9 Jan 2010 01:12:57 +0000 (17:12 -0800)
committerMatthias Kramm <kramm@quiss.org>
Sat, 9 Jan 2010 01:12:57 +0000 (17:12 -0800)
29 files changed:
configure
configure.in
lib/as3/abc.c
lib/as3/code.c
lib/as3/pool.c
lib/devices/pdf.c
lib/devices/render.c
lib/gfxfont.c
lib/gfxpoly/convert.c
lib/gfxpoly/poly.c
lib/gfxpoly/renderpoly.c
lib/jpeg.c
lib/modules/swffont.c
lib/modules/swfrender.c
lib/os.c
lib/pdf/GFXOutputDev.cc
lib/pdf/xpdf-changes.patch
lib/png.c
lib/q.c
lib/readers/swf.c
lib/rfxswf.c
lib/wav.c
src/jpeg2swf.c
src/png2swf.c
src/swfc.c
src/swfcombine.c
src/swfdump.c
src/swfextract.c
src/wav2swf.c

index 043e6f2..abe5a95 100755 (executable)
--- a/configure
+++ b/configure
@@ -1901,7 +1901,7 @@ if test "x${srcdir}" != "x."; then
     exit 1
 fi
 
-WARNINGS="-Wimplicit -Wreturn-type -Wno-write-strings"
+WARNINGS="-Wimplicit -Wreturn-type -Wno-write-strings -Wformat"
 if test "x$ENABLE_WARNINGS" '!=' "x";then
     WARNINGS="-Wall -Wno-unused -Wno-format -Wno-redundant-decls -Wno-write-strings -D_FORTIFY_SOURCE=2 "
 fi
index f9ff1e7..4c8307b 100644 (file)
@@ -43,7 +43,7 @@ if test "x${srcdir}" != "x."; then
     exit 1
 fi
 
-WARNINGS="-Wimplicit -Wreturn-type -Wno-write-strings"
+WARNINGS="-Wimplicit -Wreturn-type -Wno-write-strings -Wformat"
 if test "x$ENABLE_WARNINGS" '!=' "x";then
     WARNINGS="-Wall -Wno-unused -Wno-format -Wno-redundant-decls -Wno-write-strings -D_FORTIFY_SOURCE=2 "
 fi
index 6de2c2d..7e11e1c 100644 (file)
@@ -777,7 +777,7 @@ void* swf_ReadABC(TAG*tag)
        
         DEBUG printf("method %d) %s ", t, m->name);
         DEBUG params_dump(stdout, m->parameters, m->optional_parameters);
-        DEBUG printf("flags=%02x\n", t, m->flags);
+        DEBUG printf("flags=%02x\n", m->flags);
 
         if(m->flags&0x08) {
             m->optional_parameters = list_new();
index 8e41f22..541ebf5 100644 (file)
@@ -255,10 +255,10 @@ code_t* code_atposition(codelookup_t*l, int pos)
 
 void lookupswitch_print(lookupswitch_t*l)
 {
-    printf("default: %08x\n", l->def);
+    printf("default: %08x\n", (int)l->def);
     code_list_t*t = l->targets;
     while(t) {
-        printf("target: %08x\n", t->code);
+        printf("target: %08x\n", (int)t->code);
         t = t->next;
     }
 }
@@ -990,7 +990,7 @@ int code_dump2(code_t*c, abc_exception_list_t*exceptions, abc_file_t*file, char*
                     if(c->branch)
                         fprintf(fo, "->%d", c->branch->pos);
                     else
-                        fprintf(fo, "%08x", c->branch);
+                        fprintf(fo, "%08x", (unsigned int)c->branch);
                 } else if(*p == 's') {
                     char*s = string_escape((string_t*)data);
                     fprintf(fo, "\"%s\"", s);
index edd048b..3889ee6 100644 (file)
@@ -185,9 +185,9 @@ char* namespace_tostring(namespace_t*ns)
     char*s = escape_string(ns->name);
     char*string = (char*)malloc(strlen(access)+strlen(s)+7);
     if(!s)
-        sprintf(string, "[%s]NULL", access, s);
+        sprintf(string, "[%s]NULL", access);
     else if(!*s)
-        sprintf(string, "[%s]\"\"", access, s);
+        sprintf(string, "[%s]\"\"", access);
     else 
         sprintf(string, "[%s]%s", access, s);
     free(s);
@@ -953,7 +953,7 @@ int pool_find_float(pool_t*pool, double x)
 {
     int i = array_find(pool->x_ints, &x);
     if(i<=0) {
-        fprintf(stderr, "Couldn't find int \"%d\" in constant pool\n", x);
+        fprintf(stderr, "Couldn't find int \"%f\" in constant pool\n", x);
         return 0;
     }
     return i;
@@ -965,7 +965,7 @@ int pool_find_namespace(pool_t*pool, namespace_t*ns)
     int i = array_find(pool->x_namespaces, ns);
     if(i<0) {
         char*s = namespace_tostring(ns);
-        fprintf(stderr, "Couldn't find namespace \"%s\" %08x in constant pool\n", s, ns);
+        fprintf(stderr, "Couldn't find namespace \"%s\" %08x in constant pool\n", s, (int)ns);
         free(s);
         return 0;
     }
@@ -991,7 +991,7 @@ int pool_find_string(pool_t*pool, const char*str)
     string_t s = string_new2(str);
     int i = array_find(pool->x_strings, &s);
     if(i<=0) {
-        fprintf(stderr, "Couldn't find string \"%s\" in constant pool\n", s);
+        fprintf(stderr, "Couldn't find string \"%s\" in constant pool\n", str);
         return 0;
     }
     return i;
@@ -1232,7 +1232,7 @@ void pool_dump(pool_t*pool, FILE*fo, char flags)
         int freq = (int)(ptroff_t)array_getvalue(pool->x_strings, t);
         if(flags&1) fprintf(fo, "%5d %d) ", freq, t);
         if(flags&1) fwrite(str.str, str.len, 1, fo);
-        if(flags&1) fprintf(fo, "\n", t);
+        if(flags&1) fprintf(fo, "\n");
     }
     fprintf(fo, "%d namespaces\n", pool->x_namespaces->num);
     for(t=1;t<pool->x_namespaces->num;t++) {
index bbbf9be..9e6365b 100644 (file)
@@ -235,7 +235,7 @@ void pdf_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color
        int fontid = (int)(ptroff_t)gfxfontlist_getuserdata(i->fontlist, font->id);
        PDF_setfont(i->p, fontid, matrix->m00);
        char name[32];
-       sprintf(name, "%c\0", glyphnr+32);
+       sprintf(name, "%c", glyphnr+32);
 
        if(fabs(matrix->tx - i->lastx) > 0.001 || matrix->ty != i->lasty) {
            PDF_show_xy2(i->p, name, strlen(name), matrix->tx, matrix->ty);
index cdba442..8e0ada0 100644 (file)
@@ -822,7 +822,7 @@ char*gfximage_asXPM(gfximage_t*img, int depth)
     int d= 256/depth;
     char*str = (char*)malloc(img->width*img->height*4 + 500 + 16*depth*depth*depth);
     char*p = str;
-    p+= sprintf(p, "static char *noname[] = {\n\"%d %d 262144 3\",\n");
+    p+= sprintf(p, "static char *noname[] = {\n\"%d %d 262144 3\",\n", img->width, img->height);
     int r,g,b;
     for(r=0;r<depth;r++)
     for(g=0;g<depth;g++)
index b040a7d..db78c25 100644 (file)
@@ -173,7 +173,7 @@ gfxfont_t* gfxfont_load(char*id, char*filename, unsigned int flags, double quali
        return 0;
     }
     if(face->num_glyphs <= 0) {
-       fprintf(stderr, "File %s contains %d glyphs\n", face->num_glyphs);
+       fprintf(stderr, "File %s contains %d glyphs\n", filename, (int)face->num_glyphs);
        return 0;
     }
 
@@ -333,9 +333,9 @@ gfxfont_t* gfxfont_load(char*id, char*filename, unsigned int flags, double quali
            error = FT_Load_Glyph(face, t, FT_LOAD_NO_BITMAP);
            if(error) {
                if(hasname)
-                   fprintf(stderr, "Warning: glyph %d/%d (unicode %d, name %s) has return code %d\n", t, face->num_glyphs, glyph2unicode[t], name, error);
+                   fprintf(stderr, "Warning: glyph %d/%d (unicode %d, name %s) has return code %d\n", t, (int)face->num_glyphs, glyph2unicode[t], name, error);
                else
-                   fprintf(stderr, "Warning: glyph %d/%d (unicode %d) has return code %d\n", t, face->num_glyphs, glyph2unicode[t], error);
+                   fprintf(stderr, "Warning: glyph %d/%d (unicode %d) has return code %d\n", t, (int)face->num_glyphs, glyph2unicode[t], error);
                omit = 2;
 
 #if 0
@@ -358,7 +358,7 @@ gfxfont_t* gfxfont_load(char*id, char*filename, unsigned int flags, double quali
        if(!omit) {
            error = FT_Get_Glyph(face->glyph, &glyph);
            if(error) {
-               fprintf(stderr, "Couldn't get glyph %d/%d, error:%d\n", t, face->num_glyphs, error);
+               fprintf(stderr, "Couldn't get glyph %d/%d, error:%d\n", t, (int)face->num_glyphs, error);
                omit = 3;
            }
        }
index 39517d7..f67699e 100644 (file)
@@ -92,7 +92,7 @@ static void convert_file(const char*filename, polywriter_t*w, double gridsize)
             break;
         double x,y;
         char s[256];
-        if(sscanf(line, "%lf %lf %s", &x, &y, &s) == 3) {
+        if(sscanf(line, "%lf %lf %s", &x, &y, (char*)&s) == 3) {
             if(s && !strcmp(s,"moveto")) {
                w->moveto(w, convert_coord(x,z), convert_coord(y,z));
                 count++;
index 53b45e2..eb1b6b1 100644 (file)
@@ -201,10 +201,10 @@ void gfxpoly_dump(gfxpoly_t*poly)
 {
     int s,t;
     double g = poly->gridsize;
-    fprintf(stderr, "polyon %08x (gridsize: %f)\n", poly, poly->gridsize);
+    fprintf(stderr, "polyon %08x (gridsize: %f)\n", (int)poly, poly->gridsize);
     gfxpolystroke_t*stroke = poly->strokes;
     for(;stroke;stroke=stroke->next) {
-       fprintf(stderr, "%08x", stroke);
+       fprintf(stderr, "%08x", (int)stroke);
        for(s=0;s<stroke->num_points-1;s++) {
            point_t a = stroke->points[s];
            point_t b = stroke->points[s+1];
index 57e341c..240859d 100644 (file)
@@ -175,7 +175,7 @@ unsigned char* render_polygon(gfxpoly_t*polygon, intbbox_t*bbox, double zoom, wi
         }
         if(fill.is_filled && lastx!=buf->width) {
             /* we're bleeding, fill over padding, too. */
-            fprintf(stderr, "Polygon %08x is bleeding in line %d\n", polygon, y);
+            fprintf(stderr, "Polygon %08x is bleeding in line %d\n", (int)polygon, y);
             fill_bitwise(line, lastx, width8*8);
            assert(line[width8-1]&0x01);
            bleeding = 1;
index 24bf2ed..71483f6 100644 (file)
@@ -227,7 +227,7 @@ boolean mem_fill_input_buffer (j_decompress_ptr cinfo)
 void mem_skip_input_data (j_decompress_ptr cinfo, long num_bytes)
 {
     struct jpeg_source_mgr* mgr = cinfo->src;
-    printf("skip %d +%d\n", size - mgr->bytes_in_buffer, num_bytes);
+    printf("skip %d +%ld\n", size - mgr->bytes_in_buffer, num_bytes);
     if(num_bytes<=0)
        return;
     mgr->next_input_byte += num_bytes;
index c16cf05..986c07d 100644 (file)
@@ -146,7 +146,7 @@ SWFFONT* swf_LoadTrueTypeFont(const char*filename, char flashtype)
     FT_Set_Pixel_Sizes (face, 16*loadfont_scale*scale, 16*loadfont_scale*scale);
 
     if(face->num_glyphs <= 0) {
-       fprintf(stderr, "File %s contains %d glyphs\n", face->num_glyphs);
+       fprintf(stderr, "File %s contains %d glyphs\n", filename, (int)face->num_glyphs);
        return 0;
     }
 
index 6524089..9df996f 100644 (file)
@@ -833,7 +833,7 @@ static void change_state(int y, state_t* state, renderpoint_t*p)
     layer_t*before=0, *self=0, *after=0;
 
     if(DEBUG&2) { 
-        printf("[(%d,%d)/%d/%d-%d]", p->x, y, p->depth, p->shapeline->fillstyle0, p->shapeline->fillstyle1);
+        printf("[(%f,%d)/%d/%d-%d]", p->x, y, p->depth, p->shapeline->fillstyle0, p->shapeline->fillstyle1);
     }
 
     search_layer(state, p->depth, &before, &self, &after);
index ccb0041..fddaee9 100755 (executable)
--- a/lib/os.c
+++ b/lib/os.c
@@ -210,7 +210,7 @@ char* mktempname(char*ptr) {
  //   used to be mktemp. This does remove the warnings, but
  //   It's not exactly an improvement.
 #ifdef HAVE_LRAND48
-    sprintf(ptr, "%s%s%08x%08x",dir,sep,lrand48(),lrand48());
+    sprintf(ptr, "%s%s%08x%08x",dir,sep,(unsigned int)lrand48(),(unsigned int)lrand48());
 #else
 #   ifdef HAVE_RAND
        sprintf(ptr, "%s%s%08x%08x",dir,sep,rand(),rand());
index 843dc5c..b450e54 100644 (file)
@@ -1917,7 +1917,7 @@ void GFXOutputDev::restoreState(GfxState *state) {
       if(verbose) {
          int t;
          for(t=0;t<=statepos;t++) {
-             printf("%08x ", states[t].state);
+             printf("%08x ", (unsigned int)states[t].state);
          }
          printf("\n");
       }
index dbc02ae..9068a67 100644 (file)
@@ -870,7 +870,7 @@ diff -u -r1.5 -r1.6
 + //   used to be mktemp. This does remove the warnings, but
 + //   It's not exactly an improvement.
 +#ifdef HAVE_LRAND48
-+    sprintf(ptr, "%s%s%08x%08x",dir,sep,lrand48(),lrand48());
++    sprintf(ptr, "%s%s%08x%08x",dir,sep,(unsigned int)lrand48(),(unsigned int)lrand48());
 +#else
 +#   ifdef HAVE_RAND
 +      sprintf(ptr, "%s%s%08x%08x",dir,sep,rand(),rand());
index b74dfb0..1738151 100644 (file)
--- a/lib/png.c
+++ b/lib/png.c
@@ -122,7 +122,7 @@ static int png_read_header(FILE*fi, struct png_header*header)
                return 0;
            }
            if(a!=8 && (b==2 || b==6)) {
-               printf("Bpp %d in mode %d not supported!\n", a);
+               printf("Bpp %d in mode %d not supported!\n", b, a);
                return 0;
            }
            if(c!=0) {
diff --git a/lib/q.c b/lib/q.c
index 67597df..a2d7a63 100644 (file)
--- a/lib/q.c
+++ b/lib/q.c
@@ -508,7 +508,7 @@ void _trie_dump(trielayer_t*t, char*buffer, int pos)
     }
     if(t->rest) {
         buffer[pos]=0;
-        printf("%s%s %08x\n", buffer, t->rest, t->data);
+        printf("%s%s %08x\n", buffer, t->rest, (int)t->data);
     }
 }
 
@@ -1083,9 +1083,9 @@ void dict_dump(dict_t*h, FILE*fi, const char*prefix)
         dictentry_t*e = h->slots[t];
         while(e) {
             if(h->key_type!=&charptr_type) {
-                fprintf(fi, "%s%08x=%08x\n", prefix, e->key, e->data);
+                fprintf(fi, "%s%08x=%08x\n", prefix, (int)e->key, (int)e->data);
             } else {
-                fprintf(fi, "%s%s=%08x\n", prefix, e->key, e->data);
+                fprintf(fi, "%s%s=%08x\n", prefix, (char*)e->key, (int)e->data);
             }
             e = e->next;
         }
@@ -1337,7 +1337,7 @@ static void freestring(void*data)
 static void dumpmapentry(void*data, const void*key, void*value)
 {
     FILE*fi = (FILE*)data;
-    fprintf(fi, "%s=%s\n", key, (char*)value);
+    fprintf(fi, "%s=%s\n", (char*)key, (char*)value);
 }
 void map_dump(map_t*map, FILE*fi, const char*prefix)
 {
index 5bff2a1..7cb3580 100644 (file)
@@ -92,7 +92,7 @@ void map16_free(map16_t*map)
 void map16_add_id(map16_t*map, int nr, void*id)
 {
     if(map->ids[nr])
-       fprintf(stderr, "Warning: ID %d defined more than once\n");
+       fprintf(stderr, "Warning: ID %d defined more than once\n", nr);
     map->ids[nr] = id;
 }
 void map16_remove_id(map16_t*map, int nr)
index c9006c1..d9444d6 100644 (file)
@@ -1881,7 +1881,7 @@ int swf_WriteCGI(SWF * swf)
 
   sprintf(s,"Content-type: application/x-shockwave-flash\n"
             "Accept-Ranges: bytes\n"
-            "Content-Length: %lu\n"
+            "Content-Length: %d\n"
             "Expires: Thu, 13 Apr 2000 23:59:59 GMT\n"
             "\n",len);
             
index ff577c7..5bd30d7 100644 (file)
--- a/lib/wav.c
+++ b/lib/wav.c
@@ -74,16 +74,14 @@ int wav_read(struct WAV*wav, const char* filename)
         return 0;
     }
     if(block.size + 8 < filesize)
-        fprintf(stderr, "wav_read: warning - more tags (%d extra bytes)\n",
-    filesize - block.size - 8);
+        fprintf(stderr, "wav_read: warning - more tags (%lu extra bytes)\n", filesize - block.size - 8);
 
     if(block.size == filesize)
        /* some buggy software doesn't generate the right tag length */
         block.size = filesize - 8;
 
     if(block.size + 8 > filesize)
-        fprintf(stderr, "wav_read: warning - short file (%d bytes missing)\n",
-    block.size + 8 -  filesize);
+        fprintf(stderr, "wav_read: warning - short file (%lu bytes missing)\n", block.size + 8 -  filesize);
     if(fread(b, 1, 4, fi) < 4)
     {
         fclose(fi);
@@ -198,7 +196,7 @@ int wav_write(struct WAV*wav, const char*filename)
 
 void wav_print(struct WAV*wav)
 {
-    printf("tag:%04x channels:%d samples/sec:%d bytes/sec:%d align:%d bits/sample:%d size:%d\n",
+    printf("tag:%04x channels:%d samples/sec:%lu bytes/sec:%lu align:%d bits/sample:%d size:%d\n",
            wav->tag, wav->channels, wav->sampsPerSec, wav->bytesPerSec, 
            wav->align, wav->bps, wav->size);
 }
index da3c318..9981a15 100644 (file)
@@ -632,7 +632,7 @@ int main(int argc, char **argv)
        int i;
        for (i = 0; i < global.nfiles; i++) {
            if (VERBOSE(3))
-               fprintf(stderr, "[%03i] %s (%i%%, 1/%i)\n", i,
+               fprintf(stderr, "[%03i] %s (%i%%)\n", i,
                        image[i].filename, image[i].quality);
            t = MovieAddFrame(&swf, t, image[i].filename, image[i].quality,
                              image[i].width, image[i].height);
index 8c1d6e6..91f2188 100644 (file)
@@ -197,7 +197,7 @@ int png_read_header(FILE*fi, struct png_header*header)
                exit(1);
            }
            if(a!=8 && (b==2 || b==6)) {
-               fprintf(stderr, "Bpp %d in mode %d not supported!\n", a);
+               fprintf(stderr, "Bpp %d in mode %d not supported!\n", b, a);
                exit(1);
            }
            if(c!=0) {
@@ -553,7 +553,7 @@ TAG* PNG2Image(TAG*t, U16 id, char*filename, int*width, int*height)
     }
     
     if(!zimagedata || uncompress(imagedata, &imagedatalen, zimagedata, zimagedatalen) != Z_OK) {
-       fprintf(stderr, "Couldn't uncompress IDAT chunk (%d bytes) in %s!\n", imagedatalen, filename);
+       fprintf(stderr, "Couldn't uncompress IDAT chunk (%lu bytes) in %s!\n", imagedatalen, filename);
        if(zimagedata)
            free(zimagedata);
        return 0;
@@ -1067,7 +1067,7 @@ void args_callback_usage(char *name)
     printf("-q , --quiet                   Omit normal log messages, only log errors\n");
     printf("-C , --cgi                     For use as CGI- prepend http header, write to stdout\n");
     printf("-V , --version                 Print version information and exit\n");
-    printf("-s , --scale <percent>         Scale image to <percent>% size.\n");
+    printf("-s , --scale <percent>         Scale image to <percent>%% size.\n");
     printf("\n");
 }
 
index 42db7f4..9163534 100644 (file)
@@ -2691,7 +2691,7 @@ int parseColor2(const char*str, RGBA*color)
        return 1;
     }
     int len=strlen(str);
-    U8 alpha = 255;
+    int alpha = 255;
     if(strchr(str, '/')) {
        len = strchr(str, '/')-str;
        sscanf(str+len+1,"%02x", &alpha);
index 378bf06..7daec9c 100644 (file)
@@ -316,7 +316,7 @@ void args_callback_usage(char *name)
     printf("-f , --frame                   The following identifier is a frame or framelabel, not an id or objectname\n");
     printf("-x , --movex <xpos>            x Adjust position of slave by <xpos> pixels\n");
     printf("-y , --movey <ypos>            y Adjust position of slave by <ypos> pixels\n");
-    printf("-s , --scale <scale>           Adjust size of slave by <scale> percent (e.g. 100% = original size)\n");
+    printf("-s , --scale <scale>           Adjust size of slave by <scale> percent (e.g. 100%% = original size)\n");
     printf("-r , --rate <fps>              Set movie framerate to <fps> (frames/sec)\n");
     printf("-X , --width <width>           Force movie bbox width to <width> (default: use master width (not with -t))\n");
     printf("-Y , --height <height>          Force movie bbox height to <height> (default: use master height (not with -t))\n");
index 61bdc34..0828ea4 100644 (file)
@@ -609,7 +609,7 @@ void handleVideoFrame(TAG*tag, char*prefix)
 
     deblock = swf_GetBits(tag, 1);
     if(deblock)
-       printf(" deblock ", deblock);
+       printf(" deblock %d ", deblock);
     quantizer = swf_GetBits(tag, 5);
     printf(" quant: %d ", quantizer);
 }
index ee96ad2..e385f1f 100644 (file)
@@ -701,7 +701,7 @@ void handlejpeg(TAG*tag)
     }
     else {
        int id = GET16(tag->data);
-       fprintf(stderr, "Object %d is not a JPEG picture!\n",id, jpegtables);
+       fprintf(stderr, "Object %d is not a JPEG picture!\n", id);
        exit(1);
     }
 }
index 153f8f1..72919e5 100644 (file)
@@ -113,7 +113,7 @@ int args_callback_option(char*name,char*val)
            samplerate = 44100;
        else {
            fprintf(stderr, "Invalid samplerate: %d\n", samplerate);
-           fprintf(stderr, "Allowed values: 11025, 22050, 44100\n", samplerate);
+           fprintf(stderr, "Allowed values: 11025, 22050, 44100\n");
            exit(1);
        }
        return 1;