]> git.imager.perl.org - imager.git/commitdiff
mark mm_log() for the API with the right gcc -Wformat magic
authorTony Cook <tony@develop-help.com>
Thu, 21 Feb 2013 03:31:18 +0000 (14:31 +1100)
committerTony Cook <tony@develop-help.com>
Thu, 21 Feb 2013 03:31:18 +0000 (14:31 +1100)
and fix the format strings vs arguments errors revealed

FT2/freetyp2.c
JPEG/imexif.c
JPEG/imjpeg.c
PNG/impng.c
SGI/imsgi.c
T1/imt1.c
TIFF/imtiff.c
imexttypes.h

index 6431ad2bbb1dd786d561d147c9d1f297712ed395..e175ed4ef4be8f7437fb0ef72889c4d121eafc8c 100644 (file)
@@ -239,8 +239,8 @@ i_ft2_new(const char *name, int index) {
   score = 0;
   for (i = 0; i < face->num_charmaps; ++i) {
     FT_Encoding enc_entry = face->charmaps[i]->encoding;
-    mm_log((2, "i_ft2_new, encoding %lX platform %u encoding %u\n",
-            enc_entry, face->charmaps[i]->platform_id,
+    mm_log((2, "i_ft2_new, encoding %X platform %u encoding %u\n",
+            (unsigned)enc_entry, face->charmaps[i]->platform_id,
             face->charmaps[i]->encoding_id));
     for (j = 0; j < sizeof(enc_scores) / sizeof(*enc_scores); ++j) {
       if (enc_scores[j].encoding == enc_entry && enc_scores[j].score > score) {
@@ -251,7 +251,7 @@ i_ft2_new(const char *name, int index) {
     }
   }
   FT_Select_Charmap(face, encoding);
-  mm_log((2, "i_ft2_new, selected encoding %lX\n", encoding));
+  mm_log((2, "i_ft2_new, selected encoding %X\n", (unsigned)encoding));
 
   result = mymalloc(sizeof(FT2_Fonthandle));
   result->face = face;
@@ -424,8 +424,8 @@ i_ft2_bbox(FT2_Fonthandle *handle, double cheight, double cwidth,
   int loadFlags = FT_LOAD_DEFAULT;
   int rightb = 0;
 
-  mm_log((1, "i_ft2_bbox(handle %p, cheight %f, cwidth %f, text %p, len %d, bbox %p)\n",
-         handle, cheight, cwidth, text, len, bbox));
+  mm_log((1, "i_ft2_bbox(handle %p, cheight %f, cwidth %f, text %p, len %u, bbox %p)\n",
+         handle, cheight, cwidth, text, (unsigned)len, bbox));
 
   error = FT_Set_Char_Size(handle->face, cwidth*64, cheight*64, 
                            handle->xdpi, handle->ydpi);
@@ -457,7 +457,7 @@ i_ft2_bbox(FT2_Fonthandle *handle, double cheight, double cwidth,
     error = FT_Load_Glyph(handle->face, index, loadFlags);
     if (error) {
       ft2_push_message(error);
-      i_push_errorf(0, "loading glyph for character \\x%02x (glyph 0x%04X)", 
+      i_push_errorf(0, "loading glyph for character \\x%02lx (glyph 0x%04X)", 
                     c, index);
       return 0;
     }
@@ -499,7 +499,11 @@ i_ft2_bbox(FT2_Fonthandle *handle, double cheight, double cwidth,
   bbox[BBOX_ASCENT] = ascent;
   bbox[BBOX_ADVANCE_WIDTH] = width;
   bbox[BBOX_RIGHT_BEARING] = rightb;
-  mm_log((1, " bbox=> negw=%d glob_desc=%d pos_wid=%d glob_asc=%d desc=%d asc=%d adv_width=%d rightb=%d\n", bbox[0], bbox[1], bbox[2], bbox[3], bbox[4], bbox[5], bbox[6], bbox[7]));
+  mm_log((1, " bbox=> negw=%" i_DF " glob_desc=%" i_DF " pos_wid=%" i_DF
+         " glob_asc=%" i_DF " desc=%" i_DF " asc=%" i_DF " adv_width=%" i_DF
+         " rightb=%" i_DF "\n",
+         bbox[0], bbox[1], bbox[2], bbox[3], bbox[4], bbox[5], bbox[6],
+         bbox[7]));
 
   return BBOX_RIGHT_BEARING + 1;
 }
@@ -625,7 +629,7 @@ i_ft2_bbox_r(FT2_Fonthandle *handle, double cheight, double cwidth,
     error = FT_Load_Glyph(handle->face, index, loadFlags);
     if (error) {
       ft2_push_message(error);
-      i_push_errorf(0, "loading glyph for character \\x%02x (glyph 0x%04X)", 
+      i_push_errorf(0, "loading glyph for character \\x%02lx (glyph 0x%04X)",
                     c, index);
       return 0;
     }
@@ -740,8 +744,8 @@ i_ft2_text(FT2_Fonthandle *handle, i_img *im, i_img_dim tx, i_img_dim ty, const
   int loadFlags = FT_LOAD_DEFAULT;
   i_render *render;
 
-  mm_log((1, "i_ft2_text(handle %p, im %p, tx %d, ty %d, cl %p, cheight %f, cwidth %f, text %p, len %d, align %d, aa %d)\n",
-         handle, im, tx, ty, cl, cheight, cwidth, text, align, aa));
+  mm_log((1, "i_ft2_text(handle %p, im %p, (tx,ty) (" i_DFp "), cl %p, cheight %f, cwidth %f, text %p, len %u, align %d, aa %d, vlayout %d, utf8 %d)\n",
+         handle, im, i_DFcp(tx, ty), cl, cheight, cwidth, text, (unsigned)len, align, aa, vlayout, utf8));
 
   if (vlayout) {
     if (!FT_HAS_VERTICAL(handle->face)) {
@@ -783,7 +787,7 @@ i_ft2_text(FT2_Fonthandle *handle, i_img *im, i_img_dim tx, i_img_dim ty, const
     error = FT_Load_Glyph(handle->face, index, loadFlags);
     if (error) {
       ft2_push_message(error);
-      i_push_errorf(0, "loading glyph for character \\x%02x (glyph 0x%04X)", 
+      i_push_errorf(0, "loading glyph for character \\x%02lx (glyph 0x%04X)",
                     c, index);
       if (aa)
         i_render_delete(render);
@@ -796,7 +800,7 @@ i_ft2_text(FT2_Fonthandle *handle, i_img *im, i_img_dim tx, i_img_dim ty, const
       error = FT_Render_Glyph(slot, aa ? ft_render_mode_normal : ft_render_mode_mono);
       if (error) {
        ft2_push_message(error);
-       i_push_errorf(0, "rendering glyph 0x%04X (character \\x%02X)");
+       i_push_errorf(0, "rendering glyph 0x%04lX (character \\x%02X)", c, index);
       if (aa)
         i_render_delete(render);
        return 0;
@@ -855,7 +859,7 @@ i_ft2_text(FT2_Fonthandle *handle, i_img *im, i_img_dim tx, i_img_dim ty, const
 }
 
 /*
-=item i_ft2_cp(FT2_Fonthandle *handle, i_img *im, int tx, int ty, int channel, double cheight, double cwidth, char *text, size_t len, int align, int aa)
+=item i_ft2_cp(FT2_Fonthandle *handle, i_img *im, int tx, int ty, int channel, double cheight, double cwidth, char *text, size_t len, int align, int aa, int vlayout, int utf8)
 
 Renders I<text> to (I<tx>, I<ty>) in I<im> to I<channel> at the given 
 I<cheight> and I<cwidth>.
@@ -865,7 +869,9 @@ first character at (I<tx>, I<ty>).  If align is non-zero then the text
 is rendered with (I<tx>, I<ty>) aligned with the base-line of the
 characters.
 
-If aa is non-zero then the text is anti-aliased.
+If C<utf8> is non-zero the text is treated as UTF-8 encoded
+
+If C<aa> is non-zero then the text is drawn anti-aliased.
 
 Returns non-zero on success.
 
@@ -881,8 +887,8 @@ i_ft2_cp(FT2_Fonthandle *handle, i_img *im, i_img_dim tx, i_img_dim ty, int chan
   i_color cl, cl2;
   int x, y;
 
-  mm_log((1, "i_ft2_cp(handle %p, im %p, tx %d, ty %d, channel %d, cheight %f, cwidth %f, text %p, len %d, ...)\n", 
-         handle, im, tx, ty, channel, cheight, cwidth, text, len));
+  mm_log((1, "i_ft2_cp(handle %p, im %p, (tx, ty) (" i_DFp "), channel %d, cheight %f, cwidth %f, text %p, len %u, align %d, aa %d, vlayout %d, utf8 %d)\n", 
+         handle, im, i_DFcp(tx, ty), channel, cheight, cwidth, text, (unsigned)len, align, aa, vlayout, utf8));
 
   if (vlayout && !FT_HAS_VERTICAL(handle->face)) {
     i_push_error(0, "face has no vertical metrics");
@@ -930,8 +936,8 @@ size_t
 i_ft2_has_chars(FT2_Fonthandle *handle, char const *text, size_t len, 
                     int utf8, char *out) {
   int count = 0;
-  mm_log((1, "i_ft2_has_chars(handle %p, text %p, len %d, utf8 %d)\n", 
-         handle, text, len, utf8));
+  mm_log((1, "i_ft2_has_chars(handle %p, text %p, len %u, utf8 %d)\n", 
+         handle, text, (unsigned)len, utf8));
 
   while (len) {
     unsigned long c;
index ab7af075a6214b05ca7a0771e97a5beb62340738..4aa903189cc5978fb8801d71cb8df297f2dffdeb 100644 (file)
@@ -920,7 +920,7 @@ tiff_load_ifd(imtiff *tiff, unsigned long offset) {
 
   /* rough check count + 1 entry + next offset */
   if (offset + (2+12+4) > tiff->size) {
-    mm_log((2, "offset %uld beyond end off Exif block"));
+    mm_log((2, "offset %lu beyond end off Exif block", offset));
     return 0;
   }
 
@@ -929,7 +929,7 @@ tiff_load_ifd(imtiff *tiff, unsigned long offset) {
   /* check we can fit the whole thing */
   ifd_size = 2 + count * 12 + 4; /* count + count entries + next offset */
   if (offset + ifd_size > tiff->size) {
-    mm_log((2, "offset %uld beyond end off Exif block"));
+    mm_log((2, "offset %lu beyond end off Exif block", offset));
     return 0;
   }
 
@@ -1420,7 +1420,8 @@ Retrieve a 16 bit unsigned integer from offset.
 static unsigned
 tiff_get16(imtiff *tiff, unsigned long offset) {
   if (offset + 2 > tiff->size) {
-    mm_log((3, "attempt to get16 at %uld in %uld image", offset, tiff->size));
+    mm_log((3, "attempt to get16 at %lu in %lu image", offset,
+           (unsigned long)tiff->size));
     return 0;
   }
 
@@ -1441,7 +1442,8 @@ Retrieve a 32-bit unsigned integer from offset.
 static unsigned
 tiff_get32(imtiff *tiff, unsigned long offset) {
   if (offset + 4 > tiff->size) {
-    mm_log((3, "attempt to get16 at %uld in %uld image", offset, tiff->size));
+    mm_log((3, "attempt to get16 at %lu in %lu image", offset,
+           (unsigned long)tiff->size));
     return 0;
   }
 
@@ -1492,7 +1494,7 @@ tiff_get16s(imtiff *tiff, unsigned long offset) {
   int result;
 
   if (offset + 2 > tiff->size) {
-    mm_log((3, "attempt to get16 at %uld in %uld image", offset, tiff->size));
+    mm_log((3, "attempt to get16 at %lu in %lu image", offset, tiff->size));
     return 0;
   }
 
@@ -1520,7 +1522,7 @@ tiff_get32s(imtiff *tiff, unsigned long offset) {
   unsigned work;
 
   if (offset + 4 > tiff->size) {
-    mm_log((3, "attempt to get16 at %uld in %uld image", offset, tiff->size));
+    mm_log((3, "attempt to get16 at %lu in %lu image", offset, tiff->size));
     return 0;
   }
 
index c317e0af639738bf69ff1ca8246bcfde39b5d801..b1c97d208a788a4ae77c047a4ecdf6e14bb875cc 100644 (file)
@@ -218,7 +218,7 @@ wiol_empty_output_buffer(j_compress_ptr cinfo) {
 
   if (rc != JPGS) { /* XXX: Should raise some jpeg error */
     myfree(dest->buffer);
-    mm_log((1, "wiol_empty_output_buffer: Error: nbytes = %d != rc = %d\n", JPGS, rc));
+    mm_log((1, "wiol_empty_output_buffer: Error: nbytes = %d != rc = %d\n", JPGS, (int)rc));
     ERREXIT(cinfo, JERR_FILE_WRITE);
   }
   dest->pub.free_in_buffer = JPGS;
@@ -547,7 +547,7 @@ i_readjpeg_wiol(io_glue *data, int length, char** iptc_itext, int *itlength) {
 
   i_tags_set(&im->tags, "i_format", "jpeg", 4);
 
-  mm_log((1,"i_readjpeg_wiol -> (0x%x)\n",im));
+  mm_log((1,"i_readjpeg_wiol -> (%p)\n",im));
   return im;
 }
 
index 477a49199ae6400de42823b4907e66545eeb8fbe..1ede7f827a96ce97ce7fbb285b0a05f0d9a1db84 100644 (file)
@@ -316,9 +316,8 @@ i_readpng_wiol(io_glue *ig) {
   png_read_info(png_ptr, info_ptr);
   png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, NULL, NULL);
   
-  mm_log((1,
-         "png_get_IHDR results: width %d, height %d, bit_depth %d, color_type %d, interlace_type %d\n",
-         width,height,bit_depth,color_type,interlace_type));
+  mm_log((1, "png_get_IHDR results: width %u, height %u, bit_depth %d, color_type %d, interlace_type %d\n",
+         (unsigned)width, (unsigned)height, bit_depth,color_type,interlace_type));
   
   CC2C[PNG_COLOR_TYPE_GRAY]=1;
   CC2C[PNG_COLOR_TYPE_PALETTE]=3;
@@ -687,7 +686,7 @@ get_png_tags(i_img *im, png_structp png_ptr, png_infop info_ptr,
 
   i_tags_set(&im->tags, "i_format", "png", -1);
   if (png_get_pHYs(png_ptr, info_ptr, &xres, &yres, &unit_type)) {
-    mm_log((1,"pHYs (%d, %d) %d\n", xres, yres, unit_type));
+    mm_log((1,"pHYs (%u, %u) %d\n", (unsigned)xres, (unsigned)yres, unit_type));
     if (unit_type == PNG_RESOLUTION_METER) {
       i_tags_set_float2(&im->tags, "i_xres", 0, xres * 0.0254, 5);
       i_tags_set_float2(&im->tags, "i_yres", 0, yres * 0.0254, 5);
index 077388aad45a3545ab8d1cb8ec861902ea3cac86..3b61d8267e19e1f3434e8ef98a149b90b2c5f6fe 100644 (file)
@@ -461,7 +461,7 @@ read_rle_tables(io_glue *ig, i_img *img,
 
   mm_log((3, "Offset/length table:\n"));
   for(i=0; i < height * channels; i++)
-    mm_log((3, "%d: %d/%d\n", i, start_tab[i], length_tab[i]));
+    mm_log((3, "%d: %lu/%lu\n", i, start_tab[i], length_tab[i]));
 
   *pstart_tab = start_tab;
   *plength_tab = length_tab;
@@ -500,7 +500,7 @@ read_rgb_8_rle(i_img *img, io_glue *ig, rgb_header const *header) {
     return NULL;
   }
 
-  mm_log((1, "maxlen for an rle buffer: %d\n", max_length));
+  mm_log((1, "maxlen for an rle buffer: %lu\n", max_length));
 
   if (max_length > (img->xsize + 1) * 2) {
     i_push_errorf(0, "SGI image: ridiculous RLE line length %lu", max_length);
@@ -576,7 +576,7 @@ read_rgb_8_rle(i_img *img, io_glue *ig, rgb_header const *header) {
          /* RLE run */
          if (count > pixels_left) {
            i_push_error(0, "SGI image: RLE run overflows scanline");
-           mm_log((2, "RLE run overflows scanline (y %d chan %d offset %ld len %ld)\n", y, c, start_tab[ci], length_tab[ci]));
+           mm_log((2, "RLE run overflows scanline (y %" i_DF " chan %d offset %lu len %lu)\n", i_DFc(y), c, start_tab[ci], length_tab[ci]));
            goto ErrorReturn;
          }
          if (data_left < 1) {
index d0686bbdd47c896e0d4174e346a1c9fadd431bd3..a883503c4072c1182348cb039d2201eef1731c7c 100644 (file)
--- a/T1/imt1.c
+++ b/T1/imt1.c
@@ -302,7 +302,7 @@ i_t1_cp(i_t1_font_t font, i_img *im,i_img_dim xb,i_img_dim yb,int channel,double
   mm_log((1,"metrics: ascent: %d descent: %d\n",glyph->metrics.ascent,glyph->metrics.descent));
   mm_log((1," leftSideBearing: %d rightSideBearing: %d\n",glyph->metrics.leftSideBearing,glyph->metrics.rightSideBearing));
   mm_log((1," advanceX: %d  advanceY: %d\n",glyph->metrics.advanceX,glyph->metrics.advanceY));
-  mm_log((1,"bpp: %d\n",glyph->bpp));
+  mm_log((1,"bpp: %lu\n", (unsigned long)glyph->bpp));
   
   xsize=glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing;
   ysize=glyph->metrics.ascent-glyph->metrics.descent;
@@ -366,7 +366,8 @@ i_t1_bbox(i_t1_font_t font, double points,const char *str,size_t len, i_img_dim
 
   space_position = T1_GetEncodingIndex(fontnum, "space");
   
-  mm_log((1,"i_t1_bbox(font %p (%d),points %.2f,str '%.*s', len %d)\n",font, fontnum,points,len,str,len));
+  mm_log((1,"i_t1_bbox(font %p (%d),points %.2f,str '%.*s', len %u)\n",
+         font, fontnum,points,(int)len,str,(unsigned)len));
   T1_LoadFont(fontnum);  /* FIXME: Here a return code is ignored - haw haw haw */ 
 
   if (len == 0) {
@@ -392,7 +393,7 @@ i_t1_bbox(i_t1_font_t font, double points,const char *str,size_t len, i_img_dim
   }
   gbbox = T1_GetFontBBox(fontnum);
   
-  mm_log((1,"bbox: (%d,%d,%d,%d)\n",
+  mm_log((1,"bbox: (%d, %d, %d, %d, %d, %d)\n",
          (int)(bbox.llx*points/1000),
          (int)(gbbox.lly*points/1000),
          (int)(bbox.urx*points/1000),
@@ -483,7 +484,7 @@ i_t1_text(i_t1_font_t font, i_img *im, i_img_dim xb, i_img_dim yb,const i_color
   mm_log((1,"metrics:  ascent: %d descent: %d\n",glyph->metrics.ascent,glyph->metrics.descent));
   mm_log((1," leftSideBearing: %d rightSideBearing: %d\n",glyph->metrics.leftSideBearing,glyph->metrics.rightSideBearing));
   mm_log((1," advanceX: %d advanceY: %d\n",glyph->metrics.advanceX,glyph->metrics.advanceY));
-  mm_log((1,"bpp: %d\n",glyph->bpp));
+  mm_log((1,"bpp: %lu\n",(unsigned long)glyph->bpp));
   
   xsize=glyph->metrics.rightSideBearing-glyph->metrics.leftSideBearing;
   ysize=glyph->metrics.ascent-glyph->metrics.descent;
@@ -590,8 +591,8 @@ i_t1_has_chars(i_t1_font_t font, const char *text, size_t len, int utf8,
   
   i_mutex_lock(mutex);
 
-  mm_log((1, "i_t1_has_chars(font_num %d, text %p, len %d, utf8 %d)\n", 
-          font_num, text, len, utf8));
+  mm_log((1, "i_t1_has_chars(font_num %d, text %p, len %u, utf8 %d)\n", 
+          font_num, text, (unsigned)len, utf8));
 
   i_clear_error();
   if (T1_LoadFont(font_num)) {
index d94f686793a95683b18480a9ebe9fd2dde42a677..c848fdaab3a8ca4a93f96f19e3715b5a71da4050 100644 (file)
@@ -739,7 +739,7 @@ i_readtiff_multi_wiol(io_glue *ig, int *count) {
   /* Add code to get the filename info from the iolayer */
   /* Also add code to check for mmapped code */
 
-  mm_log((1, "i_readtiff_wiol(ig %p, length %d)\n", ig));
+  mm_log((1, "i_readtiff_wiol(ig %p)\n", ig));
   
   tif = TIFFClientOpen("(Iolayer)", 
                       "rm", 
@@ -2725,7 +2725,8 @@ putter_cmyk16(read_state_t *state, i_img_dim x, i_img_dim y, i_img_dim width, i_
   uint16 *p = state->raster;
   int out_chan = state->img->channels;
 
-  mm_log((4, "putter_cmyk16(%p, %d, %d, %d, %d, %d)\n", x, y, width, height, row_extras));
+  mm_log((4, "putter_cmyk16(%p, %" i_DF ", %" i_DF ", %" i_DF
+         ", %" i_DF ", %d)\n", state, x, y, width, height, row_extras));
 
   state->pixels_read += width * height;
   while (height > 0) {
index ae3bc002cc32cc84be915b9499cedd9a5384bd37..b2db7fec92cb6efce077b82dcdc2824237d9a6a3 100644 (file)
@@ -104,7 +104,7 @@ typedef struct {
 
   void (*f_i_clear_error)(void); /* SKIP */
   void (*f_i_push_error)(int code, char const *msg); /* SKIP */
-  void (*f_i_push_errorf)(int code, char const *fmt, ...);
+  void (*f_i_push_errorf)(int code, char const *fmt, ...) I_FORMAT_ATTR(2,3);
   void (*f_i_push_errorvf)(int code, char const *fmt, va_list); /* SKIP */
   
   void (*f_i_tags_new)(i_img_tags *tags);
@@ -165,7 +165,7 @@ typedef struct {
   i_img_dim (*f_i_img_get_width)(i_img *im);
   i_img_dim (*f_i_img_get_height)(i_img *im);
   void (*f_i_lhead)(const char *file, int line_number);
-  void (*f_i_loog)(int level, const char *msg, ...);
+  void (*f_i_loog)(int level, const char *msg, ...) I_FORMAT_ATTR(2,3);
 
   /* IMAGER_API_LEVEL 4 functions will be added here */
   i_img *(*f_i_img_alloc)(void); /* SKIP */
@@ -226,7 +226,7 @@ typedef struct {
   void (*f_im_clear_error)(im_context_t ctx);
   void (*f_im_push_error)(im_context_t ctx, int code, char const *msg);
   void (*f_im_push_errorvf)(im_context_t ctx, int code, char const *fmt, va_list);
-  void (*f_im_push_errorf)(im_context_t , int code, char const *fmt, ...);
+  void (*f_im_push_errorf)(im_context_t , int code, char const *fmt, ...) I_FORMAT_ATTR(3,4);
 
   int (*f_im_set_image_file_limits)(im_context_t ctx, i_img_dim width, i_img_dim height, size_t bytes);
   int (*f_im_get_image_file_limits)(im_context_t ctx, i_img_dim *width, i_img_dim *height, size_t *bytes);