]> Savannah Git Hosting - gnulib.git/commitdiff
fts: Don't assume that a pointer is as wide as a 'long'.
authorBruno Haible <bruno@clisp.org>
Tue, 27 Aug 2024 20:08:00 +0000 (22:08 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 27 Aug 2024 20:08:00 +0000 (22:08 +0200)
* lib/fts.c (fts_sort): Cast pointers to 'uintptr_t', not to 'long'.

ChangeLog
lib/fts.c

index 2e60f867e3e3a9005168e5daf58efa357ac5f40c..51e78323e0b77c00423b7b246e3b078539d42ec2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-08-27  Bruno Haible  <bruno@clisp.org>
+
+       fts: Don't assume that a pointer is as wide as a 'long'.
+       * lib/fts.c (fts_sort): Cast pointers to 'uintptr_t', not to 'long'.
+
 2024-08-27  Bruno Haible  <bruno@clisp.org>
 
        mkdir: Fix for use of posixcheck module on native Windows.
index 5a86419c748b8a1592851df6cd2d17b699939ca3..92306bc72f628f696ed49396181ef4a534cf6389 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -1858,13 +1858,13 @@ fts_sort (FTS *sp, FTSENT *head, register size_t nitems)
            run-time representation, and one can convert sp->fts_compar to
            the type qsort expects without problem.  Use the heuristic that
            this is OK if the two pointer types are the same size, and if
-           converting FTSENT ** to long int is the same as converting
-           FTSENT ** to void * and then to long int.  This heuristic isn't
+           converting FTSENT ** to uintptr_t is the same as converting
+           FTSENT ** to void * and then to uintptr_t.  This heuristic isn't
            valid in general but we don't know of any counterexamples.  */
         FTSENT *dummy;
         int (*compare) (void const *, void const *) =
           ((sizeof &dummy == sizeof (void *)
-            && (long int) &dummy == (long int) (void *) &dummy)
+            && (uintptr_t) &dummy == (uintptr_t) (void *) &dummy)
            ? (int (*) (void const *, void const *)) sp->fts_compar
            : fts_compar);