Skip to content

Commit 8fac227

Browse files
committed
Update the -z option processing
It can only be used if defined(HAVE_FORK) || defined(HAVE_VFORK). This avoid: tcpdump.c:3140:31: warning: unused parameter 'filename' [-Wunused-parameter] compress_savefile(const char *filename)
1 parent c6aa6c2 commit 8fac227

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tcpdump.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ static int Qflag = -1; /* restrict captured packet by send/receive direction *
203203
static int Uflag; /* "unbuffered" output of dump files */
204204
static int Wflag; /* recycle output files after this number of files */
205205
static int WflagChars;
206+
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
206207
static char *zflag = NULL; /* compress each savefile using a specified command (like gzip or bzip2) */
208+
#endif
207209
static int timeout = 1000; /* default timeout = 1000 ms = 1 s */
208210
#ifdef HAVE_PCAP_SET_IMMEDIATE_MODE
209211
static int immediate_mode;
@@ -2014,7 +2016,11 @@ main(int argc, char **argv)
20142016
break;
20152017
#endif
20162018
case 'z':
2019+
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
20172020
zflag = optarg;
2021+
#else
2022+
warning("-z ignored. Fork subprocess not implemented.\n");
2023+
#endif
20182024
break;
20192025

20202026
case 'Z':
@@ -3134,15 +3140,7 @@ compress_savefile(const char *filename)
31343140
_exit(S_ERR_HOST_PROGRAM);
31353141
#endif
31363142
}
3137-
#else /* HAVE_FORK && HAVE_VFORK */
3138-
static void
3139-
compress_savefile(const char *filename)
3140-
{
3141-
fprintf(stderr,
3142-
"%s failed. Functionality not implemented under your system\n",
3143-
__func__);
3144-
}
3145-
#endif /* HAVE_FORK && HAVE_VFORK */
3143+
#endif /* HAVE_FORK || HAVE_VFORK */
31463144

31473145
static void
31483146
close_old_dump_file(struct dump_info *dump_info)
@@ -3152,11 +3150,13 @@ close_old_dump_file(struct dump_info *dump_info)
31523150
*/
31533151
pcap_dump_close(dump_info->pdd);
31543152

3153+
#if defined(HAVE_FORK) || defined(HAVE_VFORK)
31553154
/*
31563155
* Compress the file we just closed, if the user asked for it.
31573156
*/
31583157
if (zflag != NULL)
31593158
compress_savefile(dump_info->CurrentFileName);
3159+
#endif
31603160
}
31613161

31623162
static void

0 commit comments

Comments
 (0)