From 00cdaba5a89eedb6f7334bdfa523e374e5dc4b12 Mon Sep 17 00:00:00 2001
From: Matt Turner <mattst88@gmail.com>
Date: Mon, 19 Jun 2023 15:47:17 -0400
Subject: [PATCH] gtk: Pass G_ALIGNOF (...) to gtk_sort_keys_new

The sizeof and G_ALIGNOF are often, but not always, identical.

(cherry picked from commit a4440453868ebe7c87d0a69de9609b33a688a8bb)
---
 gtk/gtknumericsorter.c     | 22 +++++++++++-----------
 gtk/gtksorter.c            |  2 +-
 gtk/gtkstringsorter.c      |  2 +-
 gtk/gtktreelistrowsorter.c |  2 +-
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/gtk/gtknumericsorter.c b/gtk/gtknumericsorter.c
index 4f474ad14d..f66d5ff505 100644
--- a/gtk/gtknumericsorter.c
+++ b/gtk/gtknumericsorter.c
@@ -227,7 +227,7 @@ gtk_numeric_sort_keys_new (GtkNumericSorter *self)
                                                       ? &GTK_ASCENDING_BOOLEAN_SORT_KEYS_CLASS
                                                       : &GTK_DESCENDING_BOOLEAN_SORT_KEYS_CLASS,
                                   sizeof (char),
-                                  sizeof (char));
+                                  G_ALIGNOF (char));
       break;
 
     case G_TYPE_CHAR:
@@ -236,7 +236,7 @@ gtk_numeric_sort_keys_new (GtkNumericSorter *self)
                                                       ? &GTK_ASCENDING_CHAR_SORT_KEYS_CLASS
                                                       : &GTK_DESCENDING_CHAR_SORT_KEYS_CLASS,
                                   sizeof (char),
-                                  sizeof (char));
+                                  G_ALIGNOF (char));
       break;
 
     case G_TYPE_UCHAR:
@@ -245,7 +245,7 @@ gtk_numeric_sort_keys_new (GtkNumericSorter *self)
                                                       ? &GTK_ASCENDING_UCHAR_SORT_KEYS_CLASS
                                                       : &GTK_DESCENDING_UCHAR_SORT_KEYS_CLASS,
                                   sizeof (guchar),
-                                  sizeof (guchar));
+                                  G_ALIGNOF (guchar));
       break;
 
     case G_TYPE_INT:
@@ -254,7 +254,7 @@ gtk_numeric_sort_keys_new (GtkNumericSorter *self)
                                                       ? &GTK_ASCENDING_INT_SORT_KEYS_CLASS
                                                       : &GTK_DESCENDING_INT_SORT_KEYS_CLASS,
                                   sizeof (int),
-                                  sizeof (int));
+                                  G_ALIGNOF (int));
       break;
 
     case G_TYPE_UINT:
@@ -263,7 +263,7 @@ gtk_numeric_sort_keys_new (GtkNumericSorter *self)
                                                       ? &GTK_ASCENDING_UINT_SORT_KEYS_CLASS
                                                       : &GTK_DESCENDING_UINT_SORT_KEYS_CLASS,
                                   sizeof (guint),
-                                  sizeof (guint));
+                                  G_ALIGNOF (guint));
       break;
 
     case G_TYPE_FLOAT:
@@ -272,7 +272,7 @@ gtk_numeric_sort_keys_new (GtkNumericSorter *self)
                                                       ? &GTK_ASCENDING_FLOAT_SORT_KEYS_CLASS
                                                       : &GTK_DESCENDING_FLOAT_SORT_KEYS_CLASS,
                                   sizeof (float),
-                                  sizeof (float));
+                                  G_ALIGNOF (float));
       break;
 
     case G_TYPE_DOUBLE:
@@ -281,7 +281,7 @@ gtk_numeric_sort_keys_new (GtkNumericSorter *self)
                                                       ? &GTK_ASCENDING_DOUBLE_SORT_KEYS_CLASS
                                                       : &GTK_DESCENDING_DOUBLE_SORT_KEYS_CLASS,
                                   sizeof (double),
-                                  sizeof (double));
+                                  G_ALIGNOF (double));
       break;
 
     case G_TYPE_LONG:
@@ -290,7 +290,7 @@ gtk_numeric_sort_keys_new (GtkNumericSorter *self)
                                                       ? &GTK_ASCENDING_LONG_SORT_KEYS_CLASS
                                                       : &GTK_DESCENDING_LONG_SORT_KEYS_CLASS,
                                   sizeof (long),
-                                  sizeof (long));
+                                  G_ALIGNOF (long));
       break;
 
     case G_TYPE_ULONG:
@@ -299,7 +299,7 @@ gtk_numeric_sort_keys_new (GtkNumericSorter *self)
                                                       ? &GTK_ASCENDING_ULONG_SORT_KEYS_CLASS
                                                       : &GTK_DESCENDING_ULONG_SORT_KEYS_CLASS,
                                   sizeof (gulong),
-                                  sizeof (gulong));
+                                  G_ALIGNOF (gulong));
       break;
 
     case G_TYPE_INT64:
@@ -308,7 +308,7 @@ gtk_numeric_sort_keys_new (GtkNumericSorter *self)
                                                       ? &GTK_ASCENDING_INT64_SORT_KEYS_CLASS
                                                       : &GTK_DESCENDING_INT64_SORT_KEYS_CLASS,
                                   sizeof (gint64),
-                                  sizeof (gint64));
+                                  G_ALIGNOF (gint64));
       break;
 
     case G_TYPE_UINT64:
@@ -317,7 +317,7 @@ gtk_numeric_sort_keys_new (GtkNumericSorter *self)
                                                       ? &GTK_ASCENDING_UINT64_SORT_KEYS_CLASS
                                                       : &GTK_DESCENDING_UINT64_SORT_KEYS_CLASS,
                                   sizeof (guint64),
-                                  sizeof (guint64));
+                                  G_ALIGNOF (guint64));
       break;
 
     default:
diff --git a/gtk/gtksorter.c b/gtk/gtksorter.c
index 2de29554ec..18bf950cf6 100644
--- a/gtk/gtksorter.c
+++ b/gtk/gtksorter.c
@@ -304,7 +304,7 @@ gtk_sorter_get_keys (GtkSorter *self)
   if (priv->keys)
     return gtk_sort_keys_ref (priv->keys);
 
-  fallback = gtk_sort_keys_new (GtkDefaultSortKeys, &GTK_DEFAULT_SORT_KEYS_CLASS, sizeof (gpointer), sizeof (gpointer));
+  fallback = gtk_sort_keys_new (GtkDefaultSortKeys, &GTK_DEFAULT_SORT_KEYS_CLASS, sizeof (gpointer), G_ALIGNOF (gpointer));
   fallback->sorter = g_object_ref (self);
 
   return (GtkSortKeys *) fallback;
diff --git a/gtk/gtkstringsorter.c b/gtk/gtkstringsorter.c
index 70739509e2..17c46b4436 100644
--- a/gtk/gtkstringsorter.c
+++ b/gtk/gtkstringsorter.c
@@ -234,7 +234,7 @@ gtk_string_sort_keys_new (GtkStringSorter *self)
   result = gtk_sort_keys_new (GtkStringSortKeys,
                               &GTK_STRING_SORT_KEYS_CLASS,
                               sizeof (char *),
-                              sizeof (char *));
+                              G_ALIGNOF (char *));
 
   result->expression = gtk_expression_ref (self->expression);
   result->ignore_case = self->ignore_case;
diff --git a/gtk/gtktreelistrowsorter.c b/gtk/gtktreelistrowsorter.c
index d7932cb067..6503948a89 100644
--- a/gtk/gtktreelistrowsorter.c
+++ b/gtk/gtktreelistrowsorter.c
@@ -350,7 +350,7 @@ gtk_tree_list_row_sort_keys_new (GtkTreeListRowSorter *self)
   result = gtk_sort_keys_new (GtkTreeListRowSortKeys,
                               &GTK_TREE_LIST_ROW_SORT_KEYS_CLASS,
                               sizeof (gpointer[MAX_KEY_DEPTH]),
-                              sizeof (gpointer[MAX_KEY_DEPTH]));
+                              G_ALIGNOF (gpointer));
 
   if (self->sorter)
     result->sort_keys = gtk_sorter_get_keys (self->sorter);
-- 
2.41.0

