]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: prefer memset_explicit to explicit_bzero
authorCollin Funk <collin.funk1@gmail.com>
Sun, 8 Mar 2026 00:16:01 +0000 (16:16 -0800)
committerCollin Funk <collin.funk1@gmail.com>
Sun, 8 Mar 2026 00:16:01 +0000 (16:16 -0800)
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
gl/lib/randint.c
gl/lib/randread.c

index 1cab8a804999f694f6a844836ad46fa8b0ae861d..331382841c95dacd0eb802fa7ec136eb8173cb31 100644 (file)
@@ -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
index bd3ce38217e48c175e698df23e2082190c311c43..97fe0bf90922d0fa5b0e628ff66e1a06454563b7 100644 (file)
@@ -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);
 }
 
index be0267a64e54463b8429135a9344f17254628df5..249d400c97898401c3c44b1a73ece86e2e0665c9 100644 (file)
@@ -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;
 }