Make internal functions static in the test code.

To avoid warnings when building with -Wmissing-prototypes.
pull/833/head
Xin LI 2 years ago committed by Mark Adler
parent 5af7cef45e
commit bd9c329c10
  1. 25
      test/example.c
  2. 30
      test/minigzip.c

@ -36,12 +36,12 @@ static uLong dictId; /* Adler32 value of the dictionary */
#ifdef Z_SOLO #ifdef Z_SOLO
void *myalloc(void *q, unsigned n, unsigned m) { static void *myalloc(void *q, unsigned n, unsigned m) {
(void)q; (void)q;
return calloc(n, m); return calloc(n, m);
} }
void myfree(void *q, void *p) { static void myfree(void *q, void *p) {
(void)q; (void)q;
free(p); free(p);
} }
@ -57,7 +57,7 @@ static free_func zfree = (free_func)0;
/* =========================================================================== /* ===========================================================================
* Test compress() and uncompress() * Test compress() and uncompress()
*/ */
void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, static void test_compress(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) { uLong uncomprLen) {
int err; int err;
uLong len = (uLong)strlen(hello)+1; uLong len = (uLong)strlen(hello)+1;
@ -81,7 +81,7 @@ void test_compress(Byte *compr, uLong comprLen, Byte *uncompr,
/* =========================================================================== /* ===========================================================================
* Test read/write of .gz files * Test read/write of .gz files
*/ */
void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) { static void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) {
#ifdef NO_GZCOMPRESS #ifdef NO_GZCOMPRESS
fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
#else #else
@ -163,7 +163,7 @@ void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) {
/* =========================================================================== /* ===========================================================================
* Test deflate() with small buffers * Test deflate() with small buffers
*/ */
void test_deflate(Byte *compr, uLong comprLen) { static void test_deflate(Byte *compr, uLong comprLen) {
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
uLong len = (uLong)strlen(hello)+1; uLong len = (uLong)strlen(hello)+1;
@ -198,7 +198,7 @@ void test_deflate(Byte *compr, uLong comprLen) {
/* =========================================================================== /* ===========================================================================
* Test inflate() with small buffers * Test inflate() with small buffers
*/ */
void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, static void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) { uLong uncomprLen) {
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -237,7 +237,7 @@ void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
/* =========================================================================== /* ===========================================================================
* Test deflate() with large buffers and dynamic change of compression level * Test deflate() with large buffers and dynamic change of compression level
*/ */
void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, static void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) { uLong uncomprLen) {
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
@ -290,7 +290,7 @@ void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
/* =========================================================================== /* ===========================================================================
* Test inflate() with large buffers * Test inflate() with large buffers
*/ */
void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, static void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) { uLong uncomprLen) {
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -329,7 +329,7 @@ void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
/* =========================================================================== /* ===========================================================================
* Test deflate() with full flush * Test deflate() with full flush
*/ */
void test_flush(Byte *compr, uLong *comprLen) { static void test_flush(Byte *compr, uLong *comprLen) {
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
uInt len = (uInt)strlen(hello)+1; uInt len = (uInt)strlen(hello)+1;
@ -364,7 +364,8 @@ void test_flush(Byte *compr, uLong *comprLen) {
/* =========================================================================== /* ===========================================================================
* Test inflateSync() * Test inflateSync()
*/ */
void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) { static void test_sync(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) {
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */
@ -404,7 +405,7 @@ void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) {
/* =========================================================================== /* ===========================================================================
* Test deflate() with preset dictionary * Test deflate() with preset dictionary
*/ */
void test_dict_deflate(Byte *compr, uLong comprLen) { static void test_dict_deflate(Byte *compr, uLong comprLen) {
z_stream c_stream; /* compression stream */ z_stream c_stream; /* compression stream */
int err; int err;
@ -438,7 +439,7 @@ void test_dict_deflate(Byte *compr, uLong comprLen) {
/* =========================================================================== /* ===========================================================================
* Test inflate() with a preset dictionary * Test inflate() with a preset dictionary
*/ */
void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, static void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
uLong uncomprLen) { uLong uncomprLen) {
int err; int err;
z_stream d_stream; /* decompression stream */ z_stream d_stream; /* decompression stream */

@ -149,12 +149,12 @@ static void pwinerror (s)
# include <unistd.h> /* for unlink() */ # include <unistd.h> /* for unlink() */
#endif #endif
void *myalloc(void *q, unsigned n, unsigned m) { static void *myalloc(void *q, unsigned n, unsigned m) {
(void)q; (void)q;
return calloc(n, m); return calloc(n, m);
} }
void myfree(void *q, void *p) { static void myfree(void *q, void *p) {
(void)q; (void)q;
free(p); free(p);
} }
@ -167,7 +167,7 @@ typedef struct gzFile_s {
z_stream strm; z_stream strm;
} *gzFile; } *gzFile;
gzFile gz_open(const char *path, int fd, const char *mode) { static gzFile gz_open(const char *path, int fd, const char *mode) {
gzFile gz; gzFile gz;
int ret; int ret;
@ -201,15 +201,15 @@ gzFile gz_open(const char *path, int fd, const char *mode) {
return gz; return gz;
} }
gzFile gzopen(const char *path, const char *mode) { static gzFile gzopen(const char *path, const char *mode) {
return gz_open(path, -1, mode); return gz_open(path, -1, mode);
} }
gzFile gzdopen(int fd, const char *mode) { static gzFile gzdopen(int fd, const char *mode) {
return gz_open(NULL, fd, mode); return gz_open(NULL, fd, mode);
} }
int gzwrite(gzFile gz, const void *buf, unsigned len) { static int gzwrite(gzFile gz, const void *buf, unsigned len) {
z_stream *strm; z_stream *strm;
unsigned char out[BUFLEN]; unsigned char out[BUFLEN];
@ -227,7 +227,7 @@ int gzwrite(gzFile gz, const void *buf, unsigned len) {
return len; return len;
} }
int gzread(gzFile gz, void *buf, unsigned len) { static int gzread(gzFile gz, void *buf, unsigned len) {
int ret; int ret;
unsigned got; unsigned got;
unsigned char in[1]; unsigned char in[1];
@ -258,7 +258,7 @@ int gzread(gzFile gz, void *buf, unsigned len) {
return len - strm->avail_out; return len - strm->avail_out;
} }
int gzclose(gzFile gz) { static int gzclose(gzFile gz) {
z_stream *strm; z_stream *strm;
unsigned char out[BUFLEN]; unsigned char out[BUFLEN];
@ -283,7 +283,7 @@ int gzclose(gzFile gz) {
return Z_OK; return Z_OK;
} }
const char *gzerror(gzFile gz, int *err) { static const char *gzerror(gzFile gz, int *err) {
*err = gz->err; *err = gz->err;
return gz->msg; return gz->msg;
} }
@ -295,7 +295,7 @@ static char *prog;
/* =========================================================================== /* ===========================================================================
* Display error message and exit * Display error message and exit
*/ */
void error(const char *msg) { static void error(const char *msg) {
fprintf(stderr, "%s: %s\n", prog, msg); fprintf(stderr, "%s: %s\n", prog, msg);
exit(1); exit(1);
} }
@ -305,7 +305,7 @@ void error(const char *msg) {
/* Try compressing the input file at once using mmap. Return Z_OK if /* Try compressing the input file at once using mmap. Return Z_OK if
* if success, Z_ERRNO otherwise. * if success, Z_ERRNO otherwise.
*/ */
int gz_compress_mmap(FILE *in, gzFile out) { static int gz_compress_mmap(FILE *in, gzFile out) {
int len; int len;
int err; int err;
int ifd = fileno(in); int ifd = fileno(in);
@ -338,7 +338,7 @@ int gz_compress_mmap(FILE *in, gzFile out) {
* Compress input to output then close both files. * Compress input to output then close both files.
*/ */
void gz_compress(FILE *in, gzFile out) { static void gz_compress(FILE *in, gzFile out) {
local char buf[BUFLEN]; local char buf[BUFLEN];
int len; int len;
int err; int err;
@ -366,7 +366,7 @@ void gz_compress(FILE *in, gzFile out) {
/* =========================================================================== /* ===========================================================================
* Uncompress input to output then close both files. * Uncompress input to output then close both files.
*/ */
void gz_uncompress(gzFile in, FILE *out) { static void gz_uncompress(gzFile in, FILE *out) {
local char buf[BUFLEN]; local char buf[BUFLEN];
int len; int len;
int err; int err;
@ -390,7 +390,7 @@ void gz_uncompress(gzFile in, FILE *out) {
* Compress the given file: create a corresponding .gz file and remove the * Compress the given file: create a corresponding .gz file and remove the
* original. * original.
*/ */
void file_compress(char *file, char *mode) { static void file_compress(char *file, char *mode) {
local char outfile[MAX_NAME_LEN]; local char outfile[MAX_NAME_LEN];
FILE *in; FILE *in;
gzFile out; gzFile out;
@ -426,7 +426,7 @@ void file_compress(char *file, char *mode) {
/* =========================================================================== /* ===========================================================================
* Uncompress the given file and remove the original. * Uncompress the given file and remove the original.
*/ */
void file_uncompress(char *file) { static void file_uncompress(char *file) {
local char buf[MAX_NAME_LEN]; local char buf[MAX_NAME_LEN];
char *infile, *outfile; char *infile, *outfile;
FILE *out; FILE *out;

Loading…
Cancel
Save