libtiff: silence "W124: Comparison result always 0" warnings from watcom.

From 64399ea871c9518129026866a0ef4ce566d08d10 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sun, 15 Oct 2023 11:10:24 +0300
Subject: [PATCH] silence "W124: Comparison result always 0" warnings from
 watcom.

---
 libtiff/tif_dirread.c  |  2 +-
 libtiff/tif_dirwrite.c | 16 ++++++++--------
 libtiff/tif_strip.c    |  4 ++--
 libtiff/tif_zip.c      | 10 +++++-----
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/libtiff/tif_dirread.c b/libtiff/tif_dirread.c
index d9cd9948..bc6bbdc5 100644
--- a/libtiff/tif_dirread.c
+++ b/libtiff/tif_dirread.c
@@ -3300,7 +3300,7 @@ static enum TIFFReadDirEntryErr TIFFReadDirEntryCheckRangeLongSlong(int32 value)
 static enum TIFFReadDirEntryErr
 TIFFReadDirEntryCheckRangeLongLong8(uint64 value)
 {
-	if (value > TIFF_UINT32_MAX)
+	if (value > (uint64)(TIFF_UINT32_MAX))
 		return(TIFFReadDirEntryErrRange);
 	else
 		return(TIFFReadDirEntryErrOk);
diff --git a/libtiff/tif_dirwrite.c b/libtiff/tif_dirwrite.c
index f481250e..805a50c8 100644
--- a/libtiff/tif_dirwrite.c
+++ b/libtiff/tif_dirwrite.c
@@ -375,7 +375,7 @@ TIFFRewriteDirectory( TIFF *tif )
 				}
 				if (tif->tif_flags & TIFF_SWAB)
 					TIFFSwabLong8(&dircount64);
-				if (dircount64>0xFFFF)
+				if (dircount64>0xFFFFULL)
 				{
 					TIFFErrorExt(tif->tif_clientdata, module,
 					     "Sanity check on tag count failed, likely corrupt TIFF");
@@ -1875,7 +1875,7 @@ TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir,
 
         for (q=p, ma=value, mb=0; mb<count; ma++, mb++, q++)
         {
-            if (*ma>0xFFFFFFFF)
+            if (*ma>0xFFFFFFFFULL)
             {
                 TIFFErrorExt(tif->tif_clientdata,module,
                             "Attempt to write value larger than 0xFFFFFFFF in LONG array.");
@@ -1903,7 +1903,7 @@ TIFFWriteDirectoryTagLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir,
 
         for (q=p, ma=value, mb=0; mb<count; ma++, mb++, q++)
         {
-            if (*ma>0xFFFF)
+            if (*ma>0xFFFFULL)
             {
                 /* Should not happen normally given the check we did before */
                 TIFFErrorExt(tif->tif_clientdata,module,
@@ -1963,7 +1963,7 @@ TIFFWriteDirectoryTagIfdIfd8Array(TIFF* tif, uint32* ndir, TIFFDirEntry* dir, ui
 
     for (q=p, ma=value, mb=0; mb<count; ma++, mb++, q++)
     {
-        if (*ma>0xFFFFFFFF)
+        if (*ma>0xFFFFFFFFULL)
         {
             TIFFErrorExt(tif->tif_clientdata,module,
                          "Attempt to write value larger than 0xFFFFFFFF in Classic TIFF file.");
@@ -1996,9 +1996,9 @@ TIFFWriteDirectoryTagShortLongLong8Array(TIFF* tif, uint32* ndir, TIFFDirEntry*
 	n=0;
 	for (ma=value, mb=0; mb<count; ma++, mb++)
 	{
-		if ((n==0)&&(*ma>0xFFFF))
+		if ((n==0)&&(*ma>0xFFFFULL))
 			n=1;
-		if ((n==1)&&(*ma>0xFFFFFFFF))
+		if ((n==1)&&(*ma>0xFFFFFFFFULL))
 		{
 			n=2;
 			break;
@@ -2155,7 +2155,7 @@ TIFFWriteDirectoryTagSubifd(TIFF* tif, uint32* ndir, TIFFDirEntry* dir)
                         assert(pa != 0);
 
                         /* Could happen if an classicTIFF has a SubIFD of type LONG8 (which is illegal) */
-                        if( *pa > 0xFFFFFFFFUL)
+                        if( *pa > 0xFFFFFFFFULL)
                         {
                             TIFFErrorExt(tif->tif_clientdata,module,"Illegal value for SubIFD tag");
                             _TIFFfree(o);
@@ -2859,7 +2859,7 @@ void DoubleToRational(double value, uint32 *num, uint32 *denom)
 	ToRationalEuclideanGCD(value, FALSE, FALSE, &ullNum, &ullDenom);
 	ToRationalEuclideanGCD(value, FALSE, TRUE, &ullNum2, &ullDenom2);
 	/*-- Double-Check, that returned values fit into ULONG :*/
-	if (ullNum > 0xFFFFFFFFUL || ullDenom > 0xFFFFFFFFUL || ullNum2 > 0xFFFFFFFFUL || ullDenom2 > 0xFFFFFFFFUL) {
+	if (ullNum > 0xFFFFFFFFULL || ullDenom > 0xFFFFFFFFULL || ullNum2 > 0xFFFFFFFFULL || ullDenom2 > 0xFFFFFFFFULL) {
 #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
diff --git a/libtiff/tif_strip.c b/libtiff/tif_strip.c
index c08c60a7..57aba516 100644
--- a/libtiff/tif_strip.c
+++ b/libtiff/tif_strip.c
@@ -236,8 +236,8 @@ _TIFFDefaultStripSize(TIFF* tif, uint32 s)
 		rows=(uint64)STRIP_SIZE_DEFAULT/scanlinesize;
 		if (rows==0)
 			rows=1;
-		else if (rows>0xFFFFFFFF)
-			rows=0xFFFFFFFF;
+		else if (rows>0xFFFFFFFFULL)
+			rows=0xFFFFFFFFULL;
 		s=(uint32)rows;
 	}
 	return (s);
diff --git a/libtiff/tif_zip.c b/libtiff/tif_zip.c
index e71c312c..b9f9da49 100644
--- a/libtiff/tif_zip.c
+++ b/libtiff/tif_zip.c
@@ -238,7 +238,7 @@ ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
 	    appropriately even before we simplify it */
 	do {
                 int state;
-                uInt avail_in_before = (uint64)tif->tif_rawcc <= 0xFFFFFFFFU ? (uInt)tif->tif_rawcc : 0xFFFFFFFFU;
+                uInt avail_in_before = (uint64)tif->tif_rawcc <= 0xFFFFFFFFULL ? (uInt)tif->tif_rawcc : 0xFFFFFFFFU;
                 uInt avail_out_before = (uint64)occ < 0xFFFFFFFFU ? (uInt) occ : 0xFFFFFFFFU;
                 sp->stream.avail_in = avail_in_before;
                 sp->stream.avail_out = avail_out_before;
@@ -318,7 +318,7 @@ ZIPPreEncode(TIFF* tif, uint16 s)
 	    we need to simplify this code to reflect a ZLib that is likely updated
 	    to deal with 8byte memory sizes, though this code will respond
 	    appropriately even before we simplify it */
-	sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU;
+	sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFULL ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU;
 	return (deflateReset(&sp->stream) == Z_OK);
 }
 
@@ -430,7 +430,7 @@ ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
 	    to deal with 8byte memory sizes, though this code will respond
 	    appropriately even before we simplify it */
 	do {
-                uInt avail_in_before = (uint64)cc <= 0xFFFFFFFFU ? (uInt)cc : 0xFFFFFFFFU;
+                uInt avail_in_before = (uint64)cc <= 0xFFFFFFFFULL ? (uInt)cc : 0xFFFFFFFFU;
                 sp->stream.avail_in = avail_in_before;
 		if (deflate(&sp->stream, Z_NO_FLUSH) != Z_OK) {
 			TIFFErrorExt(tif->tif_clientdata, module, 
@@ -443,7 +443,7 @@ ZIPEncode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s)
 			if (!TIFFFlushData1(tif))
 				return 0;
 			sp->stream.next_out = tif->tif_rawdata;
-			sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU;
+			sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFULL ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU;
 		}
 		cc -= (avail_in_before - sp->stream.avail_in);
 	} while (cc > 0);
@@ -478,7 +478,7 @@ ZIPPostEncode(TIFF* tif)
 				if (!TIFFFlushData1(tif))
 					return 0;
 				sp->stream.next_out = tif->tif_rawdata;
-				sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFU ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU;
+				sp->stream.avail_out = (uint64)tif->tif_rawdatasize <= 0xFFFFFFFFULL ? (uInt)tif->tif_rawdatasize : 0xFFFFFFFFU;
 			}
 			break;
 		default: