gridview: Add a few assertions
authorMatthias Clasen <mclasen@redhat.com>
Fri, 13 Jan 2023 16:30:13 +0000 (11:30 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 13 Jan 2023 17:07:40 +0000 (12:07 -0500)
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

index 2d91fd5096e1a6df0f9770e278762280fcc2ee6d..93ae91cee2673690d78aea8a30ab02eddc42442b 100644 (file)
@@ -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))