etc: Enable a tty for a serial port by default.
[dragora.git] / patches / glib2 / glib-2.74.6-skip_warnings-1.patch
blob2cca332ff9f47354963adacc1a582e548a274e9c
1 Submitted By: Bruce Dubbs <bdubbs@linuxfromscratch.org>
2 Rediffed By: Douglas R. Reno <renodr at linuxfromscratch dot org>
3 Date: 2017-10-15
4 Rediffed Date: 2021-04-01
5 Initial Package Version: 2.54.0
6 Upstream Status: Not submitted
7 Origin: Self
8 Description: Adds a capabiility to skip printing warning messages using
9 an environment variable: GLIB_LOG_LEVEL. The value
10 of the variable is a digit that correponds to:
11 1 Alert
12 2 Critical
13 3 Error
14 4 Warning
15 5 Notice
17 For instance GLIB_LOG_LEVEL=4 will skip output of Warning and
18 Notice messages (and Info/Debug messages if they are turned on).
20 Rediffed for 2.68.0 to reduce the fuzz warnings.
22 diff -Naurp glib-2.68.0.orig/glib/gmessages.c glib-2.68.0/glib/gmessages.c
23 --- glib-2.68.0.orig/glib/gmessages.c 2021-03-18 08:28:31.909625000 -0500
24 +++ glib-2.68.0/glib/gmessages.c 2021-04-01 20:32:23.517596280 -0500
25 @@ -528,6 +528,34 @@ static GDestroyNotify log_writer_user_da
27 /* --- functions --- */
29 +/* skip_message
30 + *
31 + * This internal function queries an optional environment variable,
32 + * GLIB_LOG_LEVEL and converts it to a value consistent
33 + * with the type GLogLevelFlags. If the value is equal to
34 + * or greater than the integer equivalent of the log_level,
35 + * then the function returns a boolean that indicates that
36 + * logging the output should be skipped.
37 + */
39 +static gboolean skip_message( GLogLevelFlags log_level);
41 +static gboolean skip_message( GLogLevelFlags log_level)
43 + char* user_log_level;
44 + int user_log_int;
45 + gboolean skip = FALSE;
47 + user_log_level = getenv( "GLIB_LOG_LEVEL" );
49 + user_log_int = ( user_log_level != NULL ) ? atoi( user_log_level ) : 0;
50 + user_log_int = ( user_log_level != 0 ) ? 1 << user_log_int : 0;
52 + if ( user_log_int >= log_level ) skip = TRUE;
54 + return skip;
57 static void _g_log_abort (gboolean breakpoint);
59 static void
60 @@ -2591,6 +2619,9 @@ g_log_writer_standard_streams (GLogLevel
61 g_return_val_if_fail (fields != NULL, G_LOG_WRITER_UNHANDLED);
62 g_return_val_if_fail (n_fields > 0, G_LOG_WRITER_UNHANDLED);
64 + /* If the user does not want this message level, just return */
65 + if ( skip_message( log_level) ) return G_LOG_WRITER_HANDLED;
67 stream = log_level_to_file (log_level);
68 if (!stream || fileno (stream) < 0)
69 return G_LOG_WRITER_UNHANDLED;
70 @@ -2818,6 +2849,9 @@ _g_log_writer_fallback (GLogLevelFlags
71 FILE *stream;
72 gsize i;
74 + /* If the user does not want this message level, just return */
75 + if ( skip_message( log_level) ) return G_LOG_WRITER_HANDLED;
77 /* we cannot call _any_ GLib functions in this fallback handler,
78 * which is why we skip UTF-8 conversion, etc.
79 * since we either recursed or ran out of memory, we're in a pretty