summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@codelibre.net>2021-01-17 17:48:43 +0000
committerRoger Leigh <rleigh@codelibre.net>2021-01-28 08:26:50 +0000
commit352cb5a4fb110a01c694616f62b0d5c388a14c16 (patch)
treee7f2416375b28e0f1f9a20170ffed7433a81058c
parente6ce256e8e5ff69498d9cacc456288e6db6ca24b (diff)
downloadlibtiff-git-352cb5a4fb110a01c694616f62b0d5c388a14c16.tar.gz
libtiff: Use PRI format flags and remove unnecessary casts
-rw-r--r--libtiff/tif_aux.c4
-rw-r--r--libtiff/tif_codec.c2
-rw-r--r--libtiff/tif_compress.c4
-rw-r--r--libtiff/tif_dir.c18
-rw-r--r--libtiff/tif_dirread.c35
-rw-r--r--libtiff/tif_dirwrite.c36
-rw-r--r--libtiff/tif_dumpmode.c16
-rw-r--r--libtiff/tif_fax3.c36
-rw-r--r--libtiff/tif_getimage.c30
-rw-r--r--libtiff/tif_jbig.c8
-rw-r--r--libtiff/tif_jpeg.c54
-rw-r--r--libtiff/tif_luv.c45
-rw-r--r--libtiff/tif_lzma.c12
-rw-r--r--libtiff/tif_lzw.c40
-rw-r--r--libtiff/tif_next.c10
-rw-r--r--libtiff/tif_ojpeg.c22
-rw-r--r--libtiff/tif_open.c10
-rw-r--r--libtiff/tif_packbits.c12
-rw-r--r--libtiff/tif_pixarlog.c24
-rw-r--r--libtiff/tif_predict.c6
-rw-r--r--libtiff/tif_print.c163
-rw-r--r--libtiff/tif_read.c283
-rw-r--r--tools/tiff2pdf.c2
-rw-r--r--tools/tiffinfo.c2
24 files changed, 345 insertions, 529 deletions
diff --git a/libtiff/tif_aux.c b/libtiff/tif_aux.c
index 96f1f55a..3910e61c 100644
--- a/libtiff/tif_aux.c
+++ b/libtiff/tif_aux.c
@@ -109,8 +109,8 @@ _TIFFCheckRealloc(TIFF* tif, void* buffer,
if (cp == NULL) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Failed to allocate memory for %s "
- "(%ld elements of %ld bytes each)",
- what,(long) nmemb, (long) elem_size);
+ "(%"PRId64" elements of %"PRId64" bytes each)",
+ what, nmemb, elem_size);
}
return cp;
diff --git a/libtiff/tif_codec.c b/libtiff/tif_codec.c
index 03fe7930..00963a5b 100644
--- a/libtiff/tif_codec.c
+++ b/libtiff/tif_codec.c
@@ -110,7 +110,7 @@ _notConfigured(TIFF* tif)
const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression);
char compression_code[20];
- sprintf(compression_code, "%d",tif->tif_dir.td_compression );
+ sprintf(compression_code, "%"PRIu16, tif->tif_dir.td_compression );
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"%s compression support is not configured",
c ? c->name : compression_code );
diff --git a/libtiff/tif_compress.c b/libtiff/tif_compress.c
index 19a1ff1c..8fcedf45 100644
--- a/libtiff/tif_compress.c
+++ b/libtiff/tif_compress.c
@@ -40,7 +40,7 @@ TIFFNoEncode(TIFF* tif, const char* method)
c->name, method);
} else {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
- "Compression scheme %u %s encoding is not implemented",
+ "Compression scheme %"PRIu16" %s encoding is not implemented",
tif->tif_dir.td_compression, method);
}
return (-1);
@@ -78,7 +78,7 @@ TIFFNoDecode(TIFF* tif, const char* method)
c->name, method);
else
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
- "Compression scheme %u %s decoding is not implemented",
+ "Compression scheme %"PRIu16" %s decoding is not implemented",
tif->tif_dir.td_compression, method);
return (0);
}
diff --git a/libtiff/tif_dir.c b/libtiff/tif_dir.c
index 7ce39d04..a6c254fc 100644
--- a/libtiff/tif_dir.c
+++ b/libtiff/tif_dir.c
@@ -160,10 +160,10 @@ checkInkNamesString(TIFF* tif, uint32_t slen, const char* s)
}
bad:
TIFFErrorExt(tif->tif_clientdata, "TIFFSetField",
- "%s: Invalid InkNames value; expecting %d names, found %d",
+ "%s: Invalid InkNames value; expecting %"PRIu16" names, found %"PRIu16,
tif->tif_name,
td->td_samplesperpixel,
- td->td_samplesperpixel-i);
+ (uint16_t)(td->td_samplesperpixel-i));
return (0);
}
@@ -394,7 +394,7 @@ _TIFFVSetField(TIFF* tif, uint32_t tag, va_list ap)
if (tif->tif_mode != O_RDONLY)
goto badvalue32;
TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
- "Nonstandard tile width %u, convert file", v32);
+ "Nonstandard tile width %"PRIu32", convert file", v32);
}
td->td_tilewidth = v32;
tif->tif_flags |= TIFF_ISTILED;
@@ -405,7 +405,7 @@ _TIFFVSetField(TIFF* tif, uint32_t tag, va_list ap)
if (tif->tif_mode != O_RDONLY)
goto badvalue32;
TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
- "Nonstandard tile length %u, convert file", v32);
+ "Nonstandard tile length %"PRIu32", convert file", v32);
}
td->td_tilelength = v32;
tif->tif_flags |= TIFF_ISTILED;
@@ -755,7 +755,7 @@ badvalue:
{
const TIFFField* fip2=TIFFFieldWithTag(tif,tag);
TIFFErrorExt(tif->tif_clientdata, module,
- "%s: Bad value %u for \"%s\" tag",
+ "%s: Bad value %"PRIu32" for \"%s\" tag",
tif->tif_name, v,
fip2 ? fip2->field_name : "Unknown");
va_end(ap);
@@ -765,7 +765,7 @@ badvalue32:
{
const TIFFField* fip2=TIFFFieldWithTag(tif,tag);
TIFFErrorExt(tif->tif_clientdata, module,
- "%s: Bad value %u for \"%s\" tag",
+ "%s: Bad value %"PRIu32" for \"%s\" tag",
tif->tif_name, v32,
fip2 ? fip2->field_name : "Unknown");
va_end(ap);
@@ -797,7 +797,7 @@ OkToChangeTag(TIFF* tif, uint32_t tag)
{
const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
if (!fip) { /* unknown tag */
- TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %u",
+ TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %"PRIu32,
tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag);
return (0);
}
@@ -928,7 +928,7 @@ _TIFFVGetField(TIFF* tif, uint32_t tag, va_list ap)
if( val > td->td_samplesperpixel )
{
TIFFWarningExt(tif->tif_clientdata,"_TIFFVGetField",
- "Truncating NumberOfInks from %u to %u",
+ "Truncating NumberOfInks from %u to %"PRIu16,
val, td->td_samplesperpixel);
val = td->td_samplesperpixel;
}
@@ -1760,7 +1760,7 @@ TIFFUnlinkDirectory(TIFF* tif, uint16_t dirn)
}
for (n = dirn-1; n > 0; n--) {
if (nextdir == 0) {
- TIFFErrorExt(tif->tif_clientdata, module, "Directory %d does not exist", dirn);
+ TIFFErrorExt(tif->tif_clientdata, module, "Directory %"PRIu16" does not exist", dirn);
return (0);
}
if (!TIFFAdvanceDirectory(tif, &nextdir, &off))
diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
index 9f7a404a..1543c3f4 100644
--- a/libtiff/tif_dirread.c
+++ b/libtiff/tif_dirread.c
@@ -809,9 +809,9 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryDataAndRealloc(
{
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
"Failed to allocate memory for %s "
- "(%ld elements of %ld bytes each)",
+ "(%"PRId64" elements of %"PRId64" bytes each)",
"TIFFReadDirEntryArray",
- (long) 1, (long) (already_read + to_read));
+ (tmsize_t) 1, already_read + to_read);
return TIFFReadDirEntryErrAlloc;
}
*pdest = new_dest;
@@ -3699,7 +3699,7 @@ TIFFReadDirectory(TIFF* tif)
if (fii == FAILED_FII)
{
TIFFWarningExt(tif->tif_clientdata, module,
- "Unknown field with tag %d (0x%x) encountered",
+ "Unknown field with tag %"PRIu16" (0x%"PRIx16") encountered",
dp->tdir_tag,dp->tdir_tag);
/* the following knowingly leaks the
anonymous field structure */
@@ -3710,7 +3710,7 @@ TIFFReadDirectory(TIFF* tif)
1)) {
TIFFWarningExt(tif->tif_clientdata,
module,
- "Registering anonymous field with tag %d (0x%x) failed",
+ "Registering anonymous field with tag %"PRIu16" (0x%"PRIx16") failed",
dp->tdir_tag,
dp->tdir_tag);
dp->tdir_ignore = TRUE;
@@ -3981,7 +3981,7 @@ TIFFReadDirectory(TIFF* tif)
{
fip = TIFFFieldWithTag(tif,dp->tdir_tag);
TIFFWarningExt(tif->tif_clientdata,module,
- "Ignoring %s because BitsPerSample=%d>24",
+ "Ignoring %s because BitsPerSample=%"PRIu16">24",
fip ? fip->field_name : "unknown tagname",
tif->tif_dir.td_bitspersample);
continue;
@@ -4164,7 +4164,8 @@ TIFFReadDirectory(TIFF* tif)
new_sampleinfo = (uint16_t*) _TIFFcalloc(tif->tif_dir.td_extrasamples, sizeof(uint16_t));
if (!new_sampleinfo) {
TIFFErrorExt(tif->tif_clientdata, module, "Failed to allocate memory for "
- "temporary new sampleinfo array (%d 16 bit elements)",
+ "temporary new sampleinfo array "
+ "(%"PRIu16" 16 bit elements)",
tif->tif_dir.td_extrasamples);
goto bad;
}
@@ -4462,14 +4463,14 @@ TIFFReadCustomDirectory(TIFF* tif, toff_t diroff,
if (fii == FAILED_FII)
{
TIFFWarningExt(tif->tif_clientdata, module,
- "Unknown field with tag %d (0x%x) encountered",
+ "Unknown field with tag %"PRIu16" (0x%"PRIx16") encountered",
dp->tdir_tag, dp->tdir_tag);
if (!_TIFFMergeFields(tif, _TIFFCreateAnonField(tif,
dp->tdir_tag,
(TIFFDataType) dp->tdir_type),
1)) {
TIFFWarningExt(tif->tif_clientdata, module,
- "Registering anonymous field with tag %d (0x%x) failed",
+ "Registering anonymous field with tag %"PRIu16" (0x%"PRIx16") failed",
dp->tdir_tag, dp->tdir_tag);
dp->tdir_ignore = TRUE;
} else {
@@ -4499,7 +4500,7 @@ TIFFReadCustomDirectory(TIFF* tif, toff_t diroff,
if (fii==0xFFFF)
{
TIFFWarningExt(tif->tif_clientdata, module,
- "Wrong data type %d for \"%s\"; tag ignored",
+ "Wrong data type %"PRIu16" for \"%s\"; tag ignored",
dp->tdir_type,fip->field_name);
dp->tdir_ignore = TRUE;
}
@@ -4598,7 +4599,7 @@ EstimateStripByteCounts(TIFF* tif, TIFFDirEntry* dir, uint16_t dircount)
typewidth = TIFFDataWidth((TIFFDataType) dp->tdir_type);
if (typewidth == 0) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Cannot determine size of unknown tag type %d",
+ "Cannot determine size of unknown tag type %"PRIu16,
dp->tdir_type);
return -1;
}
@@ -4736,14 +4737,14 @@ CheckDirCount(TIFF* tif, TIFFDirEntry* dir, uint32_t count)
if ((uint64_t)count > dir->tdir_count) {
const TIFFField* fip = TIFFFieldWithTag(tif, dir->tdir_tag);
TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
- "incorrect count for field \"%s\" (%" PRIu64 ", expecting %u); tag ignored",
+ "incorrect count for field \"%s\" (%" PRIu64 ", expecting %"PRIu32"); tag ignored",
fip ? fip->field_name : "unknown tagname",
dir->tdir_count, count);
return (0);
} else if ((uint64_t)count < dir->tdir_count) {
const TIFFField* fip = TIFFFieldWithTag(tif, dir->tdir_tag);
TIFFWarningExt(tif->tif_clientdata, tif->tif_name,
- "incorrect count for field \"%s\" (%" PRIu64 ", expecting %u); tag trimmed",
+ "incorrect count for field \"%s\" (%" PRIu64 ", expecting %"PRIu32"); tag trimmed",
fip ? fip->field_name : "unknown tagname",
dir->tdir_count, count);
dir->tdir_count = count;
@@ -5026,7 +5027,7 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
if( fii == FAILED_FII )
{
TIFFErrorExt(tif->tif_clientdata, "TIFFFetchNormalTag",
- "No definition found for tag %d",
+ "No definition found for tag %"PRIu16,
dp->tdir_tag);
return 0;
}
@@ -5187,8 +5188,8 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
assert(fip->field_passcount==0);
if (dp->tdir_count!=2) {
TIFFWarningExt(tif->tif_clientdata,module,
- "incorrect count for field \"%s\", expected 2, got %d",
- fip->field_name,(int)dp->tdir_count);
+ "incorrect count for field \"%s\", expected 2, got %"PRIu64,
+ fip->field_name, dp->tdir_count);
return(0);
}
err=TIFFReadDirEntryShortArray(tif,dp,&data);
@@ -5210,8 +5211,8 @@ TIFFFetchNormalTag(TIFF* tif, TIFFDirEntry* dp, int recover)
assert(fip->field_passcount==0);
if (dp->tdir_count!=(uint64_t)fip->field_readcount) {
TIFFWarningExt(tif->tif_clientdata,module,
- "incorrect count for field \"%s\", expected %d, got %d",
- fip->field_name,(int) fip->field_readcount, (int)dp->tdir_count);
+ "incorrect count for field \"%s\", expected %d, got %"PRIu64,
+ fip->field_name,(int) fip->field_readcount, dp->tdir_count);
return 0;
}
else
diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
index 2f469cfd..0a7eb7da 100644
--- a/libtiff/tif_dirwrite.c
+++ b/libtiff/tif_dirwrite.c
@@ -755,7 +755,7 @@ TIFFWriteDirectorySec(TIFF* tif, int isimage, int imagedone, uint64_t* pdiroff)
break;
default:
TIFFErrorExt(tif->tif_clientdata,module,
- "Cannot write tag %d (%s)",
+ "Cannot write tag %"PRIu32" (%s)",
TIFFFieldTag(o),
o->field_name ? o->field_name : "unknown");
goto bad;
@@ -2710,16 +2710,16 @@ void DoubleToSrational_direct(double value, long *num, long *denom)
* using the Euclidean algorithm to find the greatest common divisor (GCD)
------------------------------------------------------------------------*/
static
-void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmallRange, unsigned long long *ullNum, unsigned long long *ullDenom)
+void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmallRange, uint64_t *ullNum, uint64_t *ullDenom)
{
/* Internally, the integer variables can be bigger than the external ones,
* as long as the result will fit into the external variable size.
*/
- unsigned long long val, numSum[3] = { 0, 1, 0 }, denomSum[3] = { 1, 0, 0 };
- unsigned long long aux, bigNum, bigDenom;
- unsigned long long returnLimit;
+ uint64_t val, numSum[3] = { 0, 1, 0 }, denomSum[3] = { 1, 0, 0 };
+ uint64_t aux, bigNum, bigDenom;
+ uint64_t returnLimit;
int i;
- unsigned long long nMax;
+ uint64_t nMax;
double fMax;
unsigned long maxDenom;
/*-- nMax and fMax defines the initial accuracy of the starting fractional,
@@ -2729,7 +2729,7 @@ void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmall
* For long long nMax = ((9223372036854775807-1)/2); for long nMax = ((2147483647-1)/2);
*/
if (blnUseSmallRange) {
- nMax = (unsigned long long)((2147483647 - 1) / 2); /* for ULONG range */
+ nMax = (uint64_t)((2147483647 - 1) / 2); /* for ULONG range */
}
else {
nMax = ((9223372036854775807 - 1) / 2); /* for ULLONG range */
@@ -2750,7 +2750,7 @@ void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmall
}
/*-- First generate a rational fraction (bigNum/bigDenom) which represents the value
- * as a rational number with the highest accuracy. Therefore, unsigned long long (uint64_t) is needed.
+ * as a rational number with the highest accuracy. Therefore, uint64_t (uint64_t) is needed.
* This rational fraction is then reduced using the Euclidean algorithm to find the greatest common divisor (GCD).
* bigNum = big numinator of value without fraction (or cut residual fraction)
* bigDenom = big denominator of value
@@ -2762,7 +2762,7 @@ void ToRationalEuclideanGCD(double value, int blnUseSignedRange, int blnUseSmall
bigDenom <<= 1;
value *= 2;
}
- bigNum = (unsigned long long)value;
+ bigNum = (uint64_t)value;
/*-- Start Euclidean algorithm to find the greatest common divisor (GCD) -- */
#define MAX_ITERATIONS 64
@@ -2823,7 +2823,7 @@ void DoubleToRational(double value, uint32_t *num, uint32_t *denom)
{
/*---- UN-SIGNED RATIONAL ---- */
double dblDiff, dblDiff2;
- unsigned long long ullNum, ullDenom, ullNum2, ullDenom2;
+ uint64_t ullNum, ullDenom, ullNum2, ullDenom2;
/*-- Check for negative values. If so it is an error. */
/* Test written that way to catch NaN */
@@ -2860,11 +2860,7 @@ void DoubleToRational(double value, uint32_t *num, uint32_t *denom)
ToRationalEuclideanGCD(value, FALSE, TRUE, &ullNum2, &ullDenom2);
/*-- Double-Check, that returned values fit into ULONG :*/
if (ullNum > 0xFFFFFFFFUL || ullDenom > 0xFFFFFFFFUL || ullNum2 > 0xFFFFFFFFUL || ullDenom2 > 0xFFFFFFFFUL) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- TIFFErrorExt(0, "TIFFLib: DoubleToRational()", " Num or Denom exceeds ULONG: val=%14.6f, num=%I64u, denom=%I64u | num2=%I64u, denom2=%I64u", value, ullNum, ullDenom, ullNum2, ullDenom2);
-#else
- TIFFErrorExt(0, "TIFFLib: DoubleToRational()", " Num or Denom exceeds ULONG: val=%14.6f, num=%12llu, denom=%12llu | num2=%12llu, denom2=%12llu", value, ullNum, ullDenom, ullNum2, ullDenom2);
-#endif
+ TIFFErrorExt(0, "TIFFLib: DoubleToRational()", " Num or Denom exceeds ULONG: val=%14.6f, num=%12"PRIu64", denom=%12"PRIu64" | num2=%12"PRIu64", denom2=%12"PRIu64"", value, ullNum, ullDenom, ullNum2, ullDenom2);
assert(0);
}
@@ -2892,7 +2888,7 @@ void DoubleToSrational(double value, int32_t *num, int32_t *denom)
/*---- SIGNED RATIONAL ----*/
int neg = 1;
double dblDiff, dblDiff2;
- unsigned long long ullNum, ullDenom, ullNum2, ullDenom2;
+ uint64_t ullNum, ullDenom, ullNum2, ullDenom2;
/*-- Check for negative values and use then the positive one for internal calculations, but take the sign into account before returning. */
if (value < 0) { neg = -1; value = -value; }
@@ -2925,11 +2921,7 @@ void DoubleToSrational(double value, int32_t *num, int32_t *denom)
ToRationalEuclideanGCD(value, TRUE, TRUE, &ullNum2, &ullDenom2);
/*-- Double-Check, that returned values fit into LONG :*/
if (ullNum > 0x7FFFFFFFL || ullDenom > 0x7FFFFFFFL || ullNum2 > 0x7FFFFFFFL || ullDenom2 > 0x7FFFFFFFL) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- TIFFErrorExt(0, "TIFFLib: DoubleToSrational()", " Num or Denom exceeds LONG: val=%14.6f, num=%I64u, denom=%I64u | num2=%I64u, denom2=%I64u", neg*value, ullNum, ullDenom, ullNum2, ullDenom2);
-#else
- TIFFErrorExt(0, "TIFFLib: DoubleToSrational()", " Num or Denom exceeds LONG: val=%14.6f, num=%12llu, denom=%12llu | num2=%12llu, denom2=%12llu", neg*value, ullNum, ullDenom, ullNum2, ullDenom2);
-#endif
+ TIFFErrorExt(0, "TIFFLib: DoubleToSrational()", " Num or Denom exceeds LONG: val=%14.6f, num=%12"PRIu64", denom=%12"PRIu64" | num2=%12"PRIu64", denom2=%12"PRIu64"", neg*value, ullNum, ullDenom, ullNum2, ullDenom2);
assert(0);
}
@@ -3405,7 +3397,7 @@ _TIFFRewriteField(TIFF* tif, uint16_t tag, TIFFDataType in_datatype,
if( entry_tag != tag )
{
TIFFErrorExt(tif->tif_clientdata, module,
- "%s: Could not find tag %d.",
+ "%s: Could not find tag %"PRIu16".",
tif->tif_name, tag );
return 0;
}
diff --git a/libtiff/tif_dumpmode.c b/libtiff/tif_dumpmode.c
index d739d8d1..8171ac4a 100644
--- a/libtiff/tif_dumpmode.c
+++ b/libtiff/tif_dumpmode.c
@@ -78,19 +78,11 @@ DumpModeDecode(TIFF* tif, uint8_t* buf, tmsize_t cc, uint16_t s)
static const char module[] = "DumpModeDecode";
(void) s;
if (tif->tif_rawcc < cc) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
-"Not enough data for scanline %lu, expected a request for at most %I64d bytes, got a request for %I64d bytes",
- (unsigned long) tif->tif_row,
- (signed __int64) tif->tif_rawcc,
- (signed __int64) cc);
-#else
- TIFFErrorExt(tif->tif_clientdata, module,
-"Not enough data for scanline %lu, expected a request for at most %lld bytes, got a request for %lld bytes",
- (unsigned long) tif->tif_row,
- (signed long long) tif->tif_rawcc,
- (signed long long) cc);
-#endif
+"Not enough data for scanline %"PRIu32", expected a request for at most %"PRId64" bytes, got a request for %"PRId64" bytes",
+ tif->tif_row,
+ tif->tif_rawcc,
+ cc);
return (0);
}
/*
diff --git a/libtiff/tif_fax3.c b/libtiff/tif_fax3.c
index cce477cb..49776812 100644
--- a/libtiff/tif_fax3.c
+++ b/libtiff/tif_fax3.c
@@ -180,7 +180,7 @@ Fax3PreDecode(TIFF* tif, uint16_t s)
static void
Fax3Unexpected(const char* module, TIFF* tif, uint32_t line, uint32_t a0)
{
- TIFFErrorExt(tif->tif_clientdata, module, "Bad code word at line %u of %s %u (x %u)",
+ TIFFErrorExt(tif->tif_clientdata, module, "Bad code word at line %"PRIu32" of %s %"PRIu32" (x %"PRIu32")",
line, isTiled(tif) ? "tile" : "strip",
(isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip),
a0);
@@ -191,7 +191,7 @@ static void
Fax3Extension(const char* module, TIFF* tif, uint32_t line, uint32_t a0)
{
TIFFErrorExt(tif->tif_clientdata, module,
- "Uncompressed data (not supported) at line %u of %s %u (x %u)",
+ "Uncompressed data (not supported) at line %"PRIu32" of %s %"PRIu32" (x %"PRIu32")",
line, isTiled(tif) ? "tile" : "strip",
(isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip),
a0);
@@ -201,7 +201,7 @@ Fax3Extension(const char* module, TIFF* tif, uint32_t line, uint32_t a0)
static void
Fax3BadLength(const char* module, TIFF* tif, uint32_t line, uint32_t a0, uint32_t lastx)
{
- TIFFWarningExt(tif->tif_clientdata, module, "%s at line %u of %s %u (got %u, expected %u)",
+ TIFFWarningExt(tif->tif_clientdata, module, "%s at line %"PRIu32" of %s %"PRIu32" (got %"PRIu32", expected %"PRIu32")",
a0 < lastx ? "Premature EOL" : "Line length mismatch",
line, isTiled(tif) ? "tile" : "strip",
(isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip),
@@ -212,7 +212,7 @@ Fax3BadLength(const char* module, TIFF* tif, uint32_t line, uint32_t a0, uint32_
static void
Fax3PrematureEOF(const char* module, TIFF* tif, uint32_t line, uint32_t a0)
{
- TIFFWarningExt(tif->tif_clientdata, module, "Premature EOF at line %u of %s %u (x %u)",
+ TIFFWarningExt(tif->tif_clientdata, module, "Premature EOF at line %"PRIu32" of %s %"PRIu32" (x %"PRIu32")",
line, isTiled(tif) ? "tile" : "strip",
(isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip),
a0);
@@ -245,8 +245,8 @@ Fax3Decode1D(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
RunLength = 0;
pa = thisrun;
#ifdef FAX3_DEBUG
- printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail);
- printf("-------------------- %d\n", tif->tif_row);
+ printf("\nBitAcc=%08"PRIX32", BitsAvail = %d\n", BitAcc, BitsAvail);
+ printf("-------------------- %"PRIu32"\n", tif->tif_row);
fflush(stdout);
#endif
SYNC_EOL(EOF1D);
@@ -288,7 +288,7 @@ Fax3Decode2D(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
RunLength = 0;
pa = thisrun = sp->curruns;
#ifdef FAX3_DEBUG
- printf("\nBitAcc=%08X, BitsAvail = %d EOLcnt = %d",
+ printf("\nBitAcc=%08"PRIX32", BitsAvail = %d EOLcnt = %d",
BitAcc, BitsAvail, EOLcnt);
#endif
SYNC_EOL(EOF2D);
@@ -296,7 +296,7 @@ Fax3Decode2D(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
is1D = GetBits(1); /* 1D/2D-encoding tag bit */
ClrBits(1);
#ifdef FAX3_DEBUG
- printf(" %s\n-------------------- %d\n",
+ printf(" %s\n-------------------- %"PRIu32"\n",
is1D ? "1D" : "2D", tif->tif_row);
fflush(stdout);
#endif
@@ -533,7 +533,7 @@ Fax3SetupState(TIFF* tif)
}
if ((dsp->nruns == 0) || (TIFFSafeMultiply(uint32_t, dsp->nruns, 2) == 0)) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
- "Row pixels integer overflow (rowpixels %u)",
+ "Row pixels integer overflow (rowpixels %"PRIu32")",
rowpixels);
return (0);
}
@@ -642,7 +642,7 @@ Fax3PutBits(TIFF* tif, unsigned int bits, unsigned int length)
#define DEBUG_COLOR(w) (tab == TIFFFaxWhiteCodes ? w "W" : w "B")
#define DEBUG_PRINT(what,len) { \
int t; \
- printf("%08X/%-2d: %s%5d\t", data, bit, DEBUG_COLOR(what), len); \
+ printf("%08"PRIX32"/%-2d: %s%5d\t", data, bit, DEBUG_COLOR(what), len); \
for (t = length-1; t >= 0; t--) \
putchar(code & (1<<t) ? '1' : '0'); \
putchar('\n'); \
@@ -1330,7 +1330,7 @@ Fax3PrintDir(TIFF* tif, FILE* fd, long flags)
fprintf(fd, " uncorrected errors");
break;
}
- fprintf(fd, " (%u = 0x%x)\n",
+ fprintf(fd, " (%"PRIu16" = 0x%"PRIx16")\n",
sp->cleanfaxdata, sp->cleanfaxdata);
}
if (TIFFFieldSet(tif,FIELD_BADFAXLINES))
@@ -1462,7 +1462,7 @@ Fax4Decode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
pb = sp->refruns;
b1 = *pb++;
#ifdef FAX3_DEBUG
- printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail);
+ printf("\nBitAcc=%08"PRIX32", BitsAvail = %d\n", BitAcc, BitsAvail);
printf("-------------------- %d\n", tif->tif_row);
fflush(stdout);
#endif
@@ -1472,8 +1472,8 @@ Fax4Decode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */
{
TIFFErrorExt(tif->tif_clientdata, module,
- "Buffer overrun detected : %d bytes available, %d bits needed",
- (int)occ, lastx);
+ "Buffer overrun detected : %"PRId64" bytes available, %d bits needed",
+ occ, lastx);
return -1;
}
(*sp->fill)(buf, thisrun, pa, lastx);
@@ -1494,8 +1494,8 @@ Fax4Decode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
if (((lastx + 7) >> 3) > (int)occ) /* check for buffer overrun */
{
TIFFErrorExt(tif->tif_clientdata, module,
- "Buffer overrun detected : %d bytes available, %d bits needed",
- (int)occ, lastx);
+ "Buffer overrun detected : %"PRId64" bytes available, %d bits needed",
+ occ, lastx);
return -1;
}
(*sp->fill)(buf, thisrun, pa, lastx);
@@ -1600,8 +1600,8 @@ Fax3DecodeRLE(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
RunLength = 0;
pa = thisrun;
#ifdef FAX3_DEBUG
- printf("\nBitAcc=%08X, BitsAvail = %d\n", BitAcc, BitsAvail);
- printf("-------------------- %d\n", tif->tif_row);
+ printf("\nBitAcc=%08"PRIX32", BitsAvail = %d\n", BitAcc, BitsAvail);
+ printf("-------------------- %"PRIu32"\n", tif->tif_row);
fflush(stdout);
#endif
EXPAND1D(EOFRLE);
diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c
index 04c4cc7b..a1b6570b 100644
--- a/libtiff/tif_getimage.c
+++ b/libtiff/tif_getimage.c
@@ -90,7 +90,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024])
case 16:
break;
default:
- sprintf(emsg, "Sorry, can not handle images with %d-bit samples",
+ sprintf(emsg, "Sorry, can not handle images with %"PRIu16"-bit samples",
td->td_bitspersample);
return (0);
}
@@ -120,8 +120,8 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024])
&& td->td_samplesperpixel != 1
&& td->td_bitspersample < 8 ) {
sprintf(emsg,
- "Sorry, can not handle contiguous data with %s=%d, "
- "and %s=%d and Bits/Sample=%d",
+ "Sorry, can not handle contiguous data with %s=%"PRIu16", "
+ "and %s=%"PRIu16" and Bits/Sample=%"PRIu16"",
photoTag, photometric,
"Samples/pixel", td->td_samplesperpixel,
td->td_bitspersample);
@@ -160,7 +160,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024])
}
if (td->td_samplesperpixel < 4) {
sprintf(emsg,
- "Sorry, can not handle separated image with %s=%d",
+ "Sorry, can not handle separated image with %s=%"PRIu16,
"Samples/pixel", td->td_samplesperpixel);
return 0;
}
@@ -181,13 +181,13 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024])
return (0);
}
if (td->td_planarconfig != PLANARCONFIG_CONTIG) {
- sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d",
+ sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%"PRIu16,
"Planarconfiguration", td->td_planarconfig);
return (0);
}
if ( td->td_samplesperpixel != 3 || colorchannels != 3 ) {
sprintf(emsg,
- "Sorry, can not handle image with %s=%d, %s=%d",
+ "Sorry, can not handle image with %s=%"PRIu16", %s=%d",
"Samples/pixel", td->td_samplesperpixel,
"colorchannels", colorchannels);
return 0;
@@ -196,7 +196,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024])
case PHOTOMETRIC_CIELAB:
if ( td->td_samplesperpixel != 3 || colorchannels != 3 || td->td_bitspersample != 8 ) {
sprintf(emsg,
- "Sorry, can not handle image with %s=%d, %s=%d and %s=%d",
+ "Sorry, can not handle image with %s=%"PRIu16", %s=%d and %s=%"PRIu16,
"Samples/pixel", td->td_samplesperpixel,
"colorchannels", colorchannels,
"Bits/sample", td->td_bitspersample);
@@ -204,7 +204,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024])
}
break;
default:
- sprintf(emsg, "Sorry, can not handle image with %s=%d",
+ sprintf(emsg, "Sorry, can not handle image with %s=%"PRIu16,
photoTag, photometric);
return (0);
}
@@ -302,7 +302,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
case 16:
break;
default:
- sprintf(emsg, "Sorry, can not handle images with %d-bit samples",
+ sprintf(emsg, "Sorry, can not handle images with %"PRIu16"-bit samples",
img->bitspersample);
goto fail_return;
}
@@ -385,8 +385,8 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
&& img->samplesperpixel != 1
&& img->bitspersample < 8 ) {
sprintf(emsg,
- "Sorry, can not handle contiguous data with %s=%d, "
- "and %s=%d and Bits/Sample=%d",
+ "Sorry, can not handle contiguous data with %s=%"PRIu16", "
+ "and %s=%"PRIu16" and Bits/Sample=%"PRIu16,
photoTag, img->photometric,
"Samples/pixel", img->samplesperpixel,
img->bitspersample);
@@ -431,12 +431,12 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
uint16_t inkset;
TIFFGetFieldDefaulted(tif, TIFFTAG_INKSET, &inkset);
if (inkset != INKSET_CMYK) {
- sprintf(emsg, "Sorry, can not handle separated image with %s=%d",
+ sprintf(emsg, "Sorry, can not handle separated image with %s=%"PRIu16,
"InkSet", inkset);
goto fail_return;
}
if (img->samplesperpixel < 4) {
- sprintf(emsg, "Sorry, can not handle separated image with %s=%d",
+ sprintf(emsg, "Sorry, can not handle separated image with %s=%"PRIu16,
"Samples/pixel", img->samplesperpixel);
goto fail_return;
}
@@ -459,7 +459,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
goto fail_return;
}
if (planarconfig != PLANARCONFIG_CONTIG) {
- sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%d",
+ sprintf(emsg, "Sorry, can not handle LogLuv images with %s=%"PRIu16,
"Planarconfiguration", planarconfig);
return (0);
}
@@ -470,7 +470,7 @@ TIFFRGBAImageBegin(TIFFRGBAImage* img, TIFF* tif, int stop, char emsg[1024])
case PHOTOMETRIC_CIELAB:
break;
default:
- sprintf(emsg, "Sorry, can not handle image with %s=%d",
+ sprintf(emsg, "Sorry, can not handle image with %s=%"PRIu16,
photoTag, img->photometric);
goto fail_return;
}
diff --git a/libtiff/tif_jbig.c b/libtiff/tif_jbig.c
index 58ef8fe6..093ff7f0 100644
--- a/libtiff/tif_jbig.c
+++ b/libtiff/tif_jbig.c
@@ -101,14 +101,14 @@ static int JBIGDecode(TIFF* tif, uint8_t* buffer, tmsize_t size, uint16_t s)
if( (tmsize_t)decodedSize < size )
{
TIFFWarningExt(tif->tif_clientdata, "JBIG",
- "Only decoded %lu bytes, whereas %lu requested",
- decodedSize, (unsigned long)size);
+ "Only decoded %lu bytes, whereas %"PRId64" requested",
+ decodedSize, size);
}
else if( (tmsize_t)decodedSize > size )
{
TIFFErrorExt(tif->tif_clientdata, "JBIG",
- "Decoded %lu bytes, whereas %lu were requested",
- decodedSize, (unsigned long)size);
+ "Decoded %lu bytes, whereas %"PRId64" were requested",
+ decodedSize, size);
jbg_dec_free(&decoder);
return 0;
}
diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c
index ae5716e8..6076c117 100644
--- a/libtiff/tif_jpeg.c
+++ b/libtiff/tif_jpeg.c
@@ -913,10 +913,10 @@ JPEGFixupTagsSubsamplingSec(struct JPEGFixupTagsSubsamplingData* data)
if ((ph!=data->tif->tif_dir.td_ycbcrsubsampling[0])||(pv!=data->tif->tif_dir.td_ycbcrsubsampling[1]))
{
TIFFWarningExt(data->tif->tif_clientdata,module,
- "Auto-corrected former TIFF subsampling values [%d,%d] to match subsampling values inside JPEG compressed data [%d,%d]",
- (int)data->tif->tif_dir.td_ycbcrsubsampling[0],
- (int)data->tif->tif_dir.td_ycbcrsubsampling[1],
- (int)ph,(int)pv);
+ "Auto-corrected former TIFF subsampling values [%"PRIu16",%"PRIu16"] to match subsampling values inside JPEG compressed data [%"PRIu8",%"PRIu8"]",
+ data->tif->tif_dir.td_ycbcrsubsampling[0],
+ data->tif->tif_dir.td_ycbcrsubsampling[1],
+ ph, pv);
data->tif->tif_dir.td_ycbcrsubsampling[0]=ph;
data->tif->tif_dir.td_ycbcrsubsampling[1]=pv;
}
@@ -1148,7 +1148,7 @@ JPEGPreDecode(TIFF* tif, uint16_t s)
sp->cinfo.d.image_height < segment_height) {
TIFFWarningExt(tif->tif_clientdata, module,
"Improper JPEG strip/tile size, "
- "expected %dx%d, got %dx%d",
+ "expected %"PRIu32"x%"PRIu32", got %ux%u",
segment_width, segment_height,
sp->cinfo.d.image_width,
sp->cinfo.d.image_height);
@@ -1163,7 +1163,7 @@ JPEGPreDecode(TIFF* tif, uint16_t s)
/* we can safely recover from that. */
TIFFWarningExt(tif->tif_clientdata, module,
"JPEG strip size exceeds expected dimensions,"
- " expected %dx%d, got %dx%d",
+ " expected %"PRIu32"x%"PRIu32", got %ux%u",
segment_width, segment_height,
sp->cinfo.d.image_width, sp->cinfo.d.image_height);
}
@@ -1177,7 +1177,7 @@ JPEGPreDecode(TIFF* tif, uint16_t s)
*/
TIFFErrorExt(tif->tif_clientdata, module,
"JPEG strip/tile size exceeds expected dimensions,"
- " expected %dx%d, got %dx%d",
+ " expected %"PRIu32"x%"PRIu32", got %ux%u",
segment_width, segment_height,
sp->cinfo.d.image_width, sp->cinfo.d.image_height);
return (0);
@@ -1231,15 +1231,15 @@ JPEGPreDecode(TIFF* tif, uint16_t s)
{
TIFFErrorExt(tif->tif_clientdata, module,
"Reading this image would require libjpeg to allocate "
- "at least %u bytes. "
- "This is disabled since above the %u threshold. "
+ "at least %"PRIu64" bytes. "
+ "This is disabled since above the %ld threshold. "
"You may override this restriction by defining the "
"LIBTIFF_ALLOW_LARGE_LIBJPEG_MEM_ALLOC environment variable, "
"or setting the JPEGMEM environment variable to a value greater "
- "or equal to '%uM'",
- (unsigned)(nRequiredMemory),
- (unsigned)(sp->cinfo.d.mem->max_memory_to_use),
- (unsigned)((nRequiredMemory + 1000000 - 1) / 1000000));
+ "or equal to '%"PRIu64"M'",
+ nRequiredMemory,
+ sp->cinfo.d.mem->max_memory_to_use,
+ (nRequiredMemory + 1000000u - 1u) / 1000000u);
return 0;
}
}
@@ -1250,7 +1250,7 @@ JPEGPreDecode(TIFF* tif, uint16_t s)
sp->cinfo.d.comp_info[0].v_samp_factor != sp->v_sampling) {
TIFFErrorExt(tif->tif_clientdata, module,
"Improper JPEG sampling factors %d,%d\n"
- "Apparently should be %d,%d.",
+ "Apparently should be %"PRIu16",%"PRIu16".",
sp->cinfo.d.comp_info[0].h_samp_factor,
sp->cinfo.d.comp_info[0].v_samp_factor,
sp->h_sampling, sp->v_sampling);
@@ -1784,7 +1784,7 @@ JPEGSetupEncode(TIFF* tif)
if( td->td_bitspersample > 16 )
{
TIFFErrorExt(tif->tif_clientdata, module,
- "BitsPerSample %d not allowed for JPEG",
+ "BitsPerSample %"PRIu16" not allowed for JPEG",
td->td_bitspersample);
return (0);
}
@@ -1814,8 +1814,8 @@ JPEGSetupEncode(TIFF* tif)
case PHOTOMETRIC_PALETTE: /* disallowed by Tech Note */
case PHOTOMETRIC_MASK:
TIFFErrorExt(tif->tif_clientdata, module,
- "PhotometricInterpretation %d not allowed for JPEG",
- (int) sp->photometric);
+ "PhotometricInterpretation %"PRIu16" not allowed for JPEG",
+ sp->photometric);
return (0);
default:
/* TIFF 6.0 forbids subsampling of all other color spaces */
@@ -1838,8 +1838,8 @@ JPEGSetupEncode(TIFF* tif)
if (td->td_bitspersample != BITS_IN_JSAMPLE )
#endif
{
- TIFFErrorExt(tif->tif_clientdata, module, "BitsPerSample %d not allowed for JPEG",
- (int) td->td_bitspersample);
+ TIFFErrorExt(tif->tif_clientdata, module, "BitsPerSample %"PRIu16" not allowed for JPEG",
+ td->td_bitspersample);
return (0);
}
sp->cinfo.c.data_precision = td->td_bitspersample;
@@ -1849,22 +1849,22 @@ JPEGSetupEncode(TIFF* tif)
if (isTiled(tif)) {
if ((td->td_tilelength % (sp->v_sampling * DCTSIZE)) != 0) {
TIFFErrorExt(tif->tif_clientdata, module,
- "JPEG tile height must be multiple of %d",
- sp->v_sampling * DCTSIZE);
+ "JPEG tile height must be multiple of %"PRIu32,
+ (uint32_t)(sp->v_sampling * DCTSIZE));
return (0);
}
if ((td->td_tilewidth % (sp->h_sampling * DCTSIZE)) != 0) {
TIFFErrorExt(tif->tif_clientdata, module,
- "JPEG tile width must be multiple of %d",
- sp->h_sampling * DCTSIZE);
+ "JPEG tile width must be multiple of %"PRIu32,
+ (uint32_t)(sp->h_sampling * DCTSIZE));
return (0);
}
} else {
if (td->td_rowsperstrip < td->td_imagelength &&
(td->td_rowsperstrip % (sp->v_sampling * DCTSIZE)) != 0) {
TIFFErrorExt(tif->tif_clientdata, module,
- "RowsPerStrip must be multiple of %d for JPEG",
- sp->v_sampling * DCTSIZE);
+ "RowsPerStrip must be multiple of %"PRIu32" for JPEG",
+ (uint32_t)(sp->v_sampling * DCTSIZE));
return (0);
}
}
@@ -2377,8 +2377,8 @@ JPEGPrintDir(TIFF* tif, FILE* fd, long flags)
if( sp != NULL ) {
if (TIFFFieldSet(tif,FIELD_JPEGTABLES))
- fprintf(fd, " JPEG Tables: (%lu bytes)\n",
- (unsigned long) sp->jpegtables_length);
+ fprintf(fd, " JPEG Tables: (%"PRIu32" bytes)\n",
+ sp->jpegtables_length);
if (sp->printdir)
(*sp->printdir)(tif, fd, flags);
}
diff --git a/libtiff/tif_luv.c b/libtiff/tif_luv.c
index d1b9257e..de650b31 100644
--- a/libtiff/tif_luv.c
+++ b/libtiff/tif_luv.c
@@ -231,17 +231,10 @@ LogL16Decode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s)
}
}
if (i != npixels) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at row %lu (short %I64d pixels)",
- (unsigned long) tif->tif_row,
- (unsigned __int64) (npixels - i));
-#else
- TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at row %lu (short %llu pixels)",
- (unsigned long) tif->tif_row,
- (unsigned long long) (npixels - i));
-#endif
+ "Not enough data at row %"PRIu32" (short %"PRId64" pixels)",
+ tif->tif_row,
+ npixels - i);
tif->tif_rawcp = (uint8_t*) bp;
tif->tif_rawcc = cc;
return (0);
@@ -294,17 +287,10 @@ LogLuvDecode24(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s)
tif->tif_rawcp = (uint8_t*) bp;
tif->tif_rawcc = cc;
if (i != npixels) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at row %lu (short %I64d pixels)",
- (unsigned long) tif->tif_row,
- (unsigned __int64) (npixels - i));
-#else
TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at row %lu (short %llu pixels)",
- (unsigned long) tif->tif_row,
- (unsigned long long) (npixels - i));
-#endif
+ "Not enough data at row %"PRIu32" (short %"PRId64" pixels)",
+ tif->tif_row,
+ npixels - i);
return (0);
}
(*sp->tfunc)(sp, op, npixels);
@@ -367,17 +353,10 @@ LogLuvDecode32(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s)
}
}
if (i != npixels) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at row %lu (short %I64d pixels)",
- (unsigned long) tif->tif_row,
- (unsigned __int64) (npixels - i));
-#else
TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at row %lu (short %llu pixels)",
- (unsigned long) tif->tif_row,
- (unsigned long long) (npixels - i));
-#endif
+ "Not enough data at row %"PRIu32" (short %"PRId64" pixels)",
+ tif->tif_row,
+ npixels - i);
tif->tif_rawcp = (uint8_t*) bp;
tif->tif_rawcc = cc;
return (0);
@@ -1294,7 +1273,7 @@ LogL16InitState(TIFF* tif)
if( td->td_samplesperpixel != 1 )
{
TIFFErrorExt(tif->tif_clientdata, module,
- "Sorry, can not handle LogL image with %s=%d",
+ "Sorry, can not handle LogL image with %s=%"PRIu16,
"Samples/pixel", td->td_samplesperpixel);
return 0;
}
@@ -1495,7 +1474,7 @@ LogLuvSetupDecode(TIFF* tif)
return (1);
default:
TIFFErrorExt(tif->tif_clientdata, module,
- "Inappropriate photometric interpretation %d for SGILog compression; %s",
+ "Inappropriate photometric interpretation %"PRIu16" for SGILog compression; %s",
td->td_photometric, "must be either LogLUV or LogL");
break;
}
@@ -1559,7 +1538,7 @@ LogLuvSetupEncode(TIFF* tif)
break;
default:
TIFFErrorExt(tif->tif_clientdata, module,
- "Inappropriate photometric interpretation %d for SGILog compression; %s",
+ "Inappropriate photometric interpretation %"PRIu16" for SGILog compression; %s",
td->td_photometric, "must be either LogLUV or LogL");
return (0);
}
diff --git a/libtiff/tif_lzma.c b/libtiff/tif_lzma.c
index 5bc6846f..a5770569 100644
--- a/libtiff/tif_lzma.c
+++ b/libtiff/tif_lzma.c
@@ -206,15 +206,15 @@ LZMADecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s)
}
if (ret != LZMA_OK) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Decoding error at scanline %lu, %s",
- (unsigned long) tif->tif_row, LZMAStrerror(ret));
+ "Decoding error at scanline %"PRIu32", %s",
+ tif->tif_row, LZMAStrerror(ret));
break;
}
} while (sp->stream.avail_out > 0);
if (sp->stream.avail_out != 0) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at scanline %lu (short %lu bytes)",
- (unsigned long) tif->tif_row, (unsigned long) sp->stream.avail_out);
+ "Not enough data at scanline %"PRIu32" (short %zu bytes)",
+ tif->tif_row, sp->stream.avail_out);
return 0;
}
@@ -294,8 +294,8 @@ LZMAEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s)
lzma_ret ret = lzma_code(&sp->stream, LZMA_RUN);
if (ret != LZMA_OK) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Encoding error at scanline %lu, %s",
- (unsigned long) tif->tif_row, LZMAStrerror(ret));
+ "Encoding error at scanline %"PRIu32", %s",
+ tif->tif_row, LZMAStrerror(ret));
return 0;
}
if (sp->stream.avail_out == 0) {
diff --git a/libtiff/tif_lzw.c b/libtiff/tif_lzw.c
index 2f248400..c06aec40 100644
--- a/libtiff/tif_lzw.c
+++ b/libtiff/tif_lzw.c
@@ -175,7 +175,7 @@ static void cl_hash(LZWCodecState*);
#define NextCode(_tif, _sp, _bp, _code, _get) { \
if ((_sp)->dec_bitsleft < (uint64_t)nbits) { \
TIFFWarningExt(_tif->tif_clientdata, module, \
- "LZWDecode: Strip %d not terminated with EOI code", \
+ "LZWDecode: Strip %"PRIu32" not terminated with EOI code", \
_tif->tif_curstrip); \
_code = CODE_EOI; \
} else { \
@@ -352,7 +352,7 @@ static void
codeLoop(TIFF* tif, const char* module)
{
TIFFErrorExt(tif->tif_clientdata, module,
- "Bogus encoding, loop in the code table; scanline %d",
+ "Bogus encoding, loop in the code table; scanline %"PRIu32,
tif->tif_row);
}
@@ -454,7 +454,7 @@ LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s)
break;
if (code > CODE_CLEAR) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
- "LZWDecode: Corrupted LZW table at scanline %d",
+ "LZWDecode: Corrupted LZW table at scanline %"PRIu32,
tif->tif_row);
return (0);
}
@@ -471,7 +471,7 @@ LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s)
if (free_entp < &sp->dec_codetab[0] ||
free_entp >= &sp->dec_codetab[CSIZE]) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Corrupted LZW table at scanline %d",
+ "Corrupted LZW table at scanline %"PRIu32,
tif->tif_row);
return (0);
}
@@ -480,7 +480,7 @@ LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s)
if (free_entp->next < &sp->dec_codetab[0] ||
free_entp->next >= &sp->dec_codetab[CSIZE]) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Corrupted LZW table at scanline %d",
+ "Corrupted LZW table at scanline %"PRIu32,
tif->tif_row);
return (0);
}
@@ -503,7 +503,7 @@ LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s)
if(codep->length == 0) {
TIFFErrorExt(tif->tif_clientdata, module,
"Wrong length of decoded string: "
- "data probably corrupted at scanline %d",
+ "data probably corrupted at scanline %"PRIu32,
tif->tif_row);
return (0);
}
@@ -566,15 +566,9 @@ LZWDecode(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s)
sp->dec_maxcodep = maxcodep;
if (occ > 0) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at scanline %d (short %I64d bytes)",
- tif->tif_row, (unsigned __int64) occ);
-#else
- TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at scanline %d (short %llu bytes)",
- tif->tif_row, (unsigned long long) occ);
-#endif
+ "Not enough data at scanline %"PRIu32" (short %ld bytes)",
+ tif->tif_row, occ);
return (0);
}
return (1);
@@ -688,7 +682,7 @@ LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s)
break;
if (code > CODE_CLEAR) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
- "LZWDecode: Corrupted LZW table at scanline %d",
+ "LZWDecode: Corrupted LZW table at scanline %"PRIu32,
tif->tif_row);
return (0);
}
@@ -705,7 +699,7 @@ LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s)
if (free_entp < &sp->dec_codetab[0] ||
free_entp >= &sp->dec_codetab[CSIZE]) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Corrupted LZW table at scanline %d", tif->tif_row);
+ "Corrupted LZW table at scanline %"PRIu32, tif->tif_row);
return (0);
}
@@ -713,7 +707,7 @@ LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s)
if (free_entp->next < &sp->dec_codetab[0] ||
free_entp->next >= &sp->dec_codetab[CSIZE]) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Corrupted LZW table at scanline %d", tif->tif_row);
+ "Corrupted LZW table at scanline %"PRIu32, tif->tif_row);
return (0);
}
free_entp->firstchar = free_entp->next->firstchar;
@@ -735,7 +729,7 @@ LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s)
if(codep->length == 0) {
TIFFErrorExt(tif->tif_clientdata, module,
"Wrong length of decoded "
- "string: data probably corrupted at scanline %d",
+ "string: data probably corrupted at scanline %"PRIu32,
tif->tif_row);
return (0);
}
@@ -790,15 +784,9 @@ LZWDecodeCompat(TIFF* tif, uint8_t* op0, tmsize_t occ0, uint16_t s)
sp->dec_maxcodep = maxcodep;
if (occ > 0) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at scanline %d (short %I64d bytes)",
- tif->tif_row, (unsigned __int64) occ);
-#else
- TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at scanline %d (short %llu bytes)",
- tif->tif_row, (unsigned long long) occ);
-#endif
+ "Not enough data at scanline %"PRIu32" (short %ld bytes)",
+ tif->tif_row, occ);
return (0);
}
return (1);
diff --git a/libtiff/tif_next.c b/libtiff/tif_next.c
index ef0dc2f9..695fc5d4 100644
--- a/libtiff/tif_next.c
+++ b/libtiff/tif_next.c
@@ -127,8 +127,8 @@ NeXTDecode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
if (npixels >= imagewidth)
break;
if (op_offset >= scanline ) {
- TIFFErrorExt(tif->tif_clientdata, module, "Invalid data for scanline %ld",
- (long) tif->tif_row);
+ TIFFErrorExt(tif->tif_clientdata, module, "Invalid data for scanline %"PRIu32,
+ tif->tif_row);
return (0);
}
if (cc == 0)
@@ -144,8 +144,8 @@ NeXTDecode(TIFF* tif, uint8_t* buf, tmsize_t occ, uint16_t s)
tif->tif_rawcc = cc;
return (1);
bad:
- TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %ld",
- (long) tif->tif_row);
+ TIFFErrorExt(tif->tif_clientdata, module, "Not enough data for scanline %"PRIu32,
+ tif->tif_row);
return (0);
}
@@ -158,7 +158,7 @@ NeXTPreDecode(TIFF* tif, uint16_t s)
if( td->td_bitspersample != 2 )
{
- TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSample = %d",
+ TIFFErrorExt(tif->tif_clientdata, module, "Unsupported BitsPerSample = %"PRIu16,
td->td_bitspersample);
return (0);
}
diff --git a/libtiff/tif_ojpeg.c b/libtiff/tif_ojpeg.c
index 63834e44..66cd275f 100644
--- a/libtiff/tif_ojpeg.c
+++ b/libtiff/tif_ojpeg.c
@@ -641,9 +641,9 @@ OJPEGPrintDir(TIFF* tif, FILE* fd, long flags)
fprintf(fd,"\n");
}
if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGPROC))
- fprintf(fd," JpegProc: %u\n",(unsigned int)sp->jpeg_proc);
+ fprintf(fd," JpegProc: %"PRIu8"\n", sp->jpeg_proc);
if (TIFFFieldSet(tif,FIELD_OJPEG_JPEGRESTARTINTERVAL))
- fprintf(fd," JpegRestartInterval: %u\n",(unsigned int)sp->restart_interval);
+ fprintf(fd," JpegRestartInterval: %"PRIu16"\n", sp->restart_interval);
if (sp->printdir)
(*sp->printdir)(tif, fd, flags);
}
@@ -1027,21 +1027,21 @@ OJPEGSubsamplingCorrect(TIFF* tif)
if (((sp->subsampling_hor!=mh) || (sp->subsampling_ver!=mv)) && (sp->subsampling_force_desubsampling_inside_decompression==0))
{
if (sp->subsampling_tag==0)
- TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data [%d,%d] does not match default values [2,2]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver);
+ TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data [%"PRIu8",%"PRIu8"] does not match default values [2,2]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver);
else
- TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data [%d,%d] does not match subsampling tag values [%d,%d]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver,mh,mv);
+ TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data [%"PRIu8",%"PRIu8"] does not match subsampling tag values [%"PRIu8",%"PRIu8"]; assuming subsampling inside JPEG data is correct",sp->subsampling_hor,sp->subsampling_ver,mh,mv);
}
if (sp->subsampling_force_desubsampling_inside_decompression!=0)
{
if (sp->subsampling_tag==0)
TIFFWarningExt(tif->tif_clientdata,module,"Subsampling tag is not set, yet subsampling inside JPEG data does not match default values [2,2] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression");
else
- TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data does not match subsampling tag values [%d,%d] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression",mh,mv);
+ TIFFWarningExt(tif->tif_clientdata,module,"Subsampling inside JPEG data does not match subsampling tag values [%"PRIu8",%"PRIu8"] (nor any other values allowed in TIFF); assuming subsampling inside JPEG data is correct and desubsampling inside JPEG decompression",mh,mv);
}
if (sp->subsampling_force_desubsampling_inside_decompression==0)
{
if (sp->subsampling_hor<sp->subsampling_ver)
- TIFFWarningExt(tif->tif_clientdata,module,"Subsampling values [%d,%d] are not allowed in TIFF",sp->subsampling_hor,sp->subsampling_ver);
+ TIFFWarningExt(tif->tif_clientdata,module,"Subsampling values [%"PRIu8",%"PRIu8"] are not allowed in TIFF",sp->subsampling_hor,sp->subsampling_ver);
}
}
sp->subsamplingcorrect_done=1;
@@ -1081,7 +1081,7 @@ OJPEGReadHeaderInfo(TIFF* tif)
{
if (tif->tif_dir.td_samplesperpixel!=3)
{
- TIFFErrorExt(tif->tif_clientdata,module,"SamplesPerPixel %d not supported for this compression scheme",sp->samples_per_pixel);
+ TIFFErrorExt(tif->tif_clientdata,module,"SamplesPerPixel %"PRIu8" not supported for this compression scheme",sp->samples_per_pixel);
return(0);
}
sp->samples_per_pixel=3;
@@ -1266,8 +1266,8 @@ OJPEGWriteHeaderInfo(TIFF* tif)
return(0);
if(sp->libjpeg_jpeg_decompress_struct.image_width != sp->strile_width ) {
TIFFErrorExt(tif->tif_clientdata,module,
- "jpeg_start_decompress() returned image_width = %d, "
- "expected %d",
+ "jpeg_start_decompress() returned image_width = %u, "
+ "expected %"PRIu32,
sp->libjpeg_jpeg_decompress_struct.image_width,
sp->strile_width);
return 0;
@@ -1276,7 +1276,7 @@ OJPEGWriteHeaderInfo(TIFF* tif)
sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor != sp->subsampling_ver) {
TIFFErrorExt(tif->tif_clientdata,module,
"jpeg_start_decompress() returned max_h_samp_factor = %d "
- "and max_v_samp_factor = %d, expected %d and %d",
+ "and max_v_samp_factor = %d, expected %"PRIu8" and %"PRIu8,
sp->libjpeg_jpeg_decompress_struct.max_h_samp_factor,
sp->libjpeg_jpeg_decompress_struct.max_v_samp_factor,
sp->subsampling_hor,
@@ -1401,7 +1401,7 @@ OJPEGReadHeaderInfoSec(TIFF* tif)
return(0);
break;
default:
- TIFFErrorExt(tif->tif_clientdata,module,"Unknown marker type %d in JPEG data",m);
+ TIFFErrorExt(tif->tif_clientdata,module,"Unknown marker type %"PRIu8" in JPEG data", m);
return(0);
}
} while(m!=JPEG_MARKER_SOS);
diff --git a/libtiff/tif_open.c b/libtiff/tif_open.c
index 7b61d4d3..9724162e 100644
--- a/libtiff/tif_open.c
+++ b/libtiff/tif_open.c
@@ -373,11 +373,11 @@ TIFFClientOpen(
#endif
) {
TIFFErrorExt(tif->tif_clientdata, name,
- "Not a TIFF or MDI file, bad magic number %d (0x%x)",
+ "Not a TIFF or MDI file, bad magic number %"PRIu16" (0x%"PRIx16")",
#else
) {
TIFFErrorExt(tif->tif_clientdata, name,
- "Not a TIFF file, bad magic number %d (0x%x)",
+ "Not a TIFF file, bad magic number %"PRIu16" (0x%"PRIx16")",
#endif
tif->tif_header.common.tiff_magic,
tif->tif_header.common.tiff_magic);
@@ -397,7 +397,7 @@ TIFFClientOpen(
if ((tif->tif_header.common.tiff_version != TIFF_VERSION_CLASSIC)&&
(tif->tif_header.common.tiff_version != TIFF_VERSION_BIG)) {
TIFFErrorExt(tif->tif_clientdata, name,
- "Not a TIFF file, bad version number %d (0x%x)",
+ "Not a TIFF file, bad version number %"PRIu16" (0x%"PRIx16")",
tif->tif_header.common.tiff_version,
tif->tif_header.common.tiff_version);
goto bad;
@@ -424,7 +424,7 @@ TIFFClientOpen(
if (tif->tif_header.big.tiff_offsetsize != 8)
{
TIFFErrorExt(tif->tif_clientdata, name,
- "Not a TIFF file, bad BigTIFF offsetsize %d (0x%x)",
+ "Not a TIFF file, bad BigTIFF offsetsize %"PRIu16" (0x%"PRIx16")",
tif->tif_header.big.tiff_offsetsize,
tif->tif_header.big.tiff_offsetsize);
goto bad;
@@ -432,7 +432,7 @@ TIFFClientOpen(
if (tif->tif_header.big.tiff_unused != 0)
{
TIFFErrorExt(tif->tif_clientdata, name,
- "Not a TIFF file, bad BigTIFF unused %d (0x%x)",
+ "Not a TIFF file, bad BigTIFF unused %"PRIu16" (0x%"PRIx16")",
tif->tif_header.big.tiff_unused,
tif->tif_header.big.tiff_unused);
goto bad;
diff --git a/libtiff/tif_packbits.c b/libtiff/tif_packbits.c
index 01b6a23c..010c09bf 100644
--- a/libtiff/tif_packbits.c
+++ b/libtiff/tif_packbits.c
@@ -238,8 +238,8 @@ PackBitsDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s)
if( occ < (tmsize_t)n )
{
TIFFWarningExt(tif->tif_clientdata, module,
- "Discarding %lu bytes to avoid buffer overrun",
- (unsigned long) ((tmsize_t)n - occ));
+ "Discarding %"PRId64" bytes to avoid buffer overrun",
+ (tmsize_t)n - occ);
n = (long)occ;
}
if( cc == 0 )
@@ -257,8 +257,8 @@ PackBitsDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s)
if (occ < (tmsize_t)(n + 1))
{
TIFFWarningExt(tif->tif_clientdata, module,
- "Discarding %lu bytes to avoid buffer overrun",
- (unsigned long) ((tmsize_t)n - occ + 1));
+ "Discarding %"PRId64" bytes to avoid buffer overrun",
+ (tmsize_t)n - occ + 1);
n = (long)occ - 1;
}
if (cc < (tmsize_t) (n+1))
@@ -276,8 +276,8 @@ PackBitsDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s)
tif->tif_rawcc = cc;
if (occ > 0) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data for scanline %lu",
- (unsigned long) tif->tif_row);
+ "Not enough data for scanline %"PRIu32,
+ tif->tif_row);
return (0);
}
return (1);
diff --git a/libtiff/tif_pixarlog.c b/libtiff/tif_pixarlog.c
index a3846aab..9686b7c5 100644
--- a/libtiff/tif_pixarlog.c
+++ b/libtiff/tif_pixarlog.c
@@ -706,7 +706,7 @@ PixarLogSetupDecode(TIFF* tif)
sp->tbuf = NULL;
sp->tbuf_size = 0;
TIFFErrorExt(tif->tif_clientdata, module,
- "PixarLog compression can't handle bits depth/data format combination (depth: %d)",
+ "PixarLog compression can't handle bits depth/data format combination (depth: %"PRIu16")",
td->td_bitspersample);
return (0);
}
@@ -774,7 +774,7 @@ PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s)
break;
default:
TIFFErrorExt(tif->tif_clientdata, module,
- "%d bit input not supported in PixarLog",
+ "%"PRIu16" bit input not supported in PixarLog",
td->td_bitspersample);
return 0;
}
@@ -811,8 +811,8 @@ PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s)
}
if (state == Z_DATA_ERROR) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Decoding error at scanline %lu, %s",
- (unsigned long) tif->tif_row, sp->stream.msg ? sp->stream.msg : "(null)");
+ "Decoding error at scanline %"PRIu32", %s",
+ tif->tif_row, sp->stream.msg ? sp->stream.msg : "(null)");
return (0);
}
if (state != Z_OK) {
@@ -825,8 +825,8 @@ PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s)
/* hopefully, we got all the bytes we needed */
if (sp->stream.avail_out != 0) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Not enough data at scanline %lu (short %" PRIu64 " bytes)",
- (unsigned long) tif->tif_row, (uint64_t) sp->stream.avail_out);
+ "Not enough data at scanline %"PRIu32" (short %u bytes)",
+ tif->tif_row, sp->stream.avail_out);
return (0);
}
@@ -845,8 +845,8 @@ PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s)
*/
if (nsamples % llen) {
TIFFWarningExt(tif->tif_clientdata, module,
- "stride %lu is not a multiple of sample count, "
- "%lu, data truncated.", (unsigned long) llen, (unsigned long) nsamples);
+ "stride %d is not a multiple of sample count, "
+ "%"PRId64", data truncated.", llen, nsamples);
nsamples -= nsamples % llen;
}
@@ -884,7 +884,7 @@ PixarLogDecode(TIFF* tif, uint8_t* op, tmsize_t occ, uint16_t s)
break;
default:
TIFFErrorExt(tif->tif_clientdata, module,
- "Unsupported bits/sample: %d",
+ "Unsupported bits/sample: %"PRIu16,
td->td_bitspersample);
return (0);
}
@@ -917,7 +917,7 @@ PixarLogSetupEncode(TIFF* tif)
if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN)
sp->user_datafmt = PixarLogGuessDataFmt(td);
if (sp->user_datafmt == PIXARLOGDATAFMT_UNKNOWN) {
- TIFFErrorExt(tif->tif_clientdata, module, "PixarLog compression can't handle %d bit linear encodings", td->td_bitspersample);
+ TIFFErrorExt(tif->tif_clientdata, module, "PixarLog compression can't handle %"PRIu16" bit linear encodings", td->td_bitspersample);
return (0);
}
@@ -1140,7 +1140,7 @@ PixarLogEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s)
break;
default:
TIFFErrorExt(tif->tif_clientdata, module,
- "%d bit input not supported in PixarLog",
+ "%"PRIu16" bit input not supported in PixarLog",
td->td_bitspersample);
return 0;
}
@@ -1173,7 +1173,7 @@ PixarLogEncode(TIFF* tif, uint8_t* bp, tmsize_t cc, uint16_t s)
break;
default:
TIFFErrorExt(tif->tif_clientdata, module,
- "%d bit input not supported in PixarLog",
+ "%"PRIu16" bit input not supported in PixarLog",
td->td_bitspersample);
return 0;
}
diff --git a/libtiff/tif_predict.c b/libtiff/tif_predict.c
index 30c674c5..4aa4af69 100644
--- a/libtiff/tif_predict.c
+++ b/libtiff/tif_predict.c
@@ -66,7 +66,7 @@ PredictorSetup(TIFF* tif)
&& td->td_bitspersample != 16
&& td->td_bitspersample != 32) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Horizontal differencing \"Predictor\" not supported with %d-bit samples",
+ "Horizontal differencing \"Predictor\" not supported with %"PRIu16"-bit samples",
td->td_bitspersample);
return 0;
}
@@ -74,7 +74,7 @@ PredictorSetup(TIFF* tif)
case PREDICTOR_FLOATINGPOINT:
if (td->td_sampleformat != SAMPLEFORMAT_IEEEFP) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Floating point \"Predictor\" not supported with %d data format",
+ "Floating point \"Predictor\" not supported with %"PRIu16" data format",
td->td_sampleformat);
return 0;
}
@@ -83,7 +83,7 @@ PredictorSetup(TIFF* tif)
&& td->td_bitspersample != 32
&& td->td_bitspersample != 64) { /* Should 64 be allowed? */
TIFFErrorExt(tif->tif_clientdata, module,
- "Floating point \"Predictor\" not supported with %d-bit samples",
+ "Floating point \"Predictor\" not supported with %"PRIu16"-bit samples",
td->td_bitspersample);
return 0;
}
diff --git a/libtiff/tif_print.c b/libtiff/tif_print.c
index 53c87492..347dbdaf 100644
--- a/libtiff/tif_print.c
+++ b/libtiff/tif_print.c
@@ -73,54 +73,35 @@ _TIFFPrintField(FILE* fd, const TIFFField *fip,
for(j = 0; j < value_count; j++) {
if(fip->field_type == TIFF_BYTE)
- fprintf(fd, "%u", ((uint8_t *) raw_data)[j]);
+ fprintf(fd, "%"PRIu8, ((uint8_t *) raw_data)[j]);
else if(fip->field_type == TIFF_UNDEFINED)
- fprintf(fd, "0x%x",
- (unsigned int) ((unsigned char *) raw_data)[j]);
+ fprintf(fd, "0x%"PRIx8, ((uint8_t *) raw_data)[j]);
else if(fip->field_type == TIFF_SBYTE)
- fprintf(fd, "%d", ((int8_t *) raw_data)[j]);
+ fprintf(fd, "%"PRId8, ((int8_t *) raw_data)[j]);
else if(fip->field_type == TIFF_SHORT)
- fprintf(fd, "%u", ((uint16_t *) raw_data)[j]);
+ fprintf(fd, "%"PRIu16, ((uint16_t *) raw_data)[j]);
else if(fip->field_type == TIFF_SSHORT)
- fprintf(fd, "%d", ((int16_t *) raw_data)[j]);
+ fprintf(fd, "%"PRId16, ((int16_t *) raw_data)[j]);
else if(fip->field_type == TIFF_LONG)
- fprintf(fd, "%lu",
- (unsigned long)((uint32_t *) raw_data)[j]);
+ fprintf(fd, "%"PRIu32, ((uint32_t *) raw_data)[j]);
else if(fip->field_type == TIFF_SLONG)
- fprintf(fd, "%ld", (long)((int32_t *) raw_data)[j]);
+ fprintf(fd, "%"PRId32, ((int32_t *) raw_data)[j]);
else if(fip->field_type == TIFF_IFD)
- fprintf(fd, "0x%lx",
- (unsigned long)((uint32_t *) raw_data)[j]);
+ fprintf(fd, "0x%"PRIx32, ((uint32_t *) raw_data)[j]);
else if(fip->field_type == TIFF_RATIONAL
|| fip->field_type == TIFF_SRATIONAL
|| fip->field_type == TIFF_FLOAT)
fprintf(fd, "%f", ((float *) raw_data)[j]);
else if(fip->field_type == TIFF_LONG8)
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- fprintf(fd, "%I64u",
- (unsigned __int64)((uint64_t *) raw_data)[j]);
-#else
- fprintf(fd, "%llu",
- (unsigned long long)((uint64_t *) raw_data)[j]);
-#endif
+ fprintf(fd, "%"PRIu64, ((uint64_t *) raw_data)[j]);
else if(fip->field_type == TIFF_SLONG8)
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- fprintf(fd, "%I64d", (__int64)((int64_t *) raw_data)[j]);
-#else
- fprintf(fd, "%lld", (long long)((int64_t *) raw_data)[j]);
-#endif
+ fprintf(fd, "%"PRId64, ((int64_t *) raw_data)[j]);
else if(fip->field_type == TIFF_IFD8)
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- fprintf(fd, "0x%I64x",
- (unsigned __int64)((uint64_t *) raw_data)[j]);
-#else
- fprintf(fd, "0x%llx",
- (unsigned long long)((uint64_t *) raw_data)[j]);
-#endif
+ fprintf(fd, "0x%"PRIx64, ((uint64_t *) raw_data)[j]);
else if(fip->field_type == TIFF_FLOAT)
fprintf(fd, "%f", ((float *)raw_data)[j]);
else if(fip->field_type == TIFF_DOUBLE)
- fprintf(fd, "%f", ((double *) raw_data)[j]);
+ fprintf(fd, "%lf", ((double *) raw_data)[j]);
else if(fip->field_type == TIFF_ASCII) {
fprintf(fd, "%s", (char *) raw_data);
break;
@@ -158,7 +139,7 @@ _TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32_t tag,
fprintf(fd, "CMYK\n");
break;
default:
- fprintf(fd, "%u (0x%x)\n",
+ fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n",
*((uint16_t*)raw_data),
*((uint16_t*)raw_data));
break;
@@ -169,7 +150,7 @@ _TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32_t tag,
case TIFFTAG_DOTRANGE:
if (value_count == 2 && fip->field_type == TIFF_SHORT) {
- fprintf(fd, " Dot Range: %u-%u\n",
+ fprintf(fd, " Dot Range: %"PRIu16"-%"PRIu16"\n",
((uint16_t*)raw_data)[0], ((uint16_t*)raw_data)[1]);
return 1;
}
@@ -199,18 +180,18 @@ _TIFFPrettyPrintField(TIFF* tif, const TIFFField *fip, FILE* fd, uint32_t tag,
* defined as array of LONG values.
*/
fprintf(fd,
- " RichTIFFIPTC Data: <present>, %lu bytes\n",
- (unsigned long) value_count * 4);
+ " RichTIFFIPTC Data: <present>, %"PRIu32" bytes\n",
+ value_count * 4u);
return 1;
case TIFFTAG_PHOTOSHOP:
- fprintf(fd, " Photoshop Data: <present>, %lu bytes\n",
- (unsigned long) value_count);
+ fprintf(fd, " Photoshop Data: <present>, %"PRIu32" bytes\n",
+ value_count);
return 1;
case TIFFTAG_ICCPROFILE:
- fprintf(fd, " ICC Profile: <present>, %lu bytes\n",
- (unsigned long) value_count);
+ fprintf(fd, " ICC Profile: <present>, %"PRIu32" bytes\n",
+ value_count);
return 1;
case TIFFTAG_STONITS:
@@ -237,15 +218,9 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
char *sep;
long l, n;
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- fprintf(fd, "TIFF Directory at offset 0x%I64x (%I64u)\n",
- (unsigned __int64) tif->tif_diroff,
- (unsigned __int64) tif->tif_diroff);
-#else
- fprintf(fd, "TIFF Directory at offset 0x%llx (%llu)\n",
- (unsigned long long) tif->tif_diroff,
- (unsigned long long) tif->tif_diroff);
-#endif
+ fprintf(fd, "TIFF Directory at offset 0x%"PRIu64" (%"PRIx64")\n",
+ tif->tif_diroff,
+ tif->tif_diroff);
if (TIFFFieldSet(tif,FIELD_SUBFILETYPE)) {
fprintf(fd, " Subfile Type:");
sep = " ";
@@ -259,23 +234,23 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
}
if (td->td_subfiletype & FILETYPE_MASK)
fprintf(fd, "%stransparency mask", sep);
- fprintf(fd, " (%lu = 0x%lx)\n",
- (unsigned long) td->td_subfiletype, (long) td->td_subfiletype);
+ fprintf(fd, " (%"PRIu32" = 0x%"PRIx32")\n",
+ td->td_subfiletype, td->td_subfiletype);
}
if (TIFFFieldSet(tif,FIELD_IMAGEDIMENSIONS)) {
- fprintf(fd, " Image Width: %lu Image Length: %lu",
- (unsigned long) td->td_imagewidth, (unsigned long) td->td_imagelength);
+ fprintf(fd, " Image Width: %"PRIu32" Image Length: %"PRIu32,
+ td->td_imagewidth, td->td_imagelength);
if (TIFFFieldSet(tif,FIELD_IMAGEDEPTH))
- fprintf(fd, " Image Depth: %lu",
- (unsigned long) td->td_imagedepth);
+ fprintf(fd, " Image Depth: %"PRIu32,
+ td->td_imagedepth);
fprintf(fd, "\n");
}
if (TIFFFieldSet(tif,FIELD_TILEDIMENSIONS)) {
- fprintf(fd, " Tile Width: %lu Tile Length: %lu",
- (unsigned long) td->td_tilewidth, (unsigned long) td->td_tilelength);
+ fprintf(fd, " Tile Width: %"PRIu32" Tile Length: %"PRIu32,
+ td->td_tilewidth, td->td_tilelength);
if (TIFFFieldSet(tif,FIELD_TILEDEPTH))
- fprintf(fd, " Tile Depth: %lu",
- (unsigned long) td->td_tiledepth);
+ fprintf(fd, " Tile Depth: %"PRIu32,
+ td->td_tiledepth);
fprintf(fd, "\n");
}
if (TIFFFieldSet(tif,FIELD_RESOLUTION)) {
@@ -293,7 +268,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
fprintf(fd, " pixels/cm");
break;
default:
- fprintf(fd, " (unit %u = 0x%x)",
+ fprintf(fd, " (unit %"PRIu16" = 0x%"PRIx16")",
td->td_resolutionunit,
td->td_resolutionunit);
break;
@@ -305,7 +280,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
fprintf(fd, " Position: %g, %g\n",
td->td_xposition, td->td_yposition);
if (TIFFFieldSet(tif,FIELD_BITSPERSAMPLE))
- fprintf(fd, " Bits/Sample: %u\n", td->td_bitspersample);
+ fprintf(fd, " Bits/Sample: %"PRIu16"\n", td->td_bitspersample);
if (TIFFFieldSet(tif,FIELD_SAMPLEFORMAT)) {
fprintf(fd, " Sample Format: ");
switch (td->td_sampleformat) {
@@ -328,7 +303,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
fprintf(fd, "complex IEEE floating point\n");
break;
default:
- fprintf(fd, "%u (0x%x)\n",
+ fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n",
td->td_sampleformat, td->td_sampleformat);
break;
}
@@ -339,7 +314,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
if (c)
fprintf(fd, "%s\n", c->name);
else
- fprintf(fd, "%u (0x%x)\n",
+ fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n",
td->td_compression, td->td_compression);
}
if (TIFFFieldSet(tif,FIELD_PHOTOMETRIC)) {
@@ -355,7 +330,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
fprintf(fd, "CIE Log2(L) (u',v')\n");
break;
default:
- fprintf(fd, "%u (0x%x)\n",
+ fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n",
td->td_photometric, td->td_photometric);
break;
}
@@ -363,7 +338,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
}
if (TIFFFieldSet(tif,FIELD_EXTRASAMPLES) && td->td_extrasamples) {
uint16_t i;
- fprintf(fd, " Extra Samples: %u<", td->td_extrasamples);
+ fprintf(fd, " Extra Samples: %"PRIu16"<", td->td_extrasamples);
sep = "";
for (i = 0; i < td->td_extrasamples; i++) {
switch (td->td_sampleinfo[i]) {
@@ -377,7 +352,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
fprintf(fd, "%sunassoc-alpha", sep);
break;
default:
- fprintf(fd, "%s%u (0x%x)", sep,
+ fprintf(fd, "%s%"PRIu16" (0x%"PRIx16")", sep,
td->td_sampleinfo[i], td->td_sampleinfo[i]);
break;
}
@@ -415,7 +390,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
fprintf(fd, "error diffused\n");
break;
default:
- fprintf(fd, "%u (0x%x)\n",
+ fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n",
td->td_threshholding, td->td_threshholding);
break;
}
@@ -430,14 +405,14 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
fprintf(fd, "lsb-to-msb\n");
break;
default:
- fprintf(fd, "%u (0x%x)\n",
+ fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n",
td->td_fillorder, td->td_fillorder);
break;
}
}
if (TIFFFieldSet(tif,FIELD_YCBCRSUBSAMPLING))
{
- fprintf(fd, " YCbCr Subsampling: %u, %u\n",
+ fprintf(fd, " YCbCr Subsampling: %"PRIu16", %"PRIu16"\n",
td->td_ycbcrsubsampling[0], td->td_ycbcrsubsampling[1] );
}
if (TIFFFieldSet(tif,FIELD_YCBCRPOSITIONING)) {
@@ -450,35 +425,35 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
fprintf(fd, "cosited\n");
break;
default:
- fprintf(fd, "%u (0x%x)\n",
+ fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n",
td->td_ycbcrpositioning, td->td_ycbcrpositioning);
break;
}
}
if (TIFFFieldSet(tif,FIELD_HALFTONEHINTS))
- fprintf(fd, " Halftone Hints: light %u dark %u\n",
+ fprintf(fd, " Halftone Hints: light %"PRIu16" dark %"PRIu16"\n",
td->td_halftonehints[0], td->td_halftonehints[1]);
if (TIFFFieldSet(tif,FIELD_ORIENTATION)) {
fprintf(fd, " Orientation: ");
if (td->td_orientation < NORIENTNAMES)
fprintf(fd, "%s\n", orientNames[td->td_orientation]);
else
- fprintf(fd, "%u (0x%x)\n",
+ fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n",
td->td_orientation, td->td_orientation);
}
if (TIFFFieldSet(tif,FIELD_SAMPLESPERPIXEL))
- fprintf(fd, " Samples/Pixel: %u\n", td->td_samplesperpixel);
+ fprintf(fd, " Samples/Pixel: %"PRIx16"\n", td->td_samplesperpixel);
if (TIFFFieldSet(tif,FIELD_ROWSPERSTRIP)) {
fprintf(fd, " Rows/Strip: ");
if (td->td_rowsperstrip == (uint32_t) -1)
fprintf(fd, "(infinite)\n");
else
- fprintf(fd, "%lu\n", (unsigned long) td->td_rowsperstrip);
+ fprintf(fd, "%"PRIu32"\n", td->td_rowsperstrip);
}
if (TIFFFieldSet(tif,FIELD_MINSAMPLEVALUE))
- fprintf(fd, " Min Sample Value: %u\n", td->td_minsamplevalue);
+ fprintf(fd, " Min Sample Value: %"PRIu16"\n", td->td_minsamplevalue);
if (TIFFFieldSet(tif,FIELD_MAXSAMPLEVALUE))
- fprintf(fd, " Max Sample Value: %u\n", td->td_maxsamplevalue);
+ fprintf(fd, " Max Sample Value: %"PRIu16"\n", td->td_maxsamplevalue);
if (TIFFFieldSet(tif,FIELD_SMINSAMPLEVALUE)) {
int i;
int count = (tif->tif_flags & TIFF_PERSAMPLE) ? td->td_samplesperpixel : 1;
@@ -505,13 +480,13 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
fprintf(fd, "separate image planes\n");
break;
default:
- fprintf(fd, "%u (0x%x)\n",
+ fprintf(fd, "%"PRIu16" (0x%"PRIx16")\n",
td->td_planarconfig, td->td_planarconfig);
break;
}
}
if (TIFFFieldSet(tif,FIELD_PAGENUMBER))
- fprintf(fd, " Page Number: %u-%u\n",
+ fprintf(fd, " Page Number: %"PRIu16"-%"PRIu16"\n",
td->td_pagenumber[0], td->td_pagenumber[1]);
if (TIFFFieldSet(tif,FIELD_COLORMAP)) {
fprintf(fd, " Color Map: ");
@@ -519,7 +494,7 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
fprintf(fd, "\n");
n = 1L<<td->td_bitspersample;
for (l = 0; l < n; l++)
- fprintf(fd, " %5ld: %5u %5u %5u\n",
+ fprintf(fd, " %5ld: %5"PRIu16" %5"PRIu16" %5"PRIu16"\n",
l,
td->td_colormap[0][l],
td->td_colormap[1][l],
@@ -542,10 +517,10 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
n = 1L<<td->td_bitspersample;
for (l = 0; l < n; l++) {
uint16_t i;
- fprintf(fd, " %2ld: %5u",
+ fprintf(fd, " %2ld: %5"PRIu16,
l, td->td_transferfunction[0][l]);
for (i = 1; i < td->td_samplesperpixel - td->td_extrasamples && i < 3; i++)
- fprintf(fd, " %5u",
+ fprintf(fd, " %5"PRIu16,
td->td_transferfunction[i][l]);
fputc('\n', fd);
}
@@ -556,13 +531,8 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
uint16_t i;
fprintf(fd, " SubIFD Offsets:");
for (i = 0; i < td->td_nsubifd; i++)
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- fprintf(fd, " %5I64u",
- (unsigned __int64) td->td_subifd[i]);
-#else
- fprintf(fd, " %5llu",
- (unsigned long long) td->td_subifd[i]);
-#endif
+ fprintf(fd, " %5"PRIu64,
+ td->td_subifd[i]);
fputc('\n', fd);
}
@@ -656,21 +626,14 @@ TIFFPrintDirectory(TIFF* tif, FILE* fd, long flags)
TIFFFieldSet(tif,FIELD_STRIPOFFSETS)) {
uint32_t s;
- fprintf(fd, " %lu %s:\n",
- (unsigned long) td->td_nstrips,
+ fprintf(fd, " %"PRIu32" %s:\n",
+ td->td_nstrips,
isTiled(tif) ? "Tiles" : "Strips");
for (s = 0; s < td->td_nstrips; s++)
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- fprintf(fd, " %3lu: [%8I64u, %8I64u]\n",
- (unsigned long) s,
- (unsigned __int64) TIFFGetStrileOffset(tif, s),
- (unsigned __int64) TIFFGetStrileByteCount(tif, s));
-#else
- fprintf(fd, " %3lu: [%8llu, %8llu]\n",
- (unsigned long) s,
- (unsigned long long) TIFFGetStrileOffset(tif, s),
- (unsigned long long) TIFFGetStrileByteCount(tif, s));
-#endif
+ fprintf(fd, " %3"PRIu32": [%8"PRIu64", %8"PRIu64"]\n",
+ s,
+ TIFFGetStrileOffset(tif, s),
+ TIFFGetStrileByteCount(tif, s));
}
}
diff --git a/libtiff/tif_read.c b/libtiff/tif_read.c
index 748fb2d5..8b174d9a 100644
--- a/libtiff/tif_read.c
+++ b/libtiff/tif_read.c
@@ -109,8 +109,8 @@ static int TIFFReadAndRealloc(TIFF* tif, tmsize_t size,
if( new_rawdata == 0 )
{
TIFFErrorExt(tif->tif_clientdata, module,
- "No space for data buffer at scanline %lu",
- (unsigned long) tif->tif_row);
+ "No space for data buffer at scanline %"PRIu32,
+ tif->tif_row);
_TIFFfree(tif->tif_rawdata);
tif->tif_rawdata = 0;
tif->tif_rawdatasize = 0;
@@ -130,49 +130,26 @@ static int TIFFReadAndRealloc(TIFF* tif, tmsize_t size,
if (bytes_read != to_read) {
memset( tif->tif_rawdata + rawdata_offset + already_read, 0,
tif->tif_rawdatasize - rawdata_offset - already_read );
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
if( is_strip )
{
TIFFErrorExt(tif->tif_clientdata, module,
- "Read error at scanline %lu; got %I64u bytes, "
- "expected %I64u",
- (unsigned long) tif->tif_row,
- (unsigned __int64) already_read,
- (unsigned __int64) size);
+ "Read error at scanline %"PRIu32"; got %"PRId64" bytes, "
+ "expected %"PRId64,
+ tif->tif_row,
+ already_read,
+ size);
}
else
{
TIFFErrorExt(tif->tif_clientdata, module,
- "Read error at row %lu, col %lu, tile %lu; "
- "got %I64u bytes, expected %I64u",
- (unsigned long) tif->tif_row,
- (unsigned long) tif->tif_col,
- (unsigned long) strip_or_tile,
- (unsigned __int64) already_read,
- (unsigned __int64) size);
+ "Read error at row %"PRIu32", col %"PRIu32", tile %"PRIu32"; "
+ "got %"PRId64" bytes, expected %"PRId64"",
+ tif->tif_row,
+ tif->tif_col,
+ strip_or_tile,
+ already_read,
+ size);
}
-#else
- if( is_strip )
- {
- TIFFErrorExt(tif->tif_clientdata, module,
- "Read error at scanline %lu; got %llu bytes, "
- "expected %llu",
- (unsigned long) tif->tif_row,
- (unsigned long long) already_read,
- (unsigned long long) size);
- }
- else
- {
- TIFFErrorExt(tif->tif_clientdata, module,
- "Read error at row %lu, col %lu, tile %lu; "
- "got %llu bytes, expected %llu",
- (unsigned long) tif->tif_row,
- (unsigned long) tif->tif_col,
- (unsigned long) strip_or_tile,
- (unsigned long long) already_read,
- (unsigned long long) size);
- }
-#endif
return 0;
}
}
@@ -211,8 +188,8 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
tif->tif_curstrip = NOSTRIP;
if ((tif->tif_flags & TIFF_MYBUFFER) == 0) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Data buffer too small to hold part of strip %lu",
- (unsigned long) strip);
+ "Data buffer too small to hold part of strip %d",
+ strip);
return (0);
}
}
@@ -246,8 +223,8 @@ TIFFFillStripPartial( TIFF *tif, int strip, tmsize_t read_ahead, int restart )
if (!SeekOK(tif, read_offset)) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Seek error at scanline %lu, strip %lu",
- (unsigned long) tif->tif_row, (unsigned long) strip);
+ "Seek error at scanline %"PRIu32", strip %d",
+ tif->tif_row, strip);
return 0;
}
@@ -338,16 +315,16 @@ TIFFSeek(TIFF* tif, uint32_t row, uint16_t sample )
*/
if (row >= td->td_imagelength) { /* out of range */
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
- "%lu: Row out of range, max %lu",
- (unsigned long) row,
- (unsigned long) td->td_imagelength);
+ "%"PRIu32": Row out of range, max %"PRIu32"",
+ row,
+ td->td_imagelength);
return (0);
}
if (td->td_planarconfig == PLANARCONFIG_SEPARATE) {
if (sample >= td->td_samplesperpixel) {
TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
- "%lu: Sample out of range, max %lu",
- (unsigned long) sample, (unsigned long) td->td_samplesperpixel);
+ "%"PRIu16": Sample out of range, max %"PRIu16"",
+ sample, td->td_samplesperpixel);
return (0);
}
strip = (uint32_t)sample * td->td_stripsperimage + row / td->td_rowsperstrip;
@@ -499,8 +476,8 @@ static tmsize_t TIFFReadEncodedStripGetStripSize(TIFF* tif, uint32_t strip, uint
if (strip>=td->td_nstrips)
{
TIFFErrorExt(tif->tif_clientdata,module,
- "%lu: Strip out of range, max %lu",(unsigned long)strip,
- (unsigned long)td->td_nstrips);
+ "%"PRIu32": Strip out of range, max %"PRIu32, strip,
+ td->td_nstrips);
return((tmsize_t)(-1));
}
@@ -615,25 +592,17 @@ TIFFReadRawStrip1(TIFF* tif, uint32_t strip, void* buf, tmsize_t size,
if (!SeekOK(tif, TIFFGetStrileOffset(tif, strip))) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Seek error at scanline %lu, strip %lu",
- (unsigned long) tif->tif_row, (unsigned long) strip);
+ "Seek error at scanline %"PRIu32", strip %"PRIu32,
+ tif->tif_row, strip);
return ((tmsize_t)(-1));
}
cc = TIFFReadFile(tif, buf, size);
if (cc != size) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- TIFFErrorExt(tif->tif_clientdata, module,
- "Read error at scanline %lu; got %I64u bytes, expected %I64u",
- (unsigned long) tif->tif_row,
- (unsigned __int64) cc,
- (unsigned __int64) size);
-#else
TIFFErrorExt(tif->tif_clientdata, module,
- "Read error at scanline %lu; got %llu bytes, expected %llu",
- (unsigned long) tif->tif_row,
- (unsigned long long) cc,
- (unsigned long long) size);
-#endif
+ "Read error at scanline %"PRIu32"; got %"PRId64" bytes, expected %"PRId64,
+ tif->tif_row,
+ cc,
+ size);
return ((tmsize_t)(-1));
}
} else {
@@ -657,21 +626,12 @@ TIFFReadRawStrip1(TIFF* tif, uint32_t strip, void* buf, tmsize_t size,
n=size;
}
if (n!=size) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
- "Read error at scanline %lu, strip %lu; got %I64u bytes, expected %I64u",
- (unsigned long) tif->tif_row,
- (unsigned long) strip,
- (unsigned __int64) n,
- (unsigned __int64) size);
-#else
- TIFFErrorExt(tif->tif_clientdata, module,
- "Read error at scanline %lu, strip %lu; got %llu bytes, expected %llu",
- (unsigned long) tif->tif_row,
- (unsigned long) strip,
- (unsigned long long) n,
- (unsigned long long) size);
-#endif
+ "Read error at scanline %"PRIu32", strip %"PRIu32"; got %"PRId64" bytes, expected %"PRId64,
+ tif->tif_row,
+ strip,
+ n,
+ size);
return ((tmsize_t)(-1));
}
_TIFFmemcpy(buf, tif->tif_base + ma,
@@ -691,17 +651,17 @@ TIFFReadRawStripOrTile2(TIFF* tif, uint32_t strip_or_tile, int is_strip,
if( is_strip )
{
TIFFErrorExt(tif->tif_clientdata, module,
- "Seek error at scanline %lu, strip %lu",
- (unsigned long) tif->tif_row,
- (unsigned long) strip_or_tile);
+ "Seek error at scanline %"PRIu32", strip %"PRIu32,
+ tif->tif_row,
+ strip_or_tile);
}
else
{
TIFFErrorExt(tif->tif_clientdata, module,
- "Seek error at row %lu, col %lu, tile %lu",
- (unsigned long) tif->tif_row,
- (unsigned long) tif->tif_col,
- (unsigned long) strip_or_tile);
+ "Seek error at row %"PRIu32", col %"PRIu32", tile %"PRIu32,
+ tif->tif_row,
+ tif->tif_col,
+ strip_or_tile);
}
return ((tmsize_t)(-1));
}
@@ -730,9 +690,9 @@ TIFFReadRawStrip(TIFF* tif, uint32_t strip, void* buf, tmsize_t size)
return ((tmsize_t)(-1));
if (strip >= td->td_nstrips) {
TIFFErrorExt(tif->tif_clientdata, module,
- "%lu: Strip out of range, max %lu",
- (unsigned long) strip,
- (unsigned long) td->td_nstrips);
+ "%"PRIu32": Strip out of range, max %"PRIu32,
+ strip,
+ td->td_nstrips);
return ((tmsize_t)(-1));
}
if (tif->tif_flags&TIFF_NOREADRAW)
@@ -772,17 +732,10 @@ TIFFFillStrip(TIFF* tif, uint32_t strip)
{
uint64_t bytecount = TIFFGetStrileByteCount(tif, strip);
if( bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX ) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- TIFFErrorExt(tif->tif_clientdata, module,
- "Invalid strip byte count %I64u, strip %lu",
- (unsigned __int64) bytecount,
- (unsigned long) strip);
-#else
TIFFErrorExt(tif->tif_clientdata, module,
- "Invalid strip byte count %llu, strip %lu",
- (unsigned long long) bytecount,
- (unsigned long) strip);
-#endif
+ "Invalid strip byte count %"PRIu64", strip %"PRIu32,
+ bytecount,
+ strip);
return (0);
}
@@ -800,19 +753,11 @@ TIFFFillStrip(TIFF* tif, uint32_t strip)
uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096;
if( newbytecount == 0 || newbytecount > (uint64_t)TIFF_INT64_MAX )
{
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- TIFFWarningExt(tif->tif_clientdata, module,
- "Too large strip byte count %I64u, strip %lu. Limiting to %I64u",
- (unsigned __int64) bytecount,
- (unsigned long) strip,
- (unsigned __int64) newbytecount);
-#else
TIFFErrorExt(tif->tif_clientdata, module,
- "Too large strip byte count %llu, strip %lu. Limiting to %llu",
- (unsigned long long) bytecount,
- (unsigned long) strip,
- (unsigned long long) newbytecount);
-#endif
+ "Too large strip byte count %"PRIu64", strip %"PRIu32". Limiting to %"PRIu64,
+ bytecount,
+ strip,
+ newbytecount);
bytecount = newbytecount;
}
}
@@ -835,23 +780,13 @@ TIFFFillStrip(TIFF* tif, uint32_t strip)
* it's what would happen if a read were done
* instead.
*/
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
- "Read error on strip %lu; "
- "got %I64u bytes, expected %I64u",
- (unsigned long) strip,
- (unsigned __int64) NoSanitizeSubUInt64(tif->tif_size, TIFFGetStrileOffset(tif, strip)),
- (unsigned __int64) bytecount);
-#else
- TIFFErrorExt(tif->tif_clientdata, module,
-
- "Read error on strip %lu; "
- "got %llu bytes, expected %llu",
- (unsigned long) strip,
- (unsigned long long) NoSanitizeSubUInt64(tif->tif_size, TIFFGetStrileOffset(tif, strip)),
- (unsigned long long) bytecount);
-#endif
+ "Read error on strip %"PRIu32"; "
+ "got %"PRIu64" bytes, expected %"PRIu64,
+ strip,
+ NoSanitizeSubUInt64(tif->tif_size, TIFFGetStrileOffset(tif, strip)),
+ bytecount);
tif->tif_curstrip = NOSTRIP;
return (0);
}
@@ -906,8 +841,8 @@ TIFFFillStrip(TIFF* tif, uint32_t strip)
tif->tif_curstrip = NOSTRIP;
if ((tif->tif_flags & TIFF_MYBUFFER) == 0) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Data buffer too small to hold strip %lu",
- (unsigned long) strip);
+ "Data buffer too small to hold strip %"PRIu32,
+ strip);
return (0);
}
}
@@ -985,8 +920,8 @@ TIFFReadEncodedTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size)
return ((tmsize_t)(-1));
if (tile >= td->td_nstrips) {
TIFFErrorExt(tif->tif_clientdata, module,
- "%lu: Tile out of range, max %lu",
- (unsigned long) tile, (unsigned long) td->td_nstrips);
+ "%"PRIu32": Tile out of range, max %"PRIu32,
+ tile, td->td_nstrips);
return ((tmsize_t)(-1));
}
@@ -1062,8 +997,8 @@ _TIFFReadEncodedTileAndAllocBuffer(TIFF* tif, uint32_t tile,
return ((tmsize_t)(-1));
if (tile >= td->td_nstrips) {
TIFFErrorExt(tif->tif_clientdata, module,
- "%lu: Tile out of range, max %lu",
- (unsigned long) tile, (unsigned long) td->td_nstrips);
+ "%"PRIu32": Tile out of range, max %"PRIu32,
+ tile, td->td_nstrips);
return ((tmsize_t)(-1));
}
@@ -1099,29 +1034,20 @@ TIFFReadRawTile1(TIFF* tif, uint32_t tile, void* buf, tmsize_t size, const char*
if (!SeekOK(tif, TIFFGetStrileOffset(tif, tile))) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Seek error at row %lu, col %lu, tile %lu",
- (unsigned long) tif->tif_row,
- (unsigned long) tif->tif_col,
- (unsigned long) tile);
+ "Seek error at row %"PRIu32", col %"PRIu32", tile %"PRIu32,
+ tif->tif_row,
+ tif->tif_col,
+ tile);
return ((tmsize_t)(-1));
}
cc = TIFFReadFile(tif, buf, size);
if (cc != size) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- TIFFErrorExt(tif->tif_clientdata, module,
- "Read error at row %lu, col %lu; got %I64u bytes, expected %I64u",
- (unsigned long) tif->tif_row,
- (unsigned long) tif->tif_col,
- (unsigned __int64) cc,
- (unsigned __int64) size);
-#else
TIFFErrorExt(tif->tif_clientdata, module,
- "Read error at row %lu, col %lu; got %llu bytes, expected %llu",
- (unsigned long) tif->tif_row,
- (unsigned long) tif->tif_col,
- (unsigned long long) cc,
- (unsigned long long) size);
-#endif
+ "Read error at row %"PRIu32", col %"PRIu32"; got %"PRId64" bytes, expected %"PRId64,
+ tif->tif_row,
+ tif->tif_col,
+ cc,
+ size);
return ((tmsize_t)(-1));
}
} else {
@@ -1136,23 +1062,13 @@ TIFFReadRawTile1(TIFF* tif, uint32_t tile, void* buf, tmsize_t size, const char*
else
n=size;
if (n!=size) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- TIFFErrorExt(tif->tif_clientdata, module,
-"Read error at row %lu, col %lu, tile %lu; got %I64u bytes, expected %I64u",
- (unsigned long) tif->tif_row,
- (unsigned long) tif->tif_col,
- (unsigned long) tile,
- (unsigned __int64) n,
- (unsigned __int64) size);
-#else
TIFFErrorExt(tif->tif_clientdata, module,
-"Read error at row %lu, col %lu, tile %lu; got %llu bytes, expected %llu",
- (unsigned long) tif->tif_row,
- (unsigned long) tif->tif_col,
- (unsigned long) tile,
- (unsigned long long) n,
- (unsigned long long) size);
-#endif
+"Read error at row %"PRIu32", col %"PRIu32", tile %"PRIu32"; got %"PRId64" bytes, expected %"PRId64,
+ tif->tif_row,
+ tif->tif_col,
+ tile,
+ n,
+ size);
return ((tmsize_t)(-1));
}
_TIFFmemcpy(buf, tif->tif_base + ma, size);
@@ -1175,8 +1091,8 @@ TIFFReadRawTile(TIFF* tif, uint32_t tile, void* buf, tmsize_t size)
return ((tmsize_t)(-1));
if (tile >= td->td_nstrips) {
TIFFErrorExt(tif->tif_clientdata, module,
- "%lu: Tile out of range, max %lu",
- (unsigned long) tile, (unsigned long) td->td_nstrips);
+ "%"PRIu32": Tile out of range, max %"PRIu32,
+ tile, td->td_nstrips);
return ((tmsize_t)(-1));
}
if (tif->tif_flags&TIFF_NOREADRAW)
@@ -1210,17 +1126,10 @@ TIFFFillTile(TIFF* tif, uint32_t tile)
{
uint64_t bytecount = TIFFGetStrileByteCount(tif, tile);
if( bytecount == 0 || bytecount > (uint64_t)TIFF_INT64_MAX ) {
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
- "%I64u: Invalid tile byte count, tile %lu",
- (unsigned __int64) bytecount,
- (unsigned long) tile);
-#else
- TIFFErrorExt(tif->tif_clientdata, module,
- "%llu: Invalid tile byte count, tile %lu",
- (unsigned long long) bytecount,
- (unsigned long) tile);
-#endif
+ "%"PRIu64": Invalid tile byte count, tile %"PRIu32,
+ bytecount,
+ tile);
return (0);
}
@@ -1238,19 +1147,11 @@ TIFFFillTile(TIFF* tif, uint32_t tile)
uint64_t newbytecount = (uint64_t)stripsize * 10 + 4096;
if( newbytecount == 0 || newbytecount > (uint64_t)TIFF_INT64_MAX )
{
-#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
- TIFFWarningExt(tif->tif_clientdata, module,
- "Too large tile byte count %I64u, tile %lu. Limiting to %I64u",
- (unsigned __int64) bytecount,
- (unsigned long) tile,
- (unsigned __int64) newbytecount);
-#else
TIFFErrorExt(tif->tif_clientdata, module,
- "Too large tile byte count %llu, tile %lu. Limiting to %llu",
- (unsigned long long) bytecount,
- (unsigned long) tile,
- (unsigned long long) newbytecount);
-#endif
+ "Too large tile byte count %"PRIu64", tile %"PRIu32". Limiting to %"PRIu64,
+ bytecount,
+ tile,
+ newbytecount);
bytecount = newbytecount;
}
}
@@ -1317,8 +1218,8 @@ TIFFFillTile(TIFF* tif, uint32_t tile)
tif->tif_curtile = NOTILE;
if ((tif->tif_flags & TIFF_MYBUFFER) == 0) {
TIFFErrorExt(tif->tif_clientdata, module,
- "Data buffer too small to hold tile %lu",
- (unsigned long) tile);
+ "Data buffer too small to hold tile %"PRIu32,
+ tile);
return (0);
}
}
@@ -1406,8 +1307,8 @@ TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size)
}
if (tif->tif_rawdata == NULL) {
TIFFErrorExt(tif->tif_clientdata, module,
- "No space for data buffer at scanline %lu",
- (unsigned long) tif->tif_row);
+ "No space for data buffer at scanline %"PRIu32,
+ tif->tif_row);
tif->tif_rawdatasize = 0;
return (0);
}
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
index 00e9848f..2f3317e2 100644
--- a/tools/tiff2pdf.c
+++ b/tools/tiff2pdf.c
@@ -2483,7 +2483,7 @@ tsize_t t2p_readwrite_pdf_image(T2P* t2p, TIFF* input, TIFF* output){
_TIFFmalloc(max_striplength);
if(stripbuffer==NULL){
TIFFError(TIFF2PDF_MODULE,
- "Can't allocate %"PRId64" bytes of memory for t2p_readwrite_pdf_image, %s",
+ "Can't allocate %"PRId32" bytes of memory for t2p_readwrite_pdf_image, %s",
max_striplength,
TIFFFileName(input));
_TIFFfree(buffer);
diff --git a/tools/tiffinfo.c b/tools/tiffinfo.c
index 3bf66c31..329c0d31 100644
--- a/tools/tiffinfo.c
+++ b/tools/tiffinfo.c
@@ -202,7 +202,7 @@ ShowStrip(tstrip_t strip, unsigned char* pp, uint32_t nrow, tsize_t scanline)
{
register tsize_t cc;
- printf("Strip %"PRIu32":\n", (unsigned long) strip);
+ printf("Strip %"PRIu32":\n", strip);
while (nrow-- > 0) {
for (cc = 0; cc < scanline; cc++) {
printf(" %02x", *pp++);