mirror of
https://git.openwrt.org/openwrt/openwrt.git
synced 2025-08-06 07:46:59 +02:00
Move to the June 2025 update of the first 2025 stable branch
in order to better support updating gettext to the latest versions.
More instances of blocking the defining of functions
that use reallocarray() is needed for portability with macOS
as more similar functions have been added.
And one instance is removed as the function was removed.
Refer to a previous commit to explain the need for this.
Manually adjusted patch:
- 150-portable-tdestroy.patch
- 160-flag-reallocarray.patch
- 200-force-disable-after-configure.patch
Removed upstreamed patch:
- 500-acl-function-name.patch
All other patches are automatically refreshed.
Ref: 5ade7ee60
("tools/gnulib: add macros to skip reallocarray() functions")
Signed-off-by: Michael Pratt <mcpratt@pm.me>
Link: https://github.com/openwrt/openwrt/pull/16522
Signed-off-by: Robert Marko <robimarko@gmail.com>
195 lines
5.1 KiB
Diff
195 lines
5.1 KiB
Diff
--- a/lib/ialloc.h
|
|
+++ b/lib/ialloc.h
|
|
@@ -91,6 +91,8 @@ icalloc (idx_t n, idx_t s)
|
|
return calloc (n, s);
|
|
}
|
|
|
|
+#if GNULIB_REALLOCARRAY
|
|
+
|
|
/* ireallocarray (ptr, num, size) is like reallocarray (ptr, num, size).
|
|
It returns a non-NULL pointer to num * size bytes of memory.
|
|
Upon failure, it returns NULL with errno set. */
|
|
@@ -102,6 +104,8 @@ ireallocarray (void *p, idx_t n, idx_t s
|
|
: _gl_alloc_nomem ());
|
|
}
|
|
|
|
+#endif /* GNULIB_REALLOCARRAY */
|
|
+
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
--- a/lib/xmalloc.c
|
|
+++ b/lib/xmalloc.c
|
|
@@ -51,12 +51,16 @@ ximalloc (idx_t s)
|
|
return check_nonnull (imalloc (s));
|
|
}
|
|
|
|
+#if GNULIB_REALLOCARRAY
|
|
+
|
|
char *
|
|
xcharalloc (size_t n)
|
|
{
|
|
return XNMALLOC (n, char);
|
|
}
|
|
|
|
+#endif /* GNULIB_REALLOCARRAY */
|
|
+
|
|
/* Change the size of an allocated block of memory P to S bytes,
|
|
with error checking. */
|
|
|
|
@@ -75,6 +79,8 @@ xirealloc (void *p, idx_t s)
|
|
return check_nonnull (irealloc (p, s));
|
|
}
|
|
|
|
+#if GNULIB_REALLOCARRAY
|
|
+
|
|
/* Change the size of an allocated block of memory P to an array of N
|
|
objects each of S bytes, with error checking. */
|
|
|
|
@@ -205,6 +211,8 @@ x2nrealloc (void *p, size_t *pn, size_t
|
|
return p;
|
|
}
|
|
|
|
+#endif /* GNULIB_REALLOCARRAY */
|
|
+
|
|
/* Grow PA, which points to an array of *PN items, and return the
|
|
location of the reallocated array, updating *PN to reflect its
|
|
new size. The new array will contain at least N_INCR_MIN more
|
|
--- a/lib/xalloc.h
|
|
+++ b/lib/xalloc.h
|
|
@@ -81,10 +81,16 @@ void *xrealloc (void *p, size_t s)
|
|
_GL_ATTRIBUTE_ALLOC_SIZE ((2));
|
|
void *xirealloc (void *p, idx_t s)
|
|
_GL_ATTRIBUTE_ALLOC_SIZE ((2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
|
|
+
|
|
+# if GNULIB_REALLOCARRAY
|
|
+
|
|
void *xreallocarray (void *p, size_t n, size_t s)
|
|
_GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
|
|
void *xireallocarray (void *p, idx_t n, idx_t s)
|
|
_GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)) _GL_ATTRIBUTE_RETURNS_NONNULL;
|
|
+
|
|
+# endif /* GNULIB_REALLOCARRAY */
|
|
+
|
|
void *x2realloc (void *p, size_t *ps) /* superseded by xpalloc */
|
|
_GL_ATTRIBUTE_RETURNS_NONNULL;
|
|
void *x2nrealloc (void *p, size_t *pn, size_t s) /* superseded by xpalloc */
|
|
@@ -129,6 +135,7 @@ char *xstrdup (char const *str)
|
|
# define XCALLOC(n, t) \
|
|
((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
|
|
|
|
+# if GNULIB_REALLOCARRAY
|
|
|
|
/* Allocate an array of N objects, each with S bytes of memory,
|
|
dynamically, with error checking. S must be nonzero. */
|
|
@@ -156,6 +163,8 @@ char *xcharalloc (size_t n)
|
|
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
|
|
_GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
|
|
|
|
+# endif /* GNULIB_REALLOCARRAY */
|
|
+
|
|
#endif /* GNULIB_XALLOC */
|
|
|
|
|
|
--- a/lib/safe-alloc.h
|
|
+++ b/lib/safe-alloc.h
|
|
@@ -37,7 +37,6 @@ _GL_INLINE_HEADER_BEGIN
|
|
extern "C" {
|
|
#endif
|
|
|
|
-
|
|
/* Don't call this directly - use the macros below. */
|
|
_GL_ATTRIBUTE_NODISCARD SAFE_ALLOC_INLINE int
|
|
safe_alloc_check (void *ptr)
|
|
@@ -72,6 +71,8 @@ safe_alloc_check (void *ptr)
|
|
#define ALLOC_N(ptr, count) \
|
|
safe_alloc_check ((ptr) = calloc (count, sizeof *(ptr)))
|
|
|
|
+#if GNULIB_REALLOCARRAY
|
|
+
|
|
/**
|
|
* ALLOC_N_UNINITIALIZED:
|
|
* @ptr: pointer to allocated memory
|
|
@@ -100,6 +101,8 @@ safe_alloc_check (void *ptr)
|
|
#define REALLOC_N(ptr, count) \
|
|
safe_alloc_check ((ptr) = reallocarray (ptr, count, sizeof *(ptr)))
|
|
|
|
+#endif /* GNULIB_REALLOCARRAY */
|
|
+
|
|
/**
|
|
* FREE:
|
|
* @ptr: pointer holding address to be freed
|
|
--- a/lib/dfa.c
|
|
+++ b/lib/dfa.c
|
|
@@ -1620,6 +1620,8 @@ lex (struct dfa *dfa)
|
|
}
|
|
}
|
|
|
|
+#if GNULIB_REALLOCARRAY
|
|
+
|
|
static void
|
|
addtok_mb (struct dfa *dfa, token t, char mbprop)
|
|
{
|
|
@@ -1674,6 +1676,8 @@ addtok_mb (struct dfa *dfa, token t, cha
|
|
}
|
|
}
|
|
|
|
+#endif /* GNULIB_REALLOCARRAY */
|
|
+
|
|
static void addtok_wc (struct dfa *dfa, wint_t wc);
|
|
|
|
/* Add the given token to the parse tree, maintaining the depth count and
|
|
@@ -2934,6 +2938,8 @@ dfaanalyze (struct dfa *d, bool searchfl
|
|
free (tmp.elems);
|
|
}
|
|
|
|
+#if GNULIB_REALLOCARRAY
|
|
+
|
|
/* Make sure D's state arrays are large enough to hold NEW_STATE. */
|
|
static void
|
|
realloc_trans_if_necessary (struct dfa *d)
|
|
@@ -2969,6 +2975,8 @@ realloc_trans_if_necessary (struct dfa *
|
|
}
|
|
}
|
|
|
|
+#endif /* GNULIB_REALLOCARRAY */
|
|
+
|
|
/*
|
|
Calculate the transition table for a new state derived from state s
|
|
for a compiled dfa d after input character uc, and return the new
|
|
@@ -4010,6 +4018,8 @@ freelist (char **cpp)
|
|
free (*cpp++);
|
|
}
|
|
|
|
+#if GNULIB_REALLOCARRAY
|
|
+
|
|
static char **
|
|
enlistnew (char **cpp, char *new)
|
|
{
|
|
@@ -4046,6 +4056,8 @@ enlist (char **cpp, char const *str, idx
|
|
return enlistnew (cpp, ximemdup0 (str, len));
|
|
}
|
|
|
|
+#endif /* GNULIB_REALLOCARRAY */
|
|
+
|
|
/* Given pointers to two strings, return a pointer to an allocated
|
|
list of their distinct common substrings. */
|
|
static char **
|
|
--- a/lib/readtokens.c
|
|
+++ b/lib/readtokens.c
|
|
@@ -128,6 +128,8 @@ readtoken (FILE *stream,
|
|
return i;
|
|
}
|
|
|
|
+#if GNULIB_REALLOCARRAY
|
|
+
|
|
/* Build a NULL-terminated array of pointers to tokens
|
|
read from STREAM. Return the number of tokens read.
|
|
All storage is obtained through calls to xmalloc-like functions.
|
|
@@ -190,3 +192,5 @@ readtokens (FILE *stream,
|
|
free (lengths);
|
|
return n_tokens;
|
|
}
|
|
+
|
|
+#endif /* GNULIB_REALLOCARRAY */
|