Skip to content

Commit bd9c329

Browse files
delphijmadler
authored andcommitted
Make internal functions static in the test code.
To avoid warnings when building with -Wmissing-prototypes.
1 parent 5af7cef commit bd9c329

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

test/example.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ static uLong dictId; /* Adler32 value of the dictionary */
3636

3737
#ifdef Z_SOLO
3838

39-
void *myalloc(void *q, unsigned n, unsigned m) {
39+
static void *myalloc(void *q, unsigned n, unsigned m) {
4040
(void)q;
4141
return calloc(n, m);
4242
}
4343

44-
void myfree(void *q, void *p) {
44+
static void myfree(void *q, void *p) {
4545
(void)q;
4646
free(p);
4747
}
@@ -57,7 +57,7 @@ static free_func zfree = (free_func)0;
5757
/* ===========================================================================
5858
* Test compress() and uncompress()
5959
*/
60-
void test_compress(Byte *compr, uLong comprLen, Byte *uncompr,
60+
static void test_compress(Byte *compr, uLong comprLen, Byte *uncompr,
6161
uLong uncomprLen) {
6262
int err;
6363
uLong len = (uLong)strlen(hello)+1;
@@ -81,7 +81,7 @@ void test_compress(Byte *compr, uLong comprLen, Byte *uncompr,
8181
/* ===========================================================================
8282
* Test read/write of .gz files
8383
*/
84-
void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) {
84+
static void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) {
8585
#ifdef NO_GZCOMPRESS
8686
fprintf(stderr, "NO_GZCOMPRESS -- gz* functions cannot compress\n");
8787
#else
@@ -163,7 +163,7 @@ void test_gzio(const char *fname, Byte *uncompr, uLong uncomprLen) {
163163
/* ===========================================================================
164164
* Test deflate() with small buffers
165165
*/
166-
void test_deflate(Byte *compr, uLong comprLen) {
166+
static void test_deflate(Byte *compr, uLong comprLen) {
167167
z_stream c_stream; /* compression stream */
168168
int err;
169169
uLong len = (uLong)strlen(hello)+1;
@@ -198,7 +198,7 @@ void test_deflate(Byte *compr, uLong comprLen) {
198198
/* ===========================================================================
199199
* Test inflate() with small buffers
200200
*/
201-
void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
201+
static void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
202202
uLong uncomprLen) {
203203
int err;
204204
z_stream d_stream; /* decompression stream */
@@ -237,7 +237,7 @@ void test_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
237237
/* ===========================================================================
238238
* Test deflate() with large buffers and dynamic change of compression level
239239
*/
240-
void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
240+
static void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
241241
uLong uncomprLen) {
242242
z_stream c_stream; /* compression stream */
243243
int err;
@@ -290,7 +290,7 @@ void test_large_deflate(Byte *compr, uLong comprLen, Byte *uncompr,
290290
/* ===========================================================================
291291
* Test inflate() with large buffers
292292
*/
293-
void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
293+
static void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
294294
uLong uncomprLen) {
295295
int err;
296296
z_stream d_stream; /* decompression stream */
@@ -329,7 +329,7 @@ void test_large_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
329329
/* ===========================================================================
330330
* Test deflate() with full flush
331331
*/
332-
void test_flush(Byte *compr, uLong *comprLen) {
332+
static void test_flush(Byte *compr, uLong *comprLen) {
333333
z_stream c_stream; /* compression stream */
334334
int err;
335335
uInt len = (uInt)strlen(hello)+1;
@@ -364,7 +364,8 @@ void test_flush(Byte *compr, uLong *comprLen) {
364364
/* ===========================================================================
365365
* Test inflateSync()
366366
*/
367-
void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) {
367+
static void test_sync(Byte *compr, uLong comprLen, Byte *uncompr,
368+
uLong uncomprLen) {
368369
int err;
369370
z_stream d_stream; /* decompression stream */
370371

@@ -404,7 +405,7 @@ void test_sync(Byte *compr, uLong comprLen, Byte *uncompr, uLong uncomprLen) {
404405
/* ===========================================================================
405406
* Test deflate() with preset dictionary
406407
*/
407-
void test_dict_deflate(Byte *compr, uLong comprLen) {
408+
static void test_dict_deflate(Byte *compr, uLong comprLen) {
408409
z_stream c_stream; /* compression stream */
409410
int err;
410411

@@ -438,7 +439,7 @@ void test_dict_deflate(Byte *compr, uLong comprLen) {
438439
/* ===========================================================================
439440
* Test inflate() with a preset dictionary
440441
*/
441-
void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
442+
static void test_dict_inflate(Byte *compr, uLong comprLen, Byte *uncompr,
442443
uLong uncomprLen) {
443444
int err;
444445
z_stream d_stream; /* decompression stream */

test/minigzip.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ static void pwinerror (s)
149149
# include <unistd.h> /* for unlink() */
150150
#endif
151151

152-
void *myalloc(void *q, unsigned n, unsigned m) {
152+
static void *myalloc(void *q, unsigned n, unsigned m) {
153153
(void)q;
154154
return calloc(n, m);
155155
}
156156

157-
void myfree(void *q, void *p) {
157+
static void myfree(void *q, void *p) {
158158
(void)q;
159159
free(p);
160160
}
@@ -167,7 +167,7 @@ typedef struct gzFile_s {
167167
z_stream strm;
168168
} *gzFile;
169169

170-
gzFile gz_open(const char *path, int fd, const char *mode) {
170+
static gzFile gz_open(const char *path, int fd, const char *mode) {
171171
gzFile gz;
172172
int ret;
173173

@@ -201,15 +201,15 @@ gzFile gz_open(const char *path, int fd, const char *mode) {
201201
return gz;
202202
}
203203

204-
gzFile gzopen(const char *path, const char *mode) {
204+
static gzFile gzopen(const char *path, const char *mode) {
205205
return gz_open(path, -1, mode);
206206
}
207207

208-
gzFile gzdopen(int fd, const char *mode) {
208+
static gzFile gzdopen(int fd, const char *mode) {
209209
return gz_open(NULL, fd, mode);
210210
}
211211

212-
int gzwrite(gzFile gz, const void *buf, unsigned len) {
212+
static int gzwrite(gzFile gz, const void *buf, unsigned len) {
213213
z_stream *strm;
214214
unsigned char out[BUFLEN];
215215

@@ -227,7 +227,7 @@ int gzwrite(gzFile gz, const void *buf, unsigned len) {
227227
return len;
228228
}
229229

230-
int gzread(gzFile gz, void *buf, unsigned len) {
230+
static int gzread(gzFile gz, void *buf, unsigned len) {
231231
int ret;
232232
unsigned got;
233233
unsigned char in[1];
@@ -258,7 +258,7 @@ int gzread(gzFile gz, void *buf, unsigned len) {
258258
return len - strm->avail_out;
259259
}
260260

261-
int gzclose(gzFile gz) {
261+
static int gzclose(gzFile gz) {
262262
z_stream *strm;
263263
unsigned char out[BUFLEN];
264264

@@ -283,7 +283,7 @@ int gzclose(gzFile gz) {
283283
return Z_OK;
284284
}
285285

286-
const char *gzerror(gzFile gz, int *err) {
286+
static const char *gzerror(gzFile gz, int *err) {
287287
*err = gz->err;
288288
return gz->msg;
289289
}
@@ -295,7 +295,7 @@ static char *prog;
295295
/* ===========================================================================
296296
* Display error message and exit
297297
*/
298-
void error(const char *msg) {
298+
static void error(const char *msg) {
299299
fprintf(stderr, "%s: %s\n", prog, msg);
300300
exit(1);
301301
}
@@ -305,7 +305,7 @@ void error(const char *msg) {
305305
/* Try compressing the input file at once using mmap. Return Z_OK if
306306
* if success, Z_ERRNO otherwise.
307307
*/
308-
int gz_compress_mmap(FILE *in, gzFile out) {
308+
static int gz_compress_mmap(FILE *in, gzFile out) {
309309
int len;
310310
int err;
311311
int ifd = fileno(in);
@@ -338,7 +338,7 @@ int gz_compress_mmap(FILE *in, gzFile out) {
338338
* Compress input to output then close both files.
339339
*/
340340

341-
void gz_compress(FILE *in, gzFile out) {
341+
static void gz_compress(FILE *in, gzFile out) {
342342
local char buf[BUFLEN];
343343
int len;
344344
int err;
@@ -366,7 +366,7 @@ void gz_compress(FILE *in, gzFile out) {
366366
/* ===========================================================================
367367
* Uncompress input to output then close both files.
368368
*/
369-
void gz_uncompress(gzFile in, FILE *out) {
369+
static void gz_uncompress(gzFile in, FILE *out) {
370370
local char buf[BUFLEN];
371371
int len;
372372
int err;
@@ -390,7 +390,7 @@ void gz_uncompress(gzFile in, FILE *out) {
390390
* Compress the given file: create a corresponding .gz file and remove the
391391
* original.
392392
*/
393-
void file_compress(char *file, char *mode) {
393+
static void file_compress(char *file, char *mode) {
394394
local char outfile[MAX_NAME_LEN];
395395
FILE *in;
396396
gzFile out;
@@ -426,7 +426,7 @@ void file_compress(char *file, char *mode) {
426426
/* ===========================================================================
427427
* Uncompress the given file and remove the original.
428428
*/
429-
void file_uncompress(char *file) {
429+
static void file_uncompress(char *file) {
430430
local char buf[MAX_NAME_LEN];
431431
char *infile, *outfile;
432432
FILE *out;

0 commit comments

Comments
 (0)