From f033cd542efbfa857622853d5b3e53c712cf8344 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 11 Aug 2018 20:43:00 -0700 Subject: [PATCH] Clean up temporary filename generation. Don't put identical code in both arms of a conditional - move it out of the conditional. Doing that with one line of code means that the conditional is now *itself* duplicated in both arms of a conditional, so move it out, too. Change-Id: I07c1d00e7d0053684aa2ef74b460eb008b145015 Reviewed-on: https://code.wireshark.org/review/29093 Reviewed-by: Guy Harris --- dumpcap.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/dumpcap.c b/dumpcap.c index e3d4f80785..cca3d4bc1a 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -3304,11 +3304,6 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd, /* Choose a random name for the temporary capture buffer */ if (global_capture_opts.ifaces->len > 1) { prefix = g_strdup_printf("wireshark_%d_interfaces", global_capture_opts.ifaces->len); - if (capture_opts->use_pcapng) { - suffix = ".pcapng"; - }else{ - suffix = ".pcap"; - } } else { gchar *basename; basename = g_path_get_basename((&g_array_index(global_capture_opts.ifaces, interface_options, 0))->console_display_name); @@ -3325,15 +3320,14 @@ capture_loop_open_output(capture_options *capture_opts, int *save_file_fd, } #endif /* generate the temp file name prefix and suffix */ - if (capture_opts->use_pcapng) { - prefix = g_strconcat("wireshark_", basename, NULL); - suffix = ".pcapng"; - }else{ - prefix = g_strconcat("wireshark_", basename, NULL); - suffix = ".pcap"; - } + prefix = g_strconcat("wireshark_", basename, NULL); g_free(basename); } + if (capture_opts->use_pcapng) { + suffix = ".pcapng"; + } else { + suffix = ".pcap"; + } *save_file_fd = create_tempfile(&tmpname, prefix, suffix); g_free(prefix); capfile_name = g_strdup(tmpname);