]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/string/memset/: memzero(), strzero(): Return the pointer
authorAlejandro Colomar <alx@kernel.org>
Mon, 12 Aug 2024 00:15:18 +0000 (02:15 +0200)
committerSerge Hallyn <serge@hallyn.com>
Sat, 31 Aug 2024 02:44:07 +0000 (21:44 -0500)
This allows chaining with free(3) on the same line.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/string/memset/memzero.c
lib/string/memset/memzero.h

index 74a384b354082283bad53d79a8005afa825dbef0..0725bd932c029ba23d3befad6ab040a1cbec26b0 100644 (file)
@@ -1,15 +1,13 @@
-// SPDX-FileCopyrightText: 2023, Alejandro Colomar <alx@kernel.org>
+// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
 // SPDX-License-Identifier: BSD-3-Clause
 
 
 #include <config.h>
 
-#ident "$Id$"
-
 #include <stddef.h>
 
 #include "string/memset/memzero.h"
 
 
-extern inline void memzero(void *ptr, size_t size);
-extern inline void strzero(char *s);
+extern inline void *memzero(void *ptr, size_t size);
+extern inline char *strzero(char *s);
index cbf082cac8e459033f71fdcd92d088547747daa8..d20967b178d18d62ef177dcd52fb2fce5c81657a 100644 (file)
@@ -1,5 +1,5 @@
 // SPDX-FileCopyrightText: 2022-2023, Christian Göttsche <cgzones@googlemail.com>
-// SPDX-FileCopyrightText: 2023, Alejandro Colomar <alx@kernel.org>
+// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
 // SPDX-License-Identifier: BSD-3-Clause
 
 
 #define MEMZERO(arr)  memzero(arr, SIZEOF_ARRAY(arr))
 
 
-inline void memzero(void *ptr, size_t size);
-inline void strzero(char *s);
+inline void *memzero(void *ptr, size_t size);
+inline char *strzero(char *s);
 
 
-inline void
+inline void *
 memzero(void *ptr, size_t size)
 {
 #if defined(HAVE_MEMSET_EXPLICIT)
@@ -34,13 +34,14 @@ memzero(void *ptr, size_t size)
        bzero(ptr, size);
        __asm__ __volatile__ ("" : : "r"(ptr) : "memory");
 #endif
+       return ptr;
 }
 
 
-inline void
+inline char *
 strzero(char *s)
 {
-       memzero(s, strlen(s));
+       return memzero(s, strlen(s));
 }