summaryrefslogtreecommitdiff
path: root/glib/gqsort.c
diff options
context:
space:
mode:
authorTestingPlant <49836-TestingPlant@users.noreply.gitlab.gnome.org>2022-04-30 22:37:03 +0000
committerTestingPlant <49836-TestingPlant@users.noreply.gitlab.gnome.org>2022-05-07 02:01:19 +0000
commitb4b2f75bfd39470342a7b87daf5261a0cb074d73 (patch)
tree7fd6b6f3d65a7a09df21b17c4b38a534db3c638a /glib/gqsort.c
parent444fc6ccda102db2c859b99214272db0f8d62d05 (diff)
downloadglib-b4b2f75bfd39470342a7b87daf5261a0cb074d73.tar.gz
Cast to guintptr instead of subtracting by null
Subtraction by a null pointer is undefined behavior, so it's been replaced with a cast to guintptr.
Diffstat (limited to 'glib/gqsort.c')
-rw-r--r--glib/gqsort.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/glib/gqsort.c b/glib/gqsort.c
index 90e65aefe..86580f524 100644
--- a/glib/gqsort.c
+++ b/glib/gqsort.c
@@ -263,16 +263,15 @@ msort_r (void *b, size_t n, size_t s, GCompareDataFunc cmp, void *arg)
else
{
if ((s & (sizeof (guint32) - 1)) == 0
- && ((char *) b - (char *) 0) % ALIGNOF_GUINT32 == 0)
+ && (guintptr) b % ALIGNOF_GUINT32 == 0)
{
if (s == sizeof (guint32))
p.var = 0;
else if (s == sizeof (guint64)
- && ((char *) b - (char *) 0) % ALIGNOF_GUINT64 == 0)
+ && (guintptr) b % ALIGNOF_GUINT64 == 0)
p.var = 1;
else if ((s & (sizeof (unsigned long) - 1)) == 0
- && ((char *) b - (char *) 0)
- % ALIGNOF_UNSIGNED_LONG == 0)
+ && (guintptr) b % ALIGNOF_UNSIGNED_LONG == 0)
p.var = 2;
}
msort_with_tmp (&p, b, n);