]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
libmisc: Move xmalloc.c to alloc.c
authorAlejandro Colomar <alx@kernel.org>
Sun, 19 Feb 2023 19:40:16 +0000 (20:40 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 24 Feb 2023 02:28:43 +0000 (20:28 -0600)
We'll expand the contents in a following commit, so let's move the file
to a more generic name, have a dedicated header, and update includes.

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Use the new header for xstrdup()

Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/alloc.h [new file with mode: 0644]
lib/prototypes.h
libmisc/Makefile.am
libmisc/alloc.c [moved from libmisc/xmalloc.c with 100% similarity]
libmisc/copydir.c
libmisc/entry.c
libmisc/env.c
libmisc/motd.c
src/chage.c
src/chfn.c
src/chsh.c

diff --git a/lib/alloc.h b/lib/alloc.h
new file mode 100644 (file)
index 0000000..9b1f8dc
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef SHADOW_INCLUDE_LIB_MALLOC_H_
+#define SHADOW_INCLUDE_LIB_MALLOC_H_
+
+
+#include <stddef.h>
+
+/* xmalloc.c */
+extern /*@maynotreturn@*/ /*@only@*//*@out@*//*@notnull@*/void *xmalloc (size_t size)
+  /*@ensures MaxSet(result) == (size - 1); @*/;
+extern /*@maynotreturn@*/ /*@only@*//*@notnull@*/char *xstrdup (const char *);
+
+
+#endif  // include guard
index f4b4840dc5226c61a87c1a8d5fd813baeb07c12d..400d5b97b8852ee8a9f0fc00c8e22e6016ace3e9 100644 (file)
@@ -477,11 +477,6 @@ extern int setutmp (struct utmp *ut);
 /* valid.c */
 extern bool valid (const char *, const struct passwd *);
 
-/* xmalloc.c */
-extern /*@maynotreturn@*/ /*@only@*//*@out@*//*@notnull@*/void *xmalloc (size_t size)
-  /*@ensures MaxSet(result) == (size - 1); @*/;
-extern /*@maynotreturn@*/ /*@only@*//*@notnull@*/char *xstrdup (const char *);
-
 /* xgetpwnam.c */
 extern /*@null@*/ /*@only@*/struct passwd *xgetpwnam (const char *);
 /* xgetpwuid.c */
index 655fd4bf3ee04914edc1315f314494bdb5e65515..57f98e9eeb8d8d3d4a8c05f4313683af32d44f2f 100644 (file)
@@ -10,6 +10,7 @@ libmisc_la_SOURCES = \
        addgrps.c \
        age.c \
        agetpass.c \
+       alloc.c \
        audit_help.c \
        basename.c \
        bit.c \
@@ -78,7 +79,6 @@ libmisc_la_SOURCES = \
        xgetgrnam.c \
        xgetgrgid.c \
        xgetspnam.c \
-       xmalloc.c \
        yesno.c
 
 if WITH_BTRFS
similarity index 100%
rename from libmisc/xmalloc.c
rename to libmisc/alloc.c
index 715d8f53cffb17db8d0e68434f0bcf4e19ed088e..23fbd711e6b68749772585314476babc37c39e9d 100644 (file)
@@ -17,6 +17,8 @@
 #include <sys/time.h>
 #include <fcntl.h>
 #include <stdio.h>
+
+#include "alloc.h"
 #include "prototypes.h"
 #include "defines.h"
 #ifdef WITH_SELINUX
index cc4029d0f8539d6a850bb82a64e793185ead30fc..88a06b246d8346a2ae826ed388ae6e6b3ae77828 100644 (file)
@@ -13,6 +13,8 @@
 
 #include <sys/types.h>
 #include <stdio.h>
+
+#include "alloc.h"
 #include "prototypes.h"
 #include "defines.h"
 #include <pwd.h>
index eba365ae86a3e2968327a19280f0ea35533bec5b..640c96a579dc507f3d75a97560472d507150680c 100644 (file)
@@ -15,6 +15,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
+#include "alloc.h"
 #include "prototypes.h"
 #include "defines.h"
 #include "shadowlog.h"
index 7f7e523e609d340dce07983821e905e5089549a0..d1d5bf6e5ee6db8bc042efd2db5b2cb778a810ff 100644 (file)
 #ident "$Id$"
 
 #include <stdio.h>
-#include "prototypes.h"
+
+#include "alloc.h"
 #include "defines.h"
 #include "getdef.h"
+#include "prototypes.h"
 /*
  * motd -- output the /etc/motd file
  *
index 997bab73f27ae30edc4d0de18e02f1c58281f936..30d058eaf590e9ec8c5ec2f5dea1f541870e7095 100644 (file)
@@ -25,6 +25,8 @@
 #endif                         /* USE_PAM */
 #endif                         /* ACCT_TOOLS_SETUID */
 #include <pwd.h>
+
+#include "alloc.h"
 #include "prototypes.h"
 #include "defines.h"
 #include "pwio.h"
index d56b329e03d891d1612af55d5f9ce2be49bc6491..5018ab87f312dcb01f7e39335ccabd36a2021e16 100644 (file)
@@ -17,6 +17,8 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <getopt.h>
+
+#include "alloc.h"
 #include "defines.h"
 #include "getdef.h"
 #include "nscd.h"
index 64f53392b1151e927e26280f3ed5bd994bb0ef73..639ff630f1d9aa0da2178414e456235b6f80dd83 100644 (file)
@@ -16,6 +16,8 @@
 #include <pwd.h>
 #include <stdio.h>
 #include <sys/types.h>
+
+#include "alloc.h"
 #include "defines.h"
 #include "getdef.h"
 #include "nscd.h"