libtiff: Merge branch 'formatting-fixes' into 'master' (0d929)

From 699c7d4cbd95b3fea4deabe00e6550fe41e7d899 Mon Sep 17 00:00:00 2001
From: Even Rouault <[EMAIL REDACTED]>
Date: Fri, 17 May 2024 18:45:05 +0200
Subject: [PATCH] Formatting fixes

---
 libtiff/tif_fax3.c |  4 +++-
 tools/fax2tiff.c   |  8 +++++---
 tools/tiff2pdf.c   |  3 ++-
 tools/tiff2rgba.c  |  9 ++++++---
 tools/tiffcrop.c   | 33 ++++++++++++++++++++-------------
 5 files changed, 36 insertions(+), 21 deletions(-)

diff --git a/libtiff/tif_fax3.c b/libtiff/tif_fax3.c
index c70e1245..5ac5b2da 100644
--- a/libtiff/tif_fax3.c
+++ b/libtiff/tif_fax3.c
@@ -1605,7 +1605,9 @@ static int Fax4Decode(TIFF *tif, uint8_t *buf, tmsize_t occ, uint16_t s)
         }
         (*sp->fill)(buf, thisrun, pa, lastx);
         UNCACHE_STATE(tif, sp);
-        return (sp->line != start ? 1 : -1); /* don't error on badly-terminated strips */
+        return (sp->line != start
+                    ? 1
+                    : -1); /* don't error on badly-terminated strips */
     }
     UNCACHE_STATE(tif, sp);
     return (1);
diff --git a/tools/fax2tiff.c b/tools/fax2tiff.c
index e4cb7133..645931c1 100644
--- a/tools/fax2tiff.c
+++ b/tools/fax2tiff.c
@@ -154,8 +154,9 @@ int main(int argc, char *argv[])
                 xsize = (uint32_t)atoi(optarg);
                 if (xsize < 1 || xsize > 10000)
                 {
-                    fprintf(stderr, "%s: The input width %s is not reasonable\n", argv[0],
-                            optarg);
+                    fprintf(stderr,
+                            "%s: The input width %s is not reasonable\n",
+                            argv[0], optarg);
                     return EXIT_FAILURE;
                 }
                 break;
@@ -412,7 +413,8 @@ int copyFaxFile(TIFF *tifin, TIFF *tifout)
         {
             if (compression_in == COMPRESSION_CCITTFAX4)
             {
-                /* This is proably EOFB, but if it's corrupt data, then we can't continue, anyway. */
+                /* This is proably EOFB, but if it's corrupt data, then we can't
+                 * continue, anyway. */
                 break;
             }
             badfaxlines++;
diff --git a/tools/tiff2pdf.c b/tools/tiff2pdf.c
index d752d139..c0545600 100644
--- a/tools/tiff2pdf.c
+++ b/tools/tiff2pdf.c
@@ -902,7 +902,8 @@ static void usage_info(int code)
 #if defined(JPEG_SUPPORT) || defined(ZIP_SUPPORT)
         " -q: compression quality\n"
         " -n: no compressed data passthrough\n"
-        " -d: do not compress (decompress) - except monochrome to CCITT Group 4\n"
+        " -d: do not compress (decompress) - except monochrome to CCITT Group "
+        "4\n"
 #endif
         " -i: invert colors\n"
         " -u: set distance unit, 'i' for inch, 'm' for centimeter\n"
diff --git a/tools/tiff2rgba.c b/tools/tiff2rgba.c
index 61400500..41a90f0d 100644
--- a/tools/tiff2rgba.c
+++ b/tools/tiff2rgba.c
@@ -494,9 +494,12 @@ static int cvt_whole_image(TIFF *in, TIFF *out)
             /* do alpha compositing */
             const int src_alpha = src[3];
             const int background_contribution = background * (0xFF - src_alpha);
-            *(dst++) = (*(src) * src_alpha + background_contribution) / 0xFF; src++;
-            *(dst++) = (*(src) * src_alpha + background_contribution) / 0xFF; src++;
-            *(dst++) = (*(src) * src_alpha + background_contribution) / 0xFF; src++;
+            *(dst++) = (*(src)*src_alpha + background_contribution) / 0xFF;
+            src++;
+            *(dst++) = (*(src)*src_alpha + background_contribution) / 0xFF;
+            src++;
+            *(dst++) = (*(src)*src_alpha + background_contribution) / 0xFF;
+            src++;
             src++;
             count--;
         }
diff --git a/tools/tiffcrop.c b/tools/tiffcrop.c
index 6322447f..f9c22cb3 100644
--- a/tools/tiffcrop.c
+++ b/tools/tiffcrop.c
@@ -486,8 +486,8 @@ static uint32_t rowsperstrip = 0;
 static uint32_t g3opts = 0;
 static int ignore = FALSE; /* if true, ignore read errors */
 static uint32_t defg3opts = (uint32_t)-1;
-static int quality = 100; /* JPEG quality */
-static int jpegcolormode = -1;        /* means YCbCr or to not convert */
+static int quality = 100;      /* JPEG quality */
+static int jpegcolormode = -1; /* means YCbCr or to not convert */
 static uint16_t defcompression = (uint16_t)-1;
 static uint16_t defpredictor = (uint16_t)-1;
 static int pageNum = 0;
@@ -2398,7 +2398,8 @@ void process_command_opts(int argc, char *argv[], char *mp, char *mode,
                 }
                 if ((page->cols * page->rows) < 1)
                 {
-                    TIFFError("No subdivisions", "%d", (page->cols * page->rows));
+                    TIFFError("No subdivisions", "%d",
+                              (page->cols * page->rows));
                     exit(EXIT_FAILURE);
                 }
                 page->mode |= PAGE_MODE_ROWSCOLS;
@@ -7801,8 +7802,9 @@ static int extractImageSection(struct image_data *image,
 #endif
             if (src_offset + full_bytes >= check_buffsize)
             {
-                printf("Bad input. Preventing reading outside of input buffer.\n");
-                return(-1);
+                printf(
+                    "Bad input. Preventing reading outside of input buffer.\n");
+                return (-1);
             }
             _TIFFmemcpy(sect_buff + dst_offset, src_buff + src_offset,
                         full_bytes);
@@ -7852,8 +7854,9 @@ static int extractImageSection(struct image_data *image,
             {
                 if (offset1 + full_bytes >= check_buffsize)
                 {
-                    printf("Bad input. Preventing reading outside of input buffer.\n");
-                    return(-1);
+                    printf("Bad input. Preventing reading outside of input "
+                           "buffer.\n");
+                    return (-1);
                 }
                 _TIFFmemcpy(sect_buff + dst_offset, src_buff + offset1,
                             full_bytes);
@@ -7884,8 +7887,9 @@ static int extractImageSection(struct image_data *image,
                      * not wanted column samples to zero */
                     if (offset1 + full_bytes >= check_buffsize)
                     {
-                        printf("Bad input. Preventing reading outside of input buffer.\n");
-                        return(-1);
+                        printf("Bad input. Preventing reading outside of input "
+                               "buffer.\n");
+                        return (-1);
                     }
                     bytebuff2 = src_buff[offset1 + full_bytes] &
                                 ((unsigned char)255 << (8 - trailing_bits));
@@ -7929,8 +7933,9 @@ static int extractImageSection(struct image_data *image,
                      * than image size, because could read behind image here. */
                     if (offset1 + j + 1 >= check_buffsize)
                     {
-                        printf("Bad input. Preventing reading outside of input buffer.\n");
-                        return(-1);
+                        printf("Bad input. Preventing reading outside of input "
+                               "buffer.\n");
+                        return (-1);
                     }
                     bytebuff1 =
                         src_buff[offset1 + j] & ((unsigned char)255 >> shift1);
@@ -8227,7 +8232,8 @@ static int writeSingleSection(TIFF *in, TIFF *out, struct image_data *image,
                                                                  : "mask");
             return (-1);
         }
-        if (jpegcolormode == JPEGCOLORMODE_RGB && input_photometric == PHOTOMETRIC_YCBCR)
+        if (jpegcolormode == JPEGCOLORMODE_RGB &&
+            input_photometric == PHOTOMETRIC_YCBCR)
         {
             TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
         }
@@ -9001,7 +9007,8 @@ static int writeCroppedImage(TIFF *in, TIFF *out, struct image_data *image,
                                                                  : "mask");
             return (-1);
         }
-        if (jpegcolormode == JPEGCOLORMODE_RGB && input_photometric == PHOTOMETRIC_YCBCR)
+        if (jpegcolormode == JPEGCOLORMODE_RGB &&
+            input_photometric == PHOTOMETRIC_YCBCR)
         {
             TIFFSetField(out, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
         }