From 1d888bff43d5bf98df2cfb77b55279bdc7804235 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 16 Mar 2021 17:22:45 -0400 Subject: [PATCH 1/6] Drop the gtk-doc subproject No longer used. --- subprojects/gtk-doc.wrap | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 subprojects/gtk-doc.wrap diff --git a/subprojects/gtk-doc.wrap b/subprojects/gtk-doc.wrap deleted file mode 100644 index 79ec37220a..0000000000 --- a/subprojects/gtk-doc.wrap +++ /dev/null @@ -1,5 +0,0 @@ -[wrap-git] -directory=gtk-doc -url=https://gitlab.gnome.org/GNOME/gtk-doc.git -revision=master -depth=1 From ee837dfc1230f0a5cc398c3e2bfb32aac369dadd Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 17 Mar 2021 07:37:33 -0400 Subject: [PATCH 2/6] checkbutton: Add a warning about cyclic groups Setting up check or toggle button group relationships in a cycle will lead to lockups. Add a warning about this, and catch the simplest case with a precondition check. Fixes: #3763 --- gtk/gtkcheckbutton.c | 3 +++ gtk/gtktogglebutton.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c index 366fd2398c..e9a30a1ce3 100644 --- a/gtk/gtkcheckbutton.c +++ b/gtk/gtkcheckbutton.c @@ -913,6 +913,8 @@ gtk_check_button_set_label (GtkCheckButton *self, * Setting the group of a check button also changes the css name of the * indicator widget's CSS node to 'radio'. * + * Setting up groups in a cycle leads to undefined behavior. + * * Note that the same effect can be achieved via the [interface@Gtk.Actionable] * API, by using the same action with parameter type and state type 's' * for all buttons in the group, and giving each button its own target @@ -926,6 +928,7 @@ gtk_check_button_set_group (GtkCheckButton *self, GtkCheckButtonPrivate *group_priv = gtk_check_button_get_instance_private (group); g_return_if_fail (GTK_IS_CHECK_BUTTON (self)); + g_return_if_fail (self != group); if (!group) { diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c index 6ae96fc8af..1e53a896c6 100644 --- a/gtk/gtktogglebutton.c +++ b/gtk/gtktogglebutton.c @@ -473,6 +473,8 @@ gtk_toggle_button_toggled (GtkToggleButton *toggle_button) * In a group of multiple toggle buttons, only one button can be active * at a time. * + * Setting up groups in a cycle leads to undefined behavior. + * * Note that the same effect can be achieved via the [interface@Gtk.Actionable] * API, by using the same action with parameter type and state type 's' * for all buttons in the group, and giving each button its own target @@ -486,6 +488,7 @@ gtk_toggle_button_set_group (GtkToggleButton *toggle_button, GtkToggleButtonPrivate *group_priv = gtk_toggle_button_get_instance_private (group); g_return_if_fail (GTK_IS_TOGGLE_BUTTON (toggle_button)); + g_return_if_fail (toggle_button != group); if (!group) { From ea185cbdda48fea20d58863ed3ad7ff5add2ff6e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 17 Mar 2021 07:49:06 -0400 Subject: [PATCH 3/6] cssshadowvalue: Handle error condition propertly We were parsing off the end of our array before noticing that we've gone too far. gcc 11 warns about this. --- gtk/gtkcssshadowvalue.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gtk/gtkcssshadowvalue.c b/gtk/gtkcssshadowvalue.c index 86dfcafdfb..94fccffd82 100644 --- a/gtk/gtkcssshadowvalue.c +++ b/gtk/gtkcssshadowvalue.c @@ -494,14 +494,14 @@ gtk_css_shadow_value_parse (GtkCssParser *parser, return gtk_css_shadow_value_new_none (); do { + if (n_shadows == MAX_SHADOWS) + { + gtk_css_parser_error_syntax (parser, "Not more than %d shadows supported", MAX_SHADOWS); + goto fail; + } if (gtk_css_shadow_value_parse_one (parser, box_shadow_mode, &shadows[n_shadows])) n_shadows++; - if (n_shadows > MAX_SHADOWS) - { - gtk_css_parser_error_syntax (parser, "Not more than 64 shadows supported"); - goto fail; - } } while (gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COMMA)); return gtk_css_shadow_value_new (shadows, n_shadows, FALSE); From 8b82993dde5bea985dac69e5ff940236db11f83b Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 17 Mar 2021 07:50:24 -0400 Subject: [PATCH 4/6] sizerequest: Avoid a corner case gcc 11 warns that the code isn't safe when n_requested_sizes is 0. Add a precondition check to make it clear that that never happens. --- gtk/gtksizerequest.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c index a8d4ff7763..bad631c022 100644 --- a/gtk/gtksizerequest.c +++ b/gtk/gtksizerequest.c @@ -698,6 +698,7 @@ gtk_distribute_natural_allocation (int extra_space, int i; g_return_val_if_fail (extra_space >= 0, 0); + g_return_val_if_fail (n_requested_sizes > 0, 0); spreading = g_newa (guint, n_requested_sizes); From 600cbdb7ba8583f3a3425475f8f45ddc267c0ac9 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 17 Mar 2021 07:51:27 -0400 Subject: [PATCH 5/6] treestore: Initialize some local variables gcc 11 is warning that these might be used uninitialized otherwise. --- gtk/gtktreestore.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gtk/gtktreestore.c b/gtk/gtktreestore.c index c02dcd3a17..c542af00ba 100644 --- a/gtk/gtktreestore.c +++ b/gtk/gtktreestore.c @@ -2471,7 +2471,9 @@ gtk_tree_store_move (GtkTreeStore *tree_store, GNode *parent, *node, *a, *b, *tmp, *tmp_a, *tmp_b; int old_pos, new_pos, length, i, *order; GtkTreePath *path = NULL, *tmppath, *pos_path = NULL; - GtkTreeIter parent_iter, dst_a, dst_b; + GtkTreeIter parent_iter = { 0, }; + GtkTreeIter dst_a = { 0, }; + GtkTreeIter dst_b = { 0, }; int depth = 0; gboolean handle_b = TRUE; From 6d5657eee7a3511e76ab9c59864fdaad06531ec3 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 17 Mar 2021 07:56:07 -0400 Subject: [PATCH 6/6] lpr: Fix various compiler warnings gcc 11 is warning about some const mixups here. Fix them. --- modules/printbackends/gtkprintbackendlpr.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/printbackends/gtkprintbackendlpr.c b/modules/printbackends/gtkprintbackendlpr.c index 17ed4fbf3f..ea7770f5a9 100644 --- a/modules/printbackends/gtkprintbackendlpr.c +++ b/modules/printbackends/gtkprintbackendlpr.c @@ -103,7 +103,7 @@ char ** g_io_module_query (void) { char *eps[] = { - GTK_PRINT_BACKEND_EXTENSION_POINT_NAME, + (char *)GTK_PRINT_BACKEND_EXTENSION_POINT_NAME, NULL }; @@ -399,13 +399,12 @@ lpr_printer_get_options (GtkPrinter *printer, GtkPrinterOptionSet *set; GtkPrinterOption *option; const char *command; - char *n_up[] = {"1", "2", "4", "6", "9", "16" }; + const char *n_up[] = {"1", "2", "4", "6", "9", "16" }; set = gtk_printer_option_set_new (); option = gtk_printer_option_new ("gtk-n-up", _("Pages Per Sheet"), GTK_PRINTER_OPTION_TYPE_PICKONE); - gtk_printer_option_choices_from_array (option, G_N_ELEMENTS (n_up), - (char **)n_up, (char **)n_up); + gtk_printer_option_choices_from_array (option, G_N_ELEMENTS (n_up), n_up, n_up); gtk_printer_option_set (option, "1"); gtk_printer_option_set_add (set, option); g_object_unref (option);