From c4aa76401b8f255c59119fcc0a1245cd3c3bedbe Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Mon, 12 Oct 2020 19:42:14 +0200 Subject: [PATCH] Fix compiler warnings about unused variables when assert() expands to nothing --- contrib/addtiffo/tif_ovrcache.c | 1 + libtiff/tif_jbig.c | 1 + libtiff/tif_jpeg.c | 1 + libtiff/tif_luv.c | 6 ++++++ libtiff/tif_lzma.c | 1 + libtiff/tif_lzw.c | 1 + libtiff/tif_ojpeg.c | 1 + libtiff/tif_open.c | 1 + libtiff/tif_pixarlog.c | 1 + libtiff/tif_webp.c | 1 + test/defer_strile_loading.c | 13 ++++++++++--- 11 files changed, 25 insertions(+), 3 deletions(-) diff --git a/contrib/addtiffo/tif_ovrcache.c b/contrib/addtiffo/tif_ovrcache.c index 67a88120..ac500ab4 100644 --- a/contrib/addtiffo/tif_ovrcache.c +++ b/contrib/addtiffo/tif_ovrcache.c @@ -166,6 +166,7 @@ static void TIFFWriteOvrRow( TIFFOvrCache * psCache ) /* -------------------------------------------------------------------- */ nBaseDirOffset = TIFFCurrentDirOffset( psCache->hTIFF ); nRet = TIFFSetSubDirectory( psCache->hTIFF, psCache->nDirOffset ); + (void) nRet; assert( nRet == 1 ); /* -------------------------------------------------------------------- */ diff --git a/libtiff/tif_jbig.c b/libtiff/tif_jbig.c index 7ffe8851..a3500e0b 100644 --- a/libtiff/tif_jbig.c +++ b/libtiff/tif_jbig.c @@ -199,6 +199,7 @@ static int JBIGEncode(TIFF* tif, uint8* buffer, tmsize_t size, uint16 s) int TIFFInitJBIG(TIFF* tif, int scheme) { + (void)scheme; assert(scheme == COMPRESSION_JBIG); /* diff --git a/libtiff/tif_jpeg.c b/libtiff/tif_jpeg.c index 28d08e37..2c228570 100644 --- a/libtiff/tif_jpeg.c +++ b/libtiff/tif_jpeg.c @@ -2482,6 +2482,7 @@ TIFFInitJPEG(TIFF* tif, int scheme) { JPEGState* sp; + (void)scheme; assert(scheme == COMPRESSION_JPEG); /* diff --git a/libtiff/tif_luv.c b/libtiff/tif_luv.c index 863fc8d7..3bd02e88 100644 --- a/libtiff/tif_luv.c +++ b/libtiff/tif_luv.c @@ -193,6 +193,7 @@ LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tmsize_t cc; int rc; + (void)s; assert(s == 0); assert(sp != NULL); @@ -266,6 +267,7 @@ LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) unsigned char* bp; uint32* tp; + (void)s; assert(s == 0); assert(sp != NULL); @@ -326,6 +328,7 @@ LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s) tmsize_t cc; int rc; + (void)s; assert(s == 0); sp = DecoderState(tif); assert(sp != NULL); @@ -447,6 +450,7 @@ LogL16Encode(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) int rc=0, mask; tmsize_t beg; + (void)s; assert(s == 0); assert(sp != NULL); npixels = cc / sp->pixel_size; @@ -541,6 +545,7 @@ LogLuvEncode24(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) uint8* op; uint32* tp; + (void)s; assert(s == 0); assert(sp != NULL); npixels = cc / sp->pixel_size; @@ -598,6 +603,7 @@ LogLuvEncode32(TIFF* tif, uint8* bp, tmsize_t cc, uint16 s) int rc=0, mask; tmsize_t beg; + (void)s; assert(s == 0); assert(sp != NULL); diff --git a/libtiff/tif_lzma.c b/libtiff/tif_lzma.c index 4e347c94..e150bd63 100644 --- a/libtiff/tif_lzma.c +++ b/libtiff/tif_lzma.c @@ -420,6 +420,7 @@ TIFFInitLZMA(TIFF* tif, int scheme) LZMAState* sp; lzma_stream tmp_stream = LZMA_STREAM_INIT; + (void)scheme; assert( scheme == COMPRESSION_LZMA ); /* diff --git a/libtiff/tif_lzw.c b/libtiff/tif_lzw.c index 3bf92ebd..7bb61078 100644 --- a/libtiff/tif_lzw.c +++ b/libtiff/tif_lzw.c @@ -1161,6 +1161,7 @@ int TIFFInitLZW(TIFF* tif, int scheme) { static const char module[] = "TIFFInitLZW"; + (void)scheme; assert(scheme == COMPRESSION_LZW); /* * Allocate state block so tag methods have storage to record values. diff --git a/libtiff/tif_ojpeg.c b/libtiff/tif_ojpeg.c index c2d814f0..133d1f1c 100644 --- a/libtiff/tif_ojpeg.c +++ b/libtiff/tif_ojpeg.c @@ -421,6 +421,7 @@ TIFFInitOJPEG(TIFF* tif, int scheme) static const char module[]="TIFFInitOJPEG"; OJPEGState* sp; + (void)scheme; assert(scheme==COMPRESSION_OJPEG); /* diff --git a/libtiff/tif_open.c b/libtiff/tif_open.c index 4024b3cd..a0e31583 100644 --- a/libtiff/tif_open.c +++ b/libtiff/tif_open.c @@ -104,6 +104,7 @@ TIFFClientOpen( } n; n.a8[0]=1; n.a8[1]=0; + (void)n; #ifdef WORDS_BIGENDIAN assert(n.a16==256); #else diff --git a/libtiff/tif_pixarlog.c b/libtiff/tif_pixarlog.c index 148ee619..f2912015 100644 --- a/libtiff/tif_pixarlog.c +++ b/libtiff/tif_pixarlog.c @@ -1400,6 +1400,7 @@ TIFFInitPixarLog(TIFF* tif, int scheme) PixarLogState* sp; + (void)scheme; assert(scheme == COMPRESSION_PIXARLOG); /* diff --git a/libtiff/tif_webp.c b/libtiff/tif_webp.c index c7885539..912bc6f0 100644 --- a/libtiff/tif_webp.c +++ b/libtiff/tif_webp.c @@ -628,6 +628,7 @@ TIFFInitWebP(TIFF* tif, int scheme) static const char module[] = "TIFFInitWebP"; WebPState* sp; + (void)scheme; assert( scheme == COMPRESSION_WEBP ); /* diff --git a/test/defer_strile_loading.c b/test/defer_strile_loading.c index b444c01f..b2280324 100644 --- a/test/defer_strile_loading.c +++ b/test/defer_strile_loading.c @@ -148,11 +148,15 @@ int test(int classictif, int height, int tiled) assert(err == 0); size = TIFFGetStrileByteCountWithErr(tif, j, &err); + (void)size; assert(size == 256); assert(err == 0); fseek(f, offset, SEEK_SET); - fread(inputbuffer, 256, 1, f); + { + size_t nread = fread(inputbuffer, 256, 1, f); + (void)nread; + } memset(tilebuffer,0, 256); ret = TIFFReadFromUserBuffer(tif, j, @@ -204,12 +208,15 @@ int test(int classictif, int height, int tiled) assert(err == 0); size = TIFFGetStrileByteCountWithErr(tif, j, &err); + (void)size; assert(size == 1); assert(err == 0); fseek(f, offset, SEEK_SET); - fread(inputbuffer, 1, 1, f); - + { + size_t nread = fread(inputbuffer, 1, 1, f); + (void)nread; + } memset(tilebuffer,0, 1); ret = TIFFReadFromUserBuffer(tif, j, inputbuffer, 1,