From 51b4d70b8ff2c4da2db6f233a1c2327495260922 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 13 Jan 2023 11:30:13 -0500 Subject: [PATCH] gridview: Add a few assertions Just to help static analysis out. self->n_columns can't ever be 0, since we clamp it between min_columns and max_columns, with min_columns always being at least one. --- gtk/gtkgridview.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c index 2d91fd5096..93ae91cee2 100644 --- a/gtk/gtkgridview.c +++ b/gtk/gtkgridview.c @@ -627,6 +627,8 @@ gtk_grid_view_compute_n_columns (GtkGridView *self, n_columns = CLAMP (n_columns, self->min_columns, self->max_columns); + g_assert (n_columns > 0); + return n_columns; } @@ -869,6 +871,8 @@ gtk_grid_view_size_allocate (GtkWidget *widget, i = 0; row_height = 0; + g_assert (self->n_columns > 0); + for (cell = gtk_list_item_manager_get_first (self->item_manager); cell != NULL; cell = gtk_rb_tree_node_get_next (cell))