sizeof.h: Move sizeof()-related macros to their own header
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>
This commit is contained in:
committed by
Iker Pedrosa
parent
246edc0481
commit
328958ca01
@@ -131,6 +131,7 @@ libshadow_la_SOURCES = \
|
||||
shadowlog_internal.h \
|
||||
shadowmem.c \
|
||||
shell.c \
|
||||
sizeof.h \
|
||||
spawn.c \
|
||||
sssd.c \
|
||||
sssd.h \
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
#include "shadowlog.h"
|
||||
#include "sizeof.h"
|
||||
|
||||
|
||||
static uint32_t csrand_uniform32(uint32_t n);
|
||||
|
||||
@@ -155,10 +155,6 @@
|
||||
#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... */
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
21
lib/sizeof.h
Normal file
21
lib/sizeof.h
Normal file
@@ -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
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "alloc.h"
|
||||
#include "sizeof.h"
|
||||
|
||||
#ident "$Id$"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user