diff options
author | Guy Harris <guy@alum.mit.edu> | 2018-02-28 18:43:44 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2018-03-01 04:05:03 +0000 |
commit | 00373a1fd4f4cd75a0fb2f2c21b7d9fd567a41b9 (patch) | |
tree | 4f8b3128c4d39adc26137fbca760d89ba2a12d51 /extcap.c | |
parent | efd8beff4f9a6b39a7b43b18716bceb4a9f07e1f (diff) |
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>
Diffstat (limited to 'extcap.c')
-rw-r--r-- | extcap.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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 *************** * |