summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2023-09-03 13:10:10 -0700
committerMark Adler <madler@alumni.caltech.edu>2023-09-03 21:50:07 -0700
commitbd9c329c1055a9265812352655ed2eec93f36e92 (patch)
tree8661055737be23759ced7d2b5c2ecdf73e85c59b
parent5af7cef45eeef86ddf6ab00b4e363c1eecaf47b6 (diff)
downloadzlib-bd9c329c1055a9265812352655ed2eec93f36e92.tar.gz
zlib-bd9c329c1055a9265812352655ed2eec93f36e92.tar.bz2
zlib-bd9c329c1055a9265812352655ed2eec93f36e92.zip
Make internal functions static in the test code.
To avoid warnings when building with -Wmissing-prototypes.
-rw-r--r--test/example.c25
-rw-r--r--test/minigzip.c30
2 files changed, 28 insertions, 27 deletions
diff --git a/test/example.c b/test/example.c
index 582a17a..c3521dd 100644
--- a/test/example.c
+++ b/test/example.c
@@ -36,12 +36,12 @@ static uLong dictId; /* Adler32 value of the dictionary */
36 36
37#ifdef Z_SOLO 37#ifdef Z_SOLO
38 38
39void *myalloc(void *q, unsigned n, unsigned m) { 39static void *myalloc(void *q, unsigned n, unsigned m) {
40 (void)q; 40 (void)q;
41 return calloc(n, m); 41 return calloc(n, m);
42} 42}
43 43
44void myfree(void *q, void *p) { 44static void myfree(void *q, void *p) {
45 (void)q; 45 (void)q;
46 free(p); 46 free(p);
47} 47}
@@ -57,7 +57,7 @@ static free_func zfree = (free_func)0;
57/* =========================================================================== 57/* ===========================================================================
58 * Test compress() and uncompress() 58 * Test compress() and uncompress()
59 */ 59 */
60void test_compress(Byte *compr, uLong comprLen, Byte *uncompr, 60static void test_compress(Byte *compr, uLong comprLen, Byte *uncompr,
61 uLong uncomprLen) { 61 uLong uncomprLen) {
62 int err; 62 int err;
63 uLong len = (uLong)strlen(hello)+1; 63 uLong len = (uLong)strlen(hello)+1;
@@ -81,7 +81,7 @@ void test_compress(Byte *compr, uLong comprLen, Byte *uncompr,
81/* =========================================================================== 81/* ===========================================================================
82 * Test read/write of .gz files 82 * Test read/write of .gz files
83 */ 83 */
84void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) { 84static void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) {
85#ifdef NO_GZCOMPRESS 85#ifdef NO_GZCOMPRESS
86 fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n"); 86 fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
87#else 87#else
@@ -163,7 +163,7 @@ void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) {
163/* =========================================================================== 163/* ===========================================================================
164 * Test deflate() with small buffers 164 * Test deflate() with small buffers
165 */ 165 */
166void test_deflate(Byte *compr, uLong comprLen) { 166static void test_deflate(Byte *compr, uLong comprLen) {
167 z_stream c_stream; /* compression stream */ 167 z_stream c_stream; /* compression stream */
168 int err; 168 int err;
169 uLong len = (uLong)strlen(hello)+1; 169 uLong len = (uLong)strlen(hello)+1;
@@ -198,7 +198,7 @@ void test_deflate(Byte *compr, uLong comprLen) {
198/* =========================================================================== 198/* ===========================================================================
199 * Test inflate() with small buffers 199 * Test inflate() with small buffers
200 */ 200 */
201void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr, 201static void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
202 uLong uncomprLen) { 202 uLong uncomprLen) {
203 int err; 203 int err;
204 z_stream d_stream; /* decompression stream */ 204 z_stream d_stream; /* decompression stream */
@@ -237,7 +237,7 @@ void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
237/* =========================================================================== 237/* ===========================================================================
238 * Test deflate() with large buffers and dynamic change of compression level 238 * Test deflate() with large buffers and dynamic change of compression level
239 */ 239 */
240void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr, 240static void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
241 uLong uncomprLen) { 241 uLong uncomprLen) {
242 z_stream c_stream; /* compression stream */ 242 z_stream c_stream; /* compression stream */
243 int err; 243 int err;
@@ -290,7 +290,7 @@ void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
290/* =========================================================================== 290/* ===========================================================================
291 * Test inflate() with large buffers 291 * Test inflate() with large buffers
292 */ 292 */
293void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr, 293static void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
294 uLong uncomprLen) { 294 uLong uncomprLen) {
295 int err; 295 int err;
296 z_stream d_stream; /* decompression stream */ 296 z_stream d_stream; /* decompression stream */
@@ -329,7 +329,7 @@ void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
329/* =========================================================================== 329/* ===========================================================================
330 * Test deflate() with full flush 330 * Test deflate() with full flush
331 */ 331 */
332void test_flush(Byte *compr, uLong *comprLen) { 332static void test_flush(Byte *compr, uLong *comprLen) {
333 z_stream c_stream; /* compression stream */ 333 z_stream c_stream; /* compression stream */
334 int err; 334 int err;
335 uInt len = (uInt)strlen(hello)+1; 335 uInt len = (uInt)strlen(hello)+1;
@@ -364,7 +364,8 @@ void test_flush(Byte *compr, uLong *comprLen) {
364/* =========================================================================== 364/* ===========================================================================
365 * Test inflateSync() 365 * Test inflateSync()
366 */ 366 */
367void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) { 367static void test_sync(Byte *compr, uLong comprLen, Byte *uncompr,
368 uLong uncomprLen) {
368 int err; 369 int err;
369 z_stream d_stream; /* decompression stream */ 370 z_stream d_stream; /* decompression stream */
370 371
@@ -404,7 +405,7 @@ void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) {
404/* =========================================================================== 405/* ===========================================================================
405 * Test deflate() with preset dictionary 406 * Test deflate() with preset dictionary
406 */ 407 */
407void test_dict_deflate(Byte *compr, uLong comprLen) { 408static void test_dict_deflate(Byte *compr, uLong comprLen) {
408 z_stream c_stream; /* compression stream */ 409 z_stream c_stream; /* compression stream */
409 int err; 410 int err;
410 411
@@ -438,7 +439,7 @@ void test_dict_deflate(Byte *compr, uLong comprLen) {
438/* =========================================================================== 439/* ===========================================================================
439 * Test inflate() with a preset dictionary 440 * Test inflate() with a preset dictionary
440 */ 441 */
441void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr, 442static void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
442 uLong uncomprLen) { 443 uLong uncomprLen) {
443 int err; 444 int err;
444 z_stream d_stream; /* decompression stream */ 445 z_stream d_stream; /* decompression stream */
diff --git a/test/minigzip.c b/test/minigzip.c
index 8a21ddf..c72356d 100644
--- a/test/minigzip.c
+++ b/test/minigzip.c
@@ -149,12 +149,12 @@ static void pwinerror (s)
149# include <unistd.h> /* for unlink() */ 149# include <unistd.h> /* for unlink() */
150#endif 150#endif
151 151
152void *myalloc(void *q, unsigned n, unsigned m) { 152static void *myalloc(void *q, unsigned n, unsigned m) {
153 (void)q; 153 (void)q;
154 return calloc(n, m); 154 return calloc(n, m);
155} 155}
156 156
157void myfree(void *q, void *p) { 157static void myfree(void *q, void *p) {
158 (void)q; 158 (void)q;
159 free(p); 159 free(p);
160} 160}
@@ -167,7 +167,7 @@ typedef struct gzFile_s {
167 z_stream strm; 167 z_stream strm;
168} *gzFile; 168} *gzFile;
169 169
170gzFile gz_open(const char *path, int fd, const char *mode) { 170static gzFile gz_open(const char *path, int fd, const char *mode) {
171 gzFile gz; 171 gzFile gz;
172 int ret; 172 int ret;
173 173
@@ -201,15 +201,15 @@ gzFile gz_open(const char *path, int fd, const char *mode) {
201 return gz; 201 return gz;
202} 202}
203 203
204gzFile gzopen(const char *path, const char *mode) { 204static gzFile gzopen(const char *path, const char *mode) {
205 return gz_open(path, -1, mode); 205 return gz_open(path, -1, mode);
206} 206}
207 207
208gzFile gzdopen(int fd, const char *mode) { 208static gzFile gzdopen(int fd, const char *mode) {
209 return gz_open(NULL, fd, mode); 209 return gz_open(NULL, fd, mode);
210} 210}
211 211
212int gzwrite(gzFile gz, const void *buf, unsigned len) { 212static int gzwrite(gzFile gz, const void *buf, unsigned len) {
213 z_stream *strm; 213 z_stream *strm;
214 unsigned char out[BUFLEN]; 214 unsigned char out[BUFLEN];
215 215
@@ -227,7 +227,7 @@ int gzwrite(gzFile gz, const void *buf, unsigned len) {
227 return len; 227 return len;
228} 228}
229 229
230int gzread(gzFile gz, void *buf, unsigned len) { 230static int gzread(gzFile gz, void *buf, unsigned len) {
231 int ret; 231 int ret;
232 unsigned got; 232 unsigned got;
233 unsigned char in[1]; 233 unsigned char in[1];
@@ -258,7 +258,7 @@ int gzread(gzFile gz, void *buf, unsigned len) {
258 return len - strm->avail_out; 258 return len - strm->avail_out;
259} 259}
260 260
261int gzclose(gzFile gz) { 261static int gzclose(gzFile gz) {
262 z_stream *strm; 262 z_stream *strm;
263 unsigned char out[BUFLEN]; 263 unsigned char out[BUFLEN];
264 264
@@ -283,7 +283,7 @@ int gzclose(gzFile gz) {
283 return Z_OK; 283 return Z_OK;
284} 284}
285 285
286const char *gzerror(gzFile gz, int *err) { 286static const char *gzerror(gzFile gz, int *err) {
287 *err = gz->err; 287 *err = gz->err;
288 return gz->msg; 288 return gz->msg;
289} 289}
@@ -295,7 +295,7 @@ static char *prog;
295/* =========================================================================== 295/* ===========================================================================
296 * Display error message and exit 296 * Display error message and exit
297 */ 297 */
298void error(const char *msg) { 298static void error(const char *msg) {
299 fprintf(stderr, "%s: %s\n", prog, msg); 299 fprintf(stderr, "%s: %s\n", prog, msg);
300 exit(1); 300 exit(1);
301} 301}
@@ -305,7 +305,7 @@ void error(const char *msg) {
305/* Try compressing the input file at once using mmap. Return Z_OK if 305/* Try compressing the input file at once using mmap. Return Z_OK if
306 * if success, Z_ERRNO otherwise. 306 * if success, Z_ERRNO otherwise.
307 */ 307 */
308int gz_compress_mmap(FILE *in, gzFile out) { 308static int gz_compress_mmap(FILE *in, gzFile out) {
309 int len; 309 int len;
310 int err; 310 int err;
311 int ifd = fileno(in); 311 int ifd = fileno(in);
@@ -338,7 +338,7 @@ int gz_compress_mmap(FILE *in, gzFile out) {
338 * Compress input to output then close both files. 338 * Compress input to output then close both files.
339 */ 339 */
340 340
341void gz_compress(FILE *in, gzFile out) { 341static void gz_compress(FILE *in, gzFile out) {
342 local char buf[BUFLEN]; 342 local char buf[BUFLEN];
343 int len; 343 int len;
344 int err; 344 int err;
@@ -366,7 +366,7 @@ void gz_compress(FILE *in, gzFile out) {
366/* =========================================================================== 366/* ===========================================================================
367 * Uncompress input to output then close both files. 367 * Uncompress input to output then close both files.
368 */ 368 */
369void gz_uncompress(gzFile in, FILE *out) { 369static void gz_uncompress(gzFile in, FILE *out) {
370 local char buf[BUFLEN]; 370 local char buf[BUFLEN];
371 int len; 371 int len;
372 int err; 372 int err;
@@ -390,7 +390,7 @@ void gz_uncompress(gzFile in, FILE *out) {
390 * Compress the given file: create a corresponding .gz file and remove the 390 * Compress the given file: create a corresponding .gz file and remove the
391 * original. 391 * original.
392 */ 392 */
393void file_compress(char *file, char *mode) { 393static void file_compress(char *file, char *mode) {
394 local char outfile[MAX_NAME_LEN]; 394 local char outfile[MAX_NAME_LEN];
395 FILE *in; 395 FILE *in;
396 gzFile out; 396 gzFile out;
@@ -426,7 +426,7 @@ void file_compress(char *file, char *mode) {
426/* =========================================================================== 426/* ===========================================================================
427 * Uncompress the given file and remove the original. 427 * Uncompress the given file and remove the original.
428 */ 428 */
429void file_uncompress(char *file) { 429static void file_uncompress(char *file) {
430 local char buf[MAX_NAME_LEN]; 430 local char buf[MAX_NAME_LEN];
431 char *infile, *outfile; 431 char *infile, *outfile;
432 FILE *out; 432 FILE *out;