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 <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2018-08-11 20:43:00 -07:00
parent 991f5a6e85
commit f033cd542e
1 changed files with 6 additions and 12 deletions

View File

@ -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);