tshark/tfshark: Do not apply console.log.level before it is set
authorOrgad Shaneh <orgads@gmail.com>
Mon, 30 Oct 2017 13:42:43 +0000 (15:42 +0200)
committerRichard Sharpe <realrichardsharpe@gmail.com>
Tue, 7 Nov 2017 13:51:38 +0000 (13:51 +0000)
The user has no way to apply this setting while loading dissectors in order
to enable g_debug messages during init for example.

Change the behavior to be as documented in the comment.

Change-Id: I9317f12b207d4621508212b02ca1ebd46b55aadc
Reviewed-on: https://code.wireshark.org/review/24184
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
tfshark.c
tshark.c

index db4c8d5d7207edc33cc179732bc3714bf54f51ab..ab8e5cfb2fe5e163e392ec7e6e888aabc105d7d1 100644 (file)
--- a/tfshark.c
+++ b/tfshark.c
@@ -157,6 +157,7 @@ static void failure_message_cont(const char *msg_format, va_list ap);
 capture_file cfile;
 
 static GHashTable *output_only_tables = NULL;
 capture_file cfile;
 
 static GHashTable *output_only_tables = NULL;
+static e_prefs *prefs_p = NULL;
 
 #if 0
 struct string_elem {
 
 #if 0
 struct string_elem {
@@ -276,7 +277,7 @@ tfshark_log_handler (const gchar *log_domain, GLogLevelFlags log_level,
 {
   /* ignore log message, if log_level isn't interesting based
      upon the console log preferences.
 {
   /* ignore log message, if log_level isn't interesting based
      upon the console log preferences.
-     If the preferences haven't been loaded loaded yet, display the
+     If the preferences haven't been loaded yet, display the
      message anyway.
 
      The default console_log_level preference value is such that only
      message anyway.
 
      The default console_log_level preference value is such that only
@@ -287,8 +288,7 @@ tfshark_log_handler (const gchar *log_domain, GLogLevelFlags log_level,
            ERROR and CRITICAL level messages so the current code is a behavioral
            change.  The current behavior is the same as in Wireshark.
   */
            ERROR and CRITICAL level messages so the current code is a behavioral
            change.  The current behavior is the same as in Wireshark.
   */
-  if ((log_level & G_LOG_LEVEL_MASK & prefs.console_log_level) == 0 &&
-     prefs.console_log_level != 0) {
+  if (prefs_p && (log_level & G_LOG_LEVEL_MASK & prefs.console_log_level) == 0) {
     return;
   }
 
     return;
   }
 
@@ -345,7 +345,6 @@ main(int argc, char *argv[])
   dfilter_t           *rfcode = NULL;
   dfilter_t           *dfcode = NULL;
   gchar               *err_msg;
   dfilter_t           *rfcode = NULL;
   dfilter_t           *dfcode = NULL;
   gchar               *err_msg;
-  e_prefs             *prefs_p;
   int                  log_flags;
   gchar               *output_only = NULL;
 
   int                  log_flags;
   gchar               *output_only = NULL;
 
index 6a32bdbf408bc1521692ecae9fe782897bda7a7c..409a8588629ad361e65922060268c478fc54152a 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -224,6 +224,8 @@ static capture_options global_capture_opts;
 static capture_session global_capture_session;
 static info_data_t global_info_data;
 
 static capture_session global_capture_session;
 static info_data_t global_info_data;
 
+static e_prefs *prefs_p = NULL;
+
 #ifdef SIGINFO
 static gboolean infodelay;      /* if TRUE, don't print capture info in SIGINFO handler */
 static gboolean infoprint;      /* if TRUE, print capture info after clearing infodelay */
 #ifdef SIGINFO
 static gboolean infodelay;      /* if TRUE, don't print capture info in SIGINFO handler */
 static gboolean infoprint;      /* if TRUE, print capture info after clearing infodelay */
@@ -513,7 +515,7 @@ tshark_log_handler (const gchar *log_domain, GLogLevelFlags log_level,
 {
   /* ignore log message, if log_level isn't interesting based
      upon the console log preferences.
 {
   /* ignore log message, if log_level isn't interesting based
      upon the console log preferences.
-     If the preferences haven't been loaded loaded yet, display the
+     If the preferences haven't been loaded yet, display the
      message anyway.
 
      The default console_log_level preference value is such that only
      message anyway.
 
      The default console_log_level preference value is such that only
@@ -524,8 +526,7 @@ tshark_log_handler (const gchar *log_domain, GLogLevelFlags log_level,
            ERROR and CRITICAL level messages so the current code is a behavioral
            change.  The current behavior is the same as in Wireshark.
   */
            ERROR and CRITICAL level messages so the current code is a behavioral
            change.  The current behavior is the same as in Wireshark.
   */
-  if ((log_level & G_LOG_LEVEL_MASK & prefs.console_log_level) == 0 &&
-     prefs.console_log_level != 0) {
+  if (prefs_p && (log_level & G_LOG_LEVEL_MASK & prefs.console_log_level) == 0) {
     return;
   }
 
     return;
   }
 
@@ -717,7 +718,6 @@ main(int argc, char *argv[])
   dfilter_t           *rfcode = NULL;
   dfilter_t           *dfcode = NULL;
   gchar               *err_msg;
   dfilter_t           *rfcode = NULL;
   dfilter_t           *dfcode = NULL;
   gchar               *err_msg;
-  e_prefs             *prefs_p;
   int                  log_flags;
   gchar               *output_only = NULL;
   gchar               *volatile pdu_export_arg = NULL;
   int                  log_flags;
   gchar               *output_only = NULL;
   gchar               *volatile pdu_export_arg = NULL;