From d7afc8c14f379f1e7dcf91d9c57cb9b2d1f2d926 Mon Sep 17 00:00:00 2001 From: Roger Leigh Date: Tue, 2 Feb 2021 22:00:42 +0000 Subject: Use TIFF_SSIZE_FORMAT for formatting tmsize_t --- tools/tiff2pdf.c | 31 +++++++++++++++---------------- tools/tiff2ps.c | 14 +++++++------- tools/tiff2rgba.c | 4 ++-- tools/tiffcp.c | 4 ++-- tools/tiffcrop.c | 2 +- 5 files changed, 27 insertions(+), 28 deletions(-) (limited to 'tools') diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c index 2f3317e2..4cdf0f90 100644 --- a/tools/tiff2pdf.c +++ b/tools/tiff2pdf.c @@ -24,9 +24,6 @@ * OF THIS SOFTWARE. */ -#include "tif_config.h" -#include "libport.h" - #include #include #include @@ -49,6 +46,8 @@ #include "tiffiop.h" #include "tiffio.h" +#include "tif_config.h" +#include "libport.h" #ifndef EXIT_SUCCESS # define EXIT_SUCCESS 0 @@ -2262,7 +2261,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ _TIFFmalloc(t2p->tiff_datasize); if (buffer == NULL) { TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for " "t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); @@ -2531,7 +2530,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2569,7 +2568,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2579,7 +2578,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ samplebuffer = (unsigned char*) _TIFFmalloc(stripsize); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2619,7 +2618,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2654,7 +2653,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ t2p->tiff_datasize * t2p->tiff_samplesperpixel); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2685,7 +2684,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){ t2p->tiff_width*t2p->tiff_length*4); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s", + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for t2p_readwrite_pdf_image, %s", t2p->tiff_datasize, TIFFFileName(input)); t2p->t2p_error = T2P_ERR_ERROR; @@ -2882,7 +2881,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer= (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", t2p->tiff_datasize, TIFFFileName(input)); @@ -3044,7 +3043,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory for " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory for " "t2p_readwrite_pdf_image_tile, %s", t2p->tiff_datasize, TIFFFileName(input)); @@ -3078,7 +3077,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", t2p->tiff_datasize, TIFFFileName(input)); @@ -3089,7 +3088,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ samplebuffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(samplebuffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", t2p->tiff_datasize, TIFFFileName(input)); @@ -3130,7 +3129,7 @@ tsize_t t2p_readwrite_pdf_image_tile(T2P* t2p, TIFF* input, TIFF* output, ttile_ buffer = (unsigned char*) _TIFFmalloc(t2p->tiff_datasize); if(buffer==NULL){ TIFFError(TIFF2PDF_MODULE, - "Can't allocate %"PRId64" bytes of memory " + "Can't allocate %"TIFF_SSIZE_FORMAT" bytes of memory " "for t2p_readwrite_pdf_image_tile, %s", t2p->tiff_datasize, TIFFFileName(input)); @@ -4206,7 +4205,7 @@ tsize_t t2p_write_pdf_stream_length(tsize_t len, TIFF* output){ char buffer[32]; int buflen=0; - buflen=snprintf(buffer, sizeof(buffer), "%"PRId64, len); + buflen=snprintf(buffer, sizeof(buffer), "%"TIFF_SSIZE_FORMAT, len); check_snprintf_ret((T2P*)NULL, buflen, buffer); written += t2pWriteFile(output, (tdata_t) buffer, buflen); written += t2pWriteFile(output, (tdata_t) "\n", 1); diff --git a/tools/tiff2ps.c b/tools/tiff2ps.c index 9a093d25..cc5ef955 100644 --- a/tools/tiff2ps.c +++ b/tools/tiff2ps.c @@ -247,7 +247,7 @@ static void usage(int); static void* limitMalloc(tmsize_t s) { if (maxMalloc && (s > maxMalloc)) { - fprintf(stderr, "MemoryLimitError: allocation of %" PRId64 " bytes is forbidden. Limit is %" PRId64 ".\n", + fprintf(stderr, "MemoryLimitError: allocation of %" TIFF_SSIZE_FORMAT " bytes is forbidden. Limit is %" TIFF_SSIZE_FORMAT ".\n", s, maxMalloc); fprintf(stderr, " use -M option to change limit.\n"); return NULL; @@ -2212,7 +2212,7 @@ PS_Lvl2page(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) } buf_data = (unsigned char *)limitMalloc(chunk_size); if (!buf_data) { - TIFFError(filename, "Can't alloc %"PRId64" bytes for %s.", + TIFFError(filename, "Can't alloc %"TIFF_SSIZE_FORMAT" bytes for %s.", chunk_size, tiled_image ? "tiles" : "strips"); return(FALSE); } @@ -2390,8 +2390,8 @@ PSpage(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) case PHOTOMETRIC_PALETTE: fprintf(fd, "%s", RGBcolorimage); PhotoshopBanner(fd, w, h, 1, 3, "false 3 colorimage"); - fprintf(fd, "/scanLine %"PRId64" string def\n", - ps_bytesperrow * 3L); + fprintf(fd, "/scanLine %"TIFF_SSIZE_FORMAT" string def\n", + ps_bytesperrow * 3); fprintf(fd, "%"PRIu32" %"PRIu32" 8\n", w, h); fprintf(fd, "[%"PRIu32" 0 0 -%"PRIu32" 0 %"PRIu32"]\n", @@ -2403,7 +2403,7 @@ PSpage(FILE* fd, TIFF* tif, uint32_t w, uint32_t h) case PHOTOMETRIC_MINISBLACK: case PHOTOMETRIC_MINISWHITE: PhotoshopBanner(fd, w, h, 1, 1, imageOp); - fprintf(fd, "/scanLine %"PRId64" string def\n", + fprintf(fd, "/scanLine %"TIFF_SSIZE_FORMAT" string def\n", ps_bytesperrow); fprintf(fd, "%"PRIu32" %"PRIu32" %"PRIu16"\n", w, h, bitspersample); @@ -2423,7 +2423,7 @@ PSColorContigPreamble(FILE* fd, uint32_t w, uint32_t h, int nc) { ps_bytesperrow = nc * (tf_bytesperrow / samplesperpixel); PhotoshopBanner(fd, w, h, 1, nc, "false %d colorimage"); - fprintf(fd, "/line %"PRId64" string def\n", ps_bytesperrow); + fprintf(fd, "/line %"TIFF_SSIZE_FORMAT" string def\n", ps_bytesperrow); fprintf(fd, "%"PRIu32" %"PRIu32" %"PRIu16"\n", w, h, bitspersample); fprintf(fd, "[%"PRIu32" 0 0 -%"PRIu32" 0 %"PRIu32"]\n", @@ -2439,7 +2439,7 @@ PSColorSeparatePreamble(FILE* fd, uint32_t w, uint32_t h, int nc) PhotoshopBanner(fd, w, h, ps_bytesperrow, nc, "true %d colorimage"); for (i = 0; i < nc; i++) - fprintf(fd, "/line%d %"PRId64" string def\n", + fprintf(fd, "/line%d %"TIFF_SSIZE_FORMAT" string def\n", i, ps_bytesperrow); fprintf(fd, "%"PRIu32" %"PRIu32" %"PRIu16"\n", w, h, bitspersample); diff --git a/tools/tiff2rgba.c b/tools/tiff2rgba.c index e6202d69..e0dbcc45 100644 --- a/tools/tiff2rgba.c +++ b/tools/tiff2rgba.c @@ -411,7 +411,7 @@ cvt_whole_image( TIFF *in, TIFF *out ) } if (maxMalloc != 0 && (tmsize_t)pixel_count * (tmsize_t)sizeof(uint32_t) > maxMalloc) { TIFFError(TIFFFileName(in), - "Raster size %zu over memory limit (%" PRId64 "), try -b option.", + "Raster size %zu over memory limit (%" TIFF_SSIZE_FORMAT "), try -b option.", pixel_count * sizeof(uint32_t), maxMalloc); return 0; } @@ -543,7 +543,7 @@ tiffcvt(TIFF* in, TIFF* out) if (maxMalloc != 0 && TIFFStripSize(in) > maxMalloc) { TIFFError(TIFFFileName(in), - "Strip Size %" PRId64 " over memory limit (%" PRId64 ")", + "Strip Size %" TIFF_SSIZE_FORMAT " over memory limit (%" TIFF_SSIZE_FORMAT ")", TIFFStripSize(in), maxMalloc); return 0; } diff --git a/tools/tiffcp.c b/tools/tiffcp.c index f6b44813..e29ed333 100644 --- a/tools/tiffcp.c +++ b/tools/tiffcp.c @@ -107,7 +107,7 @@ static int pageInSeq = 0; static void* limitMalloc(tmsize_t s) { if (maxMalloc && (s > maxMalloc)) { - fprintf(stderr, "MemoryLimitError: allocation of %" PRId64 " bytes is forbidden. Limit is %" PRId64 ".\n", + fprintf(stderr, "MemoryLimitError: allocation of %" TIFF_SSIZE_FORMAT " bytes is forbidden. Limit is %" TIFF_SSIZE_FORMAT ".\n", s, maxMalloc); fprintf(stderr, " use -m option to change limit.\n"); return NULL; @@ -1099,7 +1099,7 @@ DECLAREcpFunc(cpDecodedStrips) return 1; } else { TIFFError(TIFFFileName(in), - "Error, can't allocate memory buffer of size %"PRId64 + "Error, can't allocate memory buffer of size %"TIFF_SSIZE_FORMAT " to read strips", stripsize); return 0; } diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c index 7751e866..06a2c148 100644 --- a/tools/tiffcrop.c +++ b/tools/tiffcrop.c @@ -865,7 +865,7 @@ static int readContigTilesIntoBuffer (TIFF* in, uint8_t* buf, if (tbytes < tilesize && !ignore) { TIFFError(TIFFFileName(in), - "Error, can't read tile at row %"PRIu32" col %"PRIu32", Read %"PRId64" bytes of %"PRId64, + "Error, can't read tile at row %"PRIu32" col %"PRIu32", Read %"TIFF_SSIZE_FORMAT" bytes of %"TIFF_SSIZE_FORMAT, col, row, tbytes, tilesize); status = 0; _TIFFfree(tilebuf); -- cgit v1.2.1