aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2023-08-16 15:34:55 -0700
committerGuy Harris <gharris@sonic.net>2023-08-16 15:34:55 -0700
commit14b8bc66e8038da56309b67b319ebcc0a341f053 (patch)
tree4ecfffd453c918a322c1b9e583ae9ad4fcfd2061
parent50778cff57b56faa05f74aeafbf32cab27de80ad (diff)
Initialize global_dissect_options at compile time.
We require a C11 compiler, and designated initializers have been in C since C99. Use them to initialize the time format and precision values at compile time, rather than requiring that dissect_opts_init() be called before the command-line arguments are parsed. This is good because TShark and rawshark were *not* calling dissect_opts_init(); that doesn't appear to have caused problems with existing versions, but it might be causing problems with another pending change that's failing to pass the test suite.
-rw-r--r--ui/commandline.c1
-rw-r--r--ui/dissect_opts.c16
-rw-r--r--ui/dissect_opts.h4
3 files changed, 4 insertions, 17 deletions
diff --git a/ui/commandline.c b/ui/commandline.c
index e39e2e9d96..c203281bfc 100644
--- a/ui/commandline.c
+++ b/ui/commandline.c
@@ -417,7 +417,6 @@ void commandline_other_options(int argc, char *argv[], gboolean opt_reset)
}
/* Initialize with default values */
- dissect_opts_init();
global_commandline_info.jump_backwards = SD_FORWARD;
global_commandline_info.go_to_packet = 0;
global_commandline_info.jfilter = NULL;
diff --git a/ui/dissect_opts.c b/ui/dissect_opts.c
index 27c21dfaa6..e26653d316 100644
--- a/ui/dissect_opts.c
+++ b/ui/dissect_opts.c
@@ -35,18 +35,10 @@
#include "ui/dissect_opts.h"
-dissect_options global_dissect_options;
-
-void
-dissect_opts_init(void)
-{
- global_dissect_options.time_format = TS_NOT_SET;
- global_dissect_options.time_precision = TS_PREC_NOT_SET;
- global_dissect_options.disable_protocol_slist = NULL;
- global_dissect_options.enable_protocol_slist = NULL;
- global_dissect_options.enable_heur_slist = NULL;
- global_dissect_options.disable_heur_slist = NULL;
-}
+dissect_options global_dissect_options = {
+ .time_format = TS_NOT_SET,
+ .time_precision = TS_PREC_NOT_SET
+};
gboolean
dissect_opts_handle_opt(int opt, char *optarg_str_p)
diff --git a/ui/dissect_opts.h b/ui/dissect_opts.h
index 6dd22c790e..6c2c4446b5 100644
--- a/ui/dissect_opts.h
+++ b/ui/dissect_opts.h
@@ -62,10 +62,6 @@ typedef struct dissect_options_tag {
extern dissect_options global_dissect_options;
-/* initialize the dissect_options with some reasonable values */
-extern void
-dissect_opts_init(void);
-
/*
* Handle a command line option.
* Returns TRUE if the option is valid, FALSE if not; an error message