Simplify the mode passed to CreateNamedPipe().
There's one mode you use if byte_mode is true, and another mode you use if it's false. My head hurts when I try to pretend to be a top-down parser for C and feed myself the existing expression, and Visual Studio Code Analyzer says "are you sure that's what you had in mind?", so I'm guessing the modes are: byte mode: PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT not byte mode: PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT and am just using one test of byte_mode to choose between them. Put the entire function under an #ifdef, so we can mark the byte_mode argument as unused on UN*X but not on Windows. Change-Id: Ib2d0b80f870b1789c1375ccb017bd90e93dca5ce Reviewed-on: https://code.wireshark.org/review/26201 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
efd8beff4f
commit
00373a1fd4
14
extcap.c
14
extcap.c
|
@ -1382,9 +1382,9 @@ extcap_init_interfaces(capture_options *capture_opts)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean extcap_create_pipe(const gchar *ifname, gchar **fifo, const gchar *pipe_prefix, gboolean byte_mode _U_)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
gboolean extcap_create_pipe(const gchar *ifname, gchar **fifo, const gchar *pipe_prefix, gboolean byte_mode)
|
||||
{
|
||||
gchar timestr[ 14 + 1 ];
|
||||
time_t current_time;
|
||||
gchar *pipename = NULL;
|
||||
|
@ -1409,7 +1409,8 @@ gboolean extcap_create_pipe(const gchar *ifname, gchar **fifo, const gchar *pipe
|
|||
pipe_h = CreateNamedPipe(
|
||||
utf_8to16(pipename),
|
||||
PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
|
||||
byte_mode ? PIPE_TYPE_BYTE : PIPE_TYPE_MESSAGE | byte_mode ? PIPE_READMODE_BYTE : PIPE_READMODE_MESSAGE | PIPE_WAIT,
|
||||
(byte_mode ? (PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT) :
|
||||
(PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT)),
|
||||
1, 65536, 65536,
|
||||
300,
|
||||
&security);
|
||||
|
@ -1425,7 +1426,12 @@ gboolean extcap_create_pipe(const gchar *ifname, gchar **fifo, const gchar *pipe
|
|||
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "\nWireshark Created pipe =>(%s)", pipename);
|
||||
*fifo = g_strdup(pipename);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
gboolean extcap_create_pipe(const gchar *ifname, gchar **fifo, const gchar *pipe_prefix, gboolean byte_mode _U_)
|
||||
{
|
||||
gchar *temp_name = NULL;
|
||||
int fd = 0;
|
||||
|
||||
|
@ -1451,10 +1457,10 @@ gboolean extcap_create_pipe(const gchar *ifname, gchar **fifo, const gchar *pipe
|
|||
{
|
||||
*fifo = g_strdup(temp_name);
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
/************* EXTCAP LOAD INTERFACE LIST ***************
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue