Fix some instances of -Wunused-but-set-variable.

Bug: chromium:1203071
Change-Id: I0ba84fd5c5339f316e4fa9c98b4751dc57d8c90c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/83390
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/third_party/libpng16/0001-unused-variable.patch b/third_party/libpng16/0001-unused-variable.patch
new file mode 100644
index 0000000..ad61072
--- /dev/null
+++ b/third_party/libpng16/0001-unused-variable.patch
@@ -0,0 +1,21 @@
+diff --git a/third_party/libpng16/pngread.c b/third_party/libpng16/pngread.c
+index 8fa7d9f16..5ab922403 100644
+--- a/third_party/libpng16/pngread.c
++++ b/third_party/libpng16/pngread.c
+@@ -3452,7 +3452,6 @@ png_image_read_background(png_voidp argument)
+ 
+             for (pass = 0; pass < passes; ++pass)
+             {
+-               png_bytep row = png_voidcast(png_bytep, display->first_row);
+                unsigned int     startx, stepx, stepy;
+                png_uint_32      y;
+ 
+@@ -3557,8 +3556,6 @@ png_image_read_background(png_voidp argument)
+ 
+                         inrow += 2; /* gray and alpha channel */
+                      }
+-
+-                     row += display->row_bytes;
+                   }
+                }
+             }
diff --git a/third_party/libpng16/README.pdfium b/third_party/libpng16/README.pdfium
index a4bcb63..8c96461 100644
--- a/third_party/libpng16/README.pdfium
+++ b/third_party/libpng16/README.pdfium
@@ -17,4 +17,5 @@
 pnglibconf.h: a copy of libpng's scripts/pnglibconf.h.prebuilt.
 pngprefix.h: manually-created redefinitions to avoid conflicts with Chromium.
 0000-build-config.patch: Local build configuration changes.
+0001-unused-variable.patch: Fix -Wunused-but-set-variable.
 0002-static-png-gt.patch: Unconditionally use static png_gt() in png.c to avoid compilation warning.
diff --git a/third_party/libpng16/pngread.c b/third_party/libpng16/pngread.c
index 8fa7d9f..5ab9224 100644
--- a/third_party/libpng16/pngread.c
+++ b/third_party/libpng16/pngread.c
@@ -3452,7 +3452,6 @@
 
             for (pass = 0; pass < passes; ++pass)
             {
-               png_bytep row = png_voidcast(png_bytep, display->first_row);
                unsigned int     startx, stepx, stepy;
                png_uint_32      y;
 
@@ -3557,8 +3556,6 @@
 
                         inrow += 2; /* gray and alpha channel */
                      }
-
-                     row += display->row_bytes;
                   }
                }
             }
diff --git a/third_party/libtiff/0001-unused-variable.patch b/third_party/libtiff/0001-unused-variable.patch
new file mode 100644
index 0000000..692858a
--- /dev/null
+++ b/third_party/libtiff/0001-unused-variable.patch
@@ -0,0 +1,12 @@
+diff --git a/third_party/libtiff/tif_lzw.c b/third_party/libtiff/tif_lzw.c
+index 21064f29a..542ada455 100644
+--- a/third_party/libtiff/tif_lzw.c
++++ b/third_party/libtiff/tif_lzw.c
+@@ -1107,6 +1107,7 @@ LZWPostEncode(TIFF* tif)
+ 	}
+ 	PutNextCode(op, CODE_EOI);
+         /* Explicit 0xff masking to make icc -check=conversions happy */
++  (void)outcount;  /* Avoid compiler warning on unused-but-set variable. */
+ 	if (nextbits > 0) 
+ 		*op++ = (unsigned char)((nextdata << (8-nextbits))&0xff);
+ 	tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata);
diff --git a/third_party/libtiff/README.pdfium b/third_party/libtiff/README.pdfium
index 9e98d61..c5b6c87 100644
--- a/third_party/libtiff/README.pdfium
+++ b/third_party/libtiff/README.pdfium
@@ -10,6 +10,7 @@
 Local Modifications:
 
 0000-build-config.patch: Local build configuration changes.
+0001-unused-variable.patch: Fix -Wunused-but-set-variable.
 0017-safe_skews_in_gtTileContig.patch: return error if to/from skews overflow from int32.
 0028-nstrips-OOM.patch: return error for excess number of tiles/strips.
 0031-safe_size_ingtStripContig.patch: return error if the size to read overflow from int32.
diff --git a/third_party/libtiff/tif_lzw.c b/third_party/libtiff/tif_lzw.c
index 21064f2..542ada4 100644
--- a/third_party/libtiff/tif_lzw.c
+++ b/third_party/libtiff/tif_lzw.c
@@ -1107,6 +1107,7 @@
 	}
 	PutNextCode(op, CODE_EOI);
         /* Explicit 0xff masking to make icc -check=conversions happy */
+  (void)outcount;  /* Avoid compiler warning on unused-but-set variable. */
 	if (nextbits > 0) 
 		*op++ = (unsigned char)((nextdata << (8-nextbits))&0xff);
 	tif->tif_rawcc = (tmsize_t)(op - tif->tif_rawdata);