]> Savannah Git Hosting - gnulib.git/commitdiff
dynarray: prefer C23 style overflow checking
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 1 May 2023 16:06:57 +0000 (09:06 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 1 May 2023 18:21:18 +0000 (11:21 -0700)
* lib/malloc/dynarray_emplace_enlarge.c, lib/malloc/dynarray_resize.c:
Include stdckdint.h, not intprops.h.
* lib/malloc/dynarray_emplace_enlarge.c:
(__libc_dynarray_emplace_enlarge):
* lib/malloc/dynarray_resize.c (__libc_dynarray_resize):
Prefer stdckdint.h to intprops.h macros.
* modules/glibc-internal/dynarray (Depends-on):
Depend on stdckdint, not intprops.

ChangeLog
lib/malloc/dynarray_emplace_enlarge.c
lib/malloc/dynarray_resize.c
modules/glibc-internal/dynarray

index 0b8e61c1236eaae34662d1c40e16ad01981919c6..3528faf40ea45986488a602e0bb118c532c07207 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2023-05-01  Paul Eggert  <eggert@cs.ucla.edu>
 
+       dynarray: prefer C23 style overflow checking
+       * lib/malloc/dynarray_emplace_enlarge.c, lib/malloc/dynarray_resize.c:
+       Include stdckdint.h, not intprops.h.
+       * lib/malloc/dynarray_emplace_enlarge.c:
+       (__libc_dynarray_emplace_enlarge):
+       * lib/malloc/dynarray_resize.c (__libc_dynarray_resize):
+       Prefer stdckdint.h to intprops.h macros.
+       * modules/glibc-internal/dynarray (Depends-on):
+       Depend on stdckdint, not intprops.
+
        mktime: prefer C23 style overflow checking
        Prefer stdckdint.h macros to intprops.h macros where either will do,
        as this is the C23 standard.  Also, it ports around a pcc bug.
index 7da539316c1453f36270d025e6a558c1bab65097..65aabb1e4a57dcdd9119afd61b503be848a43618 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <dynarray.h>
 #include <errno.h>
-#include <intprops.h>
+#include <stdckdint.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -56,7 +56,7 @@ __libc_dynarray_emplace_enlarge (struct dynarray_header *list,
     }
 
   size_t new_size;
-  if (INT_MULTIPLY_WRAPV (new_allocated, element_size, &new_size))
+  if (ckd_mul (&new_size, new_allocated, element_size))
     return false;
   void *new_array;
   if (list->array == scratch)
index 7ecd4de63b90cfd9bda1327fdfe3786b2fa3309f..014f98c330e8d2a3eeb603ede6e56da633637689 100644 (file)
@@ -22,7 +22,7 @@
 
 #include <dynarray.h>
 #include <errno.h>
-#include <intprops.h>
+#include <stdckdint.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -42,7 +42,7 @@ __libc_dynarray_resize (struct dynarray_header *list, size_t size,
      over-allocation here.  */
 
   size_t new_size_bytes;
-  if (INT_MULTIPLY_WRAPV (size, element_size, &new_size_bytes))
+  if (ckd_mul (&new_size_bytes, size, element_size))
     {
       /* Overflow.  */
       __set_errno (ENOMEM);
index 668959482e7288ec7ff6cb51693e17d2b55226e4..f78aea7f1a9139535c02099eebb89b12b004682e 100644 (file)
@@ -17,8 +17,8 @@ builtin-expect
 gen-header
 libc-config
 stdbool
+stdckdint
 stddef
-intprops
 
 configure.ac:
 AC_PROG_MKDIR_P