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:
parent
991f5a6e85
commit
f033cd542e
12
dumpcap.c
12
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 */
|
/* Choose a random name for the temporary capture buffer */
|
||||||
if (global_capture_opts.ifaces->len > 1) {
|
if (global_capture_opts.ifaces->len > 1) {
|
||||||
prefix = g_strdup_printf("wireshark_%d_interfaces", global_capture_opts.ifaces->len);
|
prefix = g_strdup_printf("wireshark_%d_interfaces", global_capture_opts.ifaces->len);
|
||||||
if (capture_opts->use_pcapng) {
|
|
||||||
suffix = ".pcapng";
|
|
||||||
}else{
|
|
||||||
suffix = ".pcap";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
gchar *basename;
|
gchar *basename;
|
||||||
basename = g_path_get_basename((&g_array_index(global_capture_opts.ifaces, interface_options, 0))->console_display_name);
|
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
|
#endif
|
||||||
/* generate the temp file name prefix and suffix */
|
/* generate the temp file name prefix and suffix */
|
||||||
if (capture_opts->use_pcapng) {
|
|
||||||
prefix = g_strconcat("wireshark_", basename, NULL);
|
prefix = g_strconcat("wireshark_", basename, NULL);
|
||||||
|
g_free(basename);
|
||||||
|
}
|
||||||
|
if (capture_opts->use_pcapng) {
|
||||||
suffix = ".pcapng";
|
suffix = ".pcapng";
|
||||||
} else {
|
} else {
|
||||||
prefix = g_strconcat("wireshark_", basename, NULL);
|
|
||||||
suffix = ".pcap";
|
suffix = ".pcap";
|
||||||
}
|
}
|
||||||
g_free(basename);
|
|
||||||
}
|
|
||||||
*save_file_fd = create_tempfile(&tmpname, prefix, suffix);
|
*save_file_fd = create_tempfile(&tmpname, prefix, suffix);
|
||||||
g_free(prefix);
|
g_free(prefix);
|
||||||
capfile_name = g_strdup(tmpname);
|
capfile_name = g_strdup(tmpname);
|
||||||
|
|
Loading…
Reference in New Issue