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/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;