Fix code formatting/style issues ...

... including, but not limited to:
- unused macros
- private functions not marked as static
- unprototyped global functions
- variable shadowing

(detected by various non-default GCC 8 warning options)
diff --git a/jchuff.c b/jchuff.c
index 939b3e7..526203e 100644
--- a/jchuff.c
+++ b/jchuff.c
@@ -4,7 +4,7 @@
  * This file was part of the Independent JPEG Group's software:
  * Copyright (C) 1991-1997, Thomas G. Lane.
  * libjpeg-turbo Modifications:
- * Copyright (C) 2009-2011, 2014-2016, 2018, D. R. Commander.
+ * Copyright (C) 2009-2011, 2014-2016, 2018-2019, D. R. Commander.
  * Copyright (C) 2015, Matthieu Darbois.
  * For conditions of distribution and use, see the accompanying README.ijg
  * file.
@@ -356,6 +356,8 @@
   put_buffer = (put_buffer << size) | code; \
 }
 
+#if SIZEOF_SIZE_T != 8 && !defined(_WIN64)
+
 #define CHECKBUF15() { \
   if (put_bits > 15) { \
     EMIT_BYTE() \
@@ -363,6 +365,8 @@
   } \
 }
 
+#endif
+
 #define CHECKBUF31() { \
   if (put_bits > 31) { \
     EMIT_BYTE() \
diff --git a/jcmaster.c b/jcmaster.c
index 93b3de6..998dc40 100644
--- a/jcmaster.c
+++ b/jcmaster.c
@@ -492,8 +492,8 @@
      */
     master->pass_type = output_pass;
     master->pass_number++;
-    /*FALLTHROUGH*/
 #endif
+    /*FALLTHROUGH*/
   case output_pass:
     /* Do a data-output pass. */
     /* We need not repeat per-scan setup if prior optimization pass did it. */
diff --git a/jdatadst-tj.c b/jdatadst-tj.c
index 0bd961b..f6ded64 100644
--- a/jdatadst-tj.c
+++ b/jdatadst-tj.c
@@ -5,7 +5,7 @@
  * Copyright (C) 1994-1996, Thomas G. Lane.
  * Modified 2009-2012 by Guido Vollbeding.
  * libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2014, 2016, D. R. Commander.
+ * Copyright (C) 2011, 2014, 2016, 2019, D. R. Commander.
  * For conditions of distribution and use, see the accompanying README.ijg
  * file.
  *
@@ -27,6 +27,8 @@
 extern void *malloc(size_t size);
 extern void free(void *ptr);
 #endif
+void jpeg_mem_dest_tj(j_compress_ptr cinfo, unsigned char **outbuffer,
+                      unsigned long *outsize, boolean alloc);
 
 
 #define OUTPUT_BUF_SIZE  4096   /* choose an efficiently fwrite'able size */
diff --git a/jdatasrc-tj.c b/jdatasrc-tj.c
index 1c71307..69fb5ea 100644
--- a/jdatasrc-tj.c
+++ b/jdatasrc-tj.c
@@ -5,7 +5,7 @@
  * Copyright (C) 1994-1996, Thomas G. Lane.
  * Modified 2009-2011 by Guido Vollbeding.
  * libjpeg-turbo Modifications:
- * Copyright (C) 2011, 2016, D. R. Commander.
+ * Copyright (C) 2011, 2016, 2019, D. R. Commander.
  * For conditions of distribution and use, see the accompanying README.ijg
  * file.
  *
@@ -23,6 +23,9 @@
 #include "jpeglib.h"
 #include "jerror.h"
 
+void jpeg_mem_src_tj(j_decompress_ptr cinfo, const unsigned char *inbuffer,
+                     unsigned long insize);
+
 
 /*
  * Initialize source --- called by jpeg_read_header
diff --git a/jdmerge.c b/jdmerge.c
index b3fec04..dff5a35 100644
--- a/jdmerge.c
+++ b/jdmerge.c
@@ -429,8 +429,6 @@
 #define PACK_TWO_PIXELS_LE(l, r)    ((r << 16) | l)
 #define PACK_TWO_PIXELS_BE(l, r)    ((l << 16) | r)
 
-#define PACK_NEED_ALIGNMENT(ptr)    (((size_t)(ptr)) & 3)
-
 #define WRITE_TWO_PIXELS_LE(addr, pixels) { \
   ((INT16 *)(addr))[0] = (INT16)(pixels); \
   ((INT16 *)(addr))[1] = (INT16)((pixels) >> 16); \
diff --git a/md5/md5hl.c b/md5/md5hl.c
index ecd2e23..8a4a762 100644
--- a/md5/md5hl.c
+++ b/md5/md5hl.c
@@ -6,7 +6,7 @@
  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
  * ----------------------------------------------------------------------------
  * libjpeg-turbo Modifications:
- * Copyright (C)2016, 2018 D. R. Commander.  All Rights Reserved.
+ * Copyright (C)2016, 2018-2019 D. R. Commander.  All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -56,7 +56,7 @@
 
 #include "./md5.h"
 
-char *MD5End(MD5_CTX *ctx, char *buf)
+static char *MD5End(MD5_CTX *ctx, char *buf)
 {
   int i;
   unsigned char digest[LENGTH];
@@ -89,7 +89,7 @@
   off_t n;
 
   MD5Init(&ctx);
-#if _WIN32
+#ifdef _WIN32
   f = _open(filename, O_RDONLY | O_BINARY);
 #else
   f = open(filename, O_RDONLY);
@@ -123,12 +123,3 @@
     return 0;
   return (MD5End(&ctx, buf));
 }
-
-char *MD5Data(const void *data, unsigned int len, char *buf)
-{
-  MD5_CTX ctx;
-
-  MD5Init(&ctx);
-  MD5Update(&ctx, (unsigned char *)data, len);
-  return (MD5End(&ctx, buf));
-}
diff --git a/rdjpgcom.c b/rdjpgcom.c
index e9f31d2..620270e 100644
--- a/rdjpgcom.c
+++ b/rdjpgcom.c
@@ -118,7 +118,6 @@
 #define M_SOI    0xD8           /* Start Of Image (beginning of datastream) */
 #define M_EOI    0xD9           /* End Of Image (end of datastream) */
 #define M_SOS    0xDA           /* Start Of Scan (begins compressed data) */
-#define M_APP0   0xE0           /* Application-specific marker, type N */
 #define M_APP12  0xEC           /* (we don't bother to list all 16 APPn's) */
 #define M_COM    0xFE           /* COMment */
 
diff --git a/tjbench.c b/tjbench.c
index f1a2f6f..b94637b 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -95,7 +95,7 @@
 double benchTime = 5.0, warmup = 1.0;
 
 
-char *formatName(int subsamp, int cs, char *buf)
+static char *formatName(int subsamp, int cs, char *buf)
 {
   if (cs == TJCS_YCbCr)
     return (char *)subNameLong[subsamp];
@@ -107,7 +107,7 @@
 }
 
 
-char *sigfig(double val, int figs, char *buf, int len)
+static char *sigfig(double val, int figs, char *buf, int len)
 {
   char format[80];
   int digitsAfterDecimal = figs - (int)ceil(log10(fabs(val)));
@@ -122,9 +122,9 @@
 
 
 /* Custom DCT filter which produces a negative of the image */
-int dummyDCTFilter(short *coeffs, tjregion arrayRegion, tjregion planeRegion,
-                   int componentIndex, int transformIndex,
-                   tjtransform *transform)
+static int dummyDCTFilter(short *coeffs, tjregion arrayRegion,
+                          tjregion planeRegion, int componentIndex,
+                          int transformIndex, tjtransform *transform)
 {
   int i;
 
@@ -135,11 +135,12 @@
 
 
 /* Decompression test */
-int decomp(unsigned char *srcBuf, unsigned char **jpegBuf,
-           unsigned long *jpegSize, unsigned char *dstBuf, int w, int h,
-           int subsamp, int jpegQual, char *fileName, int tilew, int tileh)
+static int decomp(unsigned char *srcBuf, unsigned char **jpegBuf,
+                  unsigned long *jpegSize, unsigned char *dstBuf, int w, int h,
+                  int subsamp, int jpegQual, char *fileName, int tilew,
+                  int tileh)
 {
-  char tempStr[1024], sizeStr[20] = "\0", qualStr[13] = "\0", *ptr;
+  char tempStr[1024], sizeStr[24] = "\0", qualStr[13] = "\0", *ptr;
   FILE *file = NULL;
   tjhandle handle = NULL;
   int row, col, iter = 0, dstBufAlloc = 0, retval = 0;
@@ -249,10 +250,10 @@
   if (!doWrite) goto bailout;
 
   if (sf.num != 1 || sf.denom != 1)
-    snprintf(sizeStr, 20, "%d_%d", sf.num, sf.denom);
+    snprintf(sizeStr, 24, "%d_%d", sf.num, sf.denom);
   else if (tilew != w || tileh != h)
-    snprintf(sizeStr, 20, "%dx%d", tilew, tileh);
-  else snprintf(sizeStr, 20, "full");
+    snprintf(sizeStr, 24, "%dx%d", tilew, tileh);
+  else snprintf(sizeStr, 24, "full");
   if (decompOnly)
     snprintf(tempStr, 1024, "%s_%s.%s", fileName, sizeStr, ext);
   else
@@ -303,8 +304,8 @@
 }
 
 
-int fullTest(unsigned char *srcBuf, int w, int h, int subsamp, int jpegQual,
-             char *fileName)
+static int fullTest(unsigned char *srcBuf, int w, int h, int subsamp,
+                    int jpegQual, char *fileName)
 {
   char tempStr[1024], tempStr2[80];
   FILE *file = NULL;
@@ -504,7 +505,7 @@
 }
 
 
-int decompTest(char *fileName)
+static int decompTest(char *fileName)
 {
   FILE *file = NULL;
   tjhandle handle = NULL;
@@ -724,7 +725,7 @@
 }
 
 
-void usage(char *progName)
+static void usage(char *progName)
 {
   int i;
 
@@ -902,14 +903,14 @@
       else if (!strcasecmp(argv[i], "-copynone"))
         xformOpt |= TJXOPT_COPYNONE;
       else if (!strcasecmp(argv[i], "-benchtime") && i < argc - 1) {
-        double temp = atof(argv[++i]);
+        double tempd = atof(argv[++i]);
 
-        if (temp > 0.0) benchTime = temp;
+        if (tempd > 0.0) benchTime = tempd;
         else usage(argv[0]);
       } else if (!strcasecmp(argv[i], "-warmup") && i < argc - 1) {
-        double temp = atof(argv[++i]);
+        double tempd = atof(argv[++i]);
 
-        if (temp >= 0.0) warmup = temp;
+        if (tempd >= 0.0) warmup = tempd;
         else usage(argv[0]);
         printf("Warmup time = %.1f seconds\n\n", warmup);
       } else if (!strcasecmp(argv[i], "-alloc"))
@@ -920,16 +921,16 @@
         printf("Testing YUV planar encoding/decoding\n\n");
         doYUV = 1;
       } else if (!strcasecmp(argv[i], "-yuvpad") && i < argc - 1) {
-        int temp = atoi(argv[++i]);
+        int tempi = atoi(argv[++i]);
 
-        if (temp >= 1) yuvPad = temp;
+        if (tempi >= 1) yuvPad = tempi;
       } else if (!strcasecmp(argv[i], "-subsamp") && i < argc - 1) {
         i++;
         if (toupper(argv[i][0]) == 'G') subsamp = TJSAMP_GRAY;
         else {
-          int temp = atoi(argv[i]);
+          int tempi = atoi(argv[i]);
 
-          switch (temp) {
+          switch (tempi) {
           case 444:  subsamp = TJSAMP_444;  break;
           case 422:  subsamp = TJSAMP_422;  break;
           case 440:  subsamp = TJSAMP_440;  break;
diff --git a/tjexample.c b/tjexample.c
index 0db2269..001ea49 100644
--- a/tjexample.c
+++ b/tjexample.c
@@ -1,6 +1,6 @@
 /*
- * Copyright (C)2011-2012, 2014-2015, 2017 D. R. Commander.
- *                                         All Rights Reserved.
+ * Copyright (C)2011-2012, 2014-2015, 2017, 2019 D. R. Commander.
+ *                                               All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -71,9 +71,9 @@
 
 /* DCT filter example.  This produces a negative of the image. */
 
-int customFilter(short *coeffs, tjregion arrayRegion, tjregion planeRegion,
-                 int componentIndex, int transformIndex,
-                 tjtransform *transform)
+static int customFilter(short *coeffs, tjregion arrayRegion,
+                        tjregion planeRegion, int componentIndex,
+                        int transformIndex, tjtransform *transform)
 {
   int i;
 
@@ -84,7 +84,7 @@
 }
 
 
-void usage(char *programName)
+static void usage(char *programName)
 {
   int i;
 
@@ -355,9 +355,10 @@
 
   if (!strcasecmp(outFormat, "jpg")) {
     /* Output image format is JPEG.  Compress the uncompressed image. */
-    unsigned char *jpegBuf = NULL;  /* Dynamically allocate the JPEG buffer */
     unsigned long jpegSize = 0;
 
+    jpegBuf = NULL;  /* Dynamically allocate the JPEG buffer */
+
     if (outQual < 0)
       outQual = DEFAULT_QUALITY;
     printf(", %s subsampling, quality = %d\n", subsampName[outSubsamp],
diff --git a/tjunittest.c b/tjunittest.c
index fe6e4bb..a5baf5b 100644
--- a/tjunittest.c
+++ b/tjunittest.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C)2009-2014, 2017-2018 D. R. Commander.  All Rights Reserved.
+ * Copyright (C)2009-2014, 2017-2019 D. R. Commander.  All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -46,7 +46,7 @@
 #endif
 
 
-void usage(char *progName)
+static void usage(char *progName)
 {
   printf("\nUSAGE: %s [options]\n\n", progName);
   printf("Options:\n");
@@ -96,7 +96,7 @@
 #define BAILOUT() { exitStatus = -1;  goto bailout; }
 
 
-void initBuf(unsigned char *buf, int w, int h, int pf, int flags)
+static void initBuf(unsigned char *buf, int w, int h, int pf, int flags)
 {
   int roffset = tjRedOffset[pf];
   int goffset = tjGreenOffset[pf];
@@ -174,8 +174,8 @@
 }
 
 
-int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp,
-             tjscalingfactor sf, int flags)
+static int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp,
+                    tjscalingfactor sf, int flags)
 {
   int roffset = tjRedOffset[pf];
   int goffset = tjGreenOffset[pf];
@@ -270,8 +270,8 @@
 
 #define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
 
-int checkBufYUV(unsigned char *buf, int w, int h, int subsamp,
-                tjscalingfactor sf)
+static int checkBufYUV(unsigned char *buf, int w, int h, int subsamp,
+                       tjscalingfactor sf)
 {
   int row, col;
   int hsf = tjMCUWidth[subsamp] / 8, vsf = tjMCUHeight[subsamp] / 8;
@@ -296,7 +296,7 @@
     }
   }
   if (subsamp != TJSAMP_GRAY) {
-    int halfway = 16 / vsf * sf.num / sf.denom;
+    halfway = 16 / vsf * sf.num / sf.denom;
 
     for (row = 0; row < ch; row++) {
       for (col = 0; col < cw; col++) {
@@ -342,7 +342,8 @@
 }
 
 
-void writeJPEG(unsigned char *jpegBuf, unsigned long jpegSize, char *filename)
+static void writeJPEG(unsigned char *jpegBuf, unsigned long jpegSize,
+                      char *filename)
 {
   FILE *file = fopen(filename, "wb");
 
@@ -356,9 +357,9 @@
 }
 
 
-void compTest(tjhandle handle, unsigned char **dstBuf, unsigned long *dstSize,
-              int w, int h, int pf, char *basename, int subsamp, int jpegQual,
-              int flags)
+static void compTest(tjhandle handle, unsigned char **dstBuf,
+                     unsigned long *dstSize, int w, int h, int pf,
+                     char *basename, int subsamp, int jpegQual, int flags)
 {
   char tempStr[1024];
   unsigned char *srcBuf = NULL, *yuvBuf = NULL;
@@ -414,9 +415,10 @@
 }
 
 
-void _decompTest(tjhandle handle, unsigned char *jpegBuf,
-                 unsigned long jpegSize, int w, int h, int pf, char *basename,
-                 int subsamp, int flags, tjscalingfactor sf)
+static void _decompTest(tjhandle handle, unsigned char *jpegBuf,
+                        unsigned long jpegSize, int w, int h, int pf,
+                        char *basename, int subsamp, int flags,
+                        tjscalingfactor sf)
 {
   unsigned char *dstBuf = NULL, *yuvBuf = NULL;
   int _hdrw = 0, _hdrh = 0, _hdrsubsamp = -1;
@@ -481,9 +483,9 @@
 }
 
 
-void decompTest(tjhandle handle, unsigned char *jpegBuf,
-                unsigned long jpegSize, int w, int h, int pf, char *basename,
-                int subsamp, int flags)
+static void decompTest(tjhandle handle, unsigned char *jpegBuf,
+                       unsigned long jpegSize, int w, int h, int pf,
+                       char *basename, int subsamp, int flags)
 {
   int i, n = 0;
   tjscalingfactor *sf = tjGetScalingFactors(&n);
@@ -505,8 +507,8 @@
 }
 
 
-void doTest(int w, int h, const int *formats, int nformats, int subsamp,
-            char *basename)
+static void doTest(int w, int h, const int *formats, int nformats, int subsamp,
+                   char *basename)
 {
   tjhandle chandle = NULL, dhandle = NULL;
   unsigned char *dstBuf = NULL;
@@ -552,7 +554,7 @@
 }
 
 
-void bufSizeTest(void)
+static void bufSizeTest(void)
 {
   int w, h, i, subsamp;
   unsigned char *srcBuf = NULL, *dstBuf = NULL;
@@ -633,8 +635,8 @@
 }
 
 
-void initBitmap(unsigned char *buf, int width, int pitch, int height, int pf,
-                int flags)
+static void initBitmap(unsigned char *buf, int width, int pitch, int height,
+                       int pf, int flags)
 {
   int roffset = tjRedOffset[pf];
   int goffset = tjGreenOffset[pf];
@@ -667,8 +669,8 @@
 }
 
 
-int cmpBitmap(unsigned char *buf, int width, int pitch, int height, int pf,
-              int flags, int gray2rgb)
+static int cmpBitmap(unsigned char *buf, int width, int pitch, int height,
+                     int pf, int flags, int gray2rgb)
 {
   int roffset = tjRedOffset[pf];
   int goffset = tjGreenOffset[pf];
@@ -718,8 +720,8 @@
 }
 
 
-int doBmpTest(const char *ext, int width, int align, int height, int pf,
-              int flags)
+static int doBmpTest(const char *ext, int width, int align, int height, int pf,
+                     int flags)
 {
   char filename[80], *md5sum, md5buf[65];
   int ps = tjPixelSize[pf], pitch = PAD(width * ps, align), loadWidth = 0,
@@ -807,7 +809,7 @@
 }
 
 
-int bmpTest(void)
+static int bmpTest(void)
 {
   int align, width = 35, height = 39, format;
 
diff --git a/tjutil.c b/tjutil.c
index b44086d..e4f9b42 100644
--- a/tjutil.c
+++ b/tjutil.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C)2011 D. R. Commander.  All Rights Reserved.
+ * Copyright (C)2011, 2019 D. R. Commander.  All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -26,6 +26,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "tjutil.h"
+
 #ifdef _WIN32
 
 #include <windows.h>
diff --git a/turbojpeg-jni.c b/turbojpeg-jni.c
index 070dd90..9992479 100644
--- a/turbojpeg-jni.c
+++ b/turbojpeg-jni.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C)2011-2018 D. R. Commander.  All Rights Reserved.
+ * Copyright (C)2011-2019 D. R. Commander.  All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -35,10 +35,9 @@
 #include <jni.h>
 #include "java/org_libjpegturbo_turbojpeg_TJCompressor.h"
 #include "java/org_libjpegturbo_turbojpeg_TJDecompressor.h"
+#include "java/org_libjpegturbo_turbojpeg_TJTransformer.h"
 #include "java/org_libjpegturbo_turbojpeg_TJ.h"
 
-#define PAD(v, p)  ((v + (p) - 1) & (~((p) - 1)))
-
 #define BAILIF0(f) { \
   if (!(f) || (*env)->ExceptionCheck(env)) { \
     goto bailout; \
@@ -104,7 +103,7 @@
   cArray = NULL; \
 }
 
-int ProcessSystemProperties(JNIEnv *env)
+static int ProcessSystemProperties(JNIEnv *env)
 {
   jclass cls;
   jmethodID mid;
@@ -520,7 +519,7 @@
   return;
 }
 
-JNIEXPORT void JNICALL TJCompressor_encodeYUV_12
+static void JNICALL TJCompressor_encodeYUV_12
   (JNIEnv *env, jobject obj, jarray src, jint srcElementSize, jint width,
    jint pitch, jint height, jint pf, jbyteArray dst, jint subsamp, jint flags)
 {
diff --git a/turbojpeg.c b/turbojpeg.c
index f3d0ff3..d491972 100644
--- a/turbojpeg.c
+++ b/turbojpeg.c
@@ -1364,12 +1364,12 @@
 }
 
 
-int my_read_markers(j_decompress_ptr dinfo)
+static int my_read_markers(j_decompress_ptr dinfo)
 {
   return JPEG_REACHED_SOS;
 }
 
-void my_reset_marker_reader(j_decompress_ptr dinfo)
+static void my_reset_marker_reader(j_decompress_ptr dinfo)
 {
 }