]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
sizeof.h: Move sizeof()-related macros to their own header
authorAlejandro Colomar <alx@kernel.org>
Sun, 30 Jul 2023 12:05:10 +0000 (14:05 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 1 Sep 2023 07:39:23 +0000 (09:39 +0200)
Cc: Christian Göttsche <cgzones@googlemail.com>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: Iker Pedrosa <ipedrosa@redhat.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/Makefile.am
lib/csrand.c
lib/defines.h
lib/idmapping.c
lib/sizeof.h [new file with mode: 0644]
lib/utmp.c
src/login_nopam.c

index f585215153b8fd861dd9b93db76f41c9308ee98f..3b56ce4cfc7a68ea43fbdd960a50addc01d49318 100644 (file)
@@ -131,6 +131,7 @@ libshadow_la_SOURCES = \
        shadowlog_internal.h \
        shadowmem.c \
        shell.c \
+       sizeof.h \
        spawn.c \
        sssd.c \
        sssd.h \
index e85eaa8a4b44e83b40e22d1fd3bbbe4f6847f0af..9d6f1503dfd231d81c8bb976727e9a361ff2d01d 100644 (file)
@@ -20,6 +20,7 @@
 #include "defines.h"
 #include "prototypes.h"
 #include "shadowlog.h"
+#include "sizeof.h"
 
 
 static uint32_t csrand_uniform32(uint32_t n);
index a24a0c7d3e2c66e3ffde9e1bc93d0db22afb470f..d517424cd5155faa3365359e22111b9a9bdafeb3 100644 (file)
 #define SCALE DAY
 #endif
 
-#define WIDTHOF(x)   (sizeof(x) * CHAR_BIT)
-#define NITEMS(arr)  (sizeof((arr)) / sizeof((arr)[0]))
-#define STRLEN(s)    (NITEMS(s) - 1)
-
 /* Copy string pointed by B to array A with size checking.  It was originally
    in lmain.c but is _very_ useful elsewhere.  Some setuid root programs with
    very sloppy coding used to assume that BUFSIZ will always be enough...  */
index b4e459e6755cdcce93bc11b433e77f59c66922bb..d9f9cd5230d2f8a65435e08c5efd2b0e188c93d1 100644 (file)
@@ -21,6 +21,7 @@
 #include <sys/capability.h>
 #endif
 #include "shadowlog.h"
+#include "sizeof.h"
 
 struct map_range *get_map_ranges(int ranges, int argc, char **argv)
 {
diff --git a/lib/sizeof.h b/lib/sizeof.h
new file mode 100644 (file)
index 0000000..b1a5daf
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * SPDX-FileCopyrightText: 2022-2023, Alejandro Colomar <alx@kernel.org>
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+#ifndef SHADOW_INCLUDE_LIBMISC_SIZEOF_H_
+#define SHADOW_INCLUDE_LIBMISC_SIZEOF_H_
+
+
+#include <config.h>
+
+#include <limits.h>
+
+
+#define WIDTHOF(x)   (sizeof(x) * CHAR_BIT)
+#define NITEMS(arr)  (sizeof((arr)) / sizeof((arr)[0]))
+#define STRLEN(s)    (NITEMS(s) - 1)
+
+
+#endif  // include guard
index 2cccdcd2947c6d413019b568104682043405cf0a..be8efa340bd6fc731aafc1790b2317aae2c73189 100644 (file)
@@ -23,6 +23,7 @@
 #include <fcntl.h>
 
 #include "alloc.h"
+#include "sizeof.h"
 
 #ident "$Id$"
 
index 4b0f6882a25b72d11b908098b3397a640dc15c93..cd5bc5b7238ea4c62df6e0669beddee6b6e10682 100644 (file)
@@ -56,6 +56,8 @@
 #include <netinet/in.h>
 #include <arpa/inet.h>         /* for inet_ntoa() */
 
+#include "sizeof.h"
+
 #if !defined(MAXHOSTNAMELEN) || (MAXHOSTNAMELEN < 64)
 #undef MAXHOSTNAMELEN
 #define MAXHOSTNAMELEN 256