The explicit_bzero function is a common extension, but memset_explicit
was standardized in C23. It will likely become more portable in the
future, and Gnulib provides an implementation if needed.

* bootstrap.conf (gnulib_modules): Add memset_explicit. Remove
explicit_bzero.
* gl/lib/randint.c (randint_free): Use memset_explicit instead of
explicit_bzero.
* gl/lib/randread.c (randread_free_body): Likewise.
---
 bootstrap.conf    | 2 +-
 gl/lib/randint.c  | 2 +-
 gl/lib/randread.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/bootstrap.conf b/bootstrap.conf
index 1cab8a804..331382841 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -90,7 +90,6 @@ gnulib_modules="
   euidaccess
   exclude
   exitfail
-  explicit_bzero
   faccessat
   fadvise
   fchdir
@@ -187,6 +186,7 @@ gnulib_modules="
   memcmp2
   mempcpy
   memrchr
+  memset_explicit
   minmax
   mkancesdirs
   mkdir
diff --git a/gl/lib/randint.c b/gl/lib/randint.c
index bd3ce3821..97fe0bf90 100644
--- a/gl/lib/randint.c
+++ b/gl/lib/randint.c
@@ -198,7 +198,7 @@ randint_genmax (struct randint_source *s, randint genmax)
 void
 randint_free (struct randint_source *s)
 {
-  explicit_bzero (s, sizeof *s);
+  memset_explicit (s, 0, sizeof *s);
   free (s);
 }
 
diff --git a/gl/lib/randread.c b/gl/lib/randread.c
index be0267a64..249d400c9 100644
--- a/gl/lib/randread.c
+++ b/gl/lib/randread.c
@@ -153,7 +153,7 @@ static int
 randread_free_body (struct randread_source *s)
 {
   FILE *source = s->source;
-  explicit_bzero (s, sizeof *s);
+  memset_explicit (s, 0, sizeof *s);
   free (s);
   return source ? fclose (source) : 0;
 }
-- 
2.53.0


Reply via email to