Skip to content

Commit 2ac1426

Browse files
lib/, src/, tests/: Move x*() definitions to non-x* header files
Now that all of these are one-liners, they don't need a separate header file. Compact stuff. Signed-off-by: Alejandro Colomar <[email protected]>
1 parent f57f94d commit 2ac1426

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+85
-203
lines changed

lib/Makefile.am

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ libshadow_la_SOURCES = \
3737
alloc/realloc.h \
3838
alloc/reallocf.c \
3939
alloc/reallocf.h \
40-
alloc/x/xcalloc.c \
41-
alloc/x/xcalloc.h \
42-
alloc/x/xmalloc.c \
43-
alloc/x/xmalloc.h \
44-
alloc/x/xrealloc.c \
45-
alloc/x/xrealloc.h \
4640
atoi/a2i/a2i.c \
4741
atoi/a2i/a2i.h \
4842
atoi/a2i/a2s.c \
@@ -199,8 +193,6 @@ libshadow_la_SOURCES = \
199193
string/sprintf/snprintf.h \
200194
string/sprintf/stpeprintf.c \
201195
string/sprintf/stpeprintf.h \
202-
string/sprintf/xaprintf.c \
203-
string/sprintf/xaprintf.h \
204196
string/strchr/strchrcnt.c \
205197
string/strchr/strchrcnt.h \
206198
string/strchr/strchrscnt.c \
@@ -223,12 +215,12 @@ libshadow_la_SOURCES = \
223215
string/strcpy/strncpy.h \
224216
string/strcpy/strtcpy.c \
225217
string/strcpy/strtcpy.h \
218+
string/strdup/strdup.c \
219+
string/strdup/strdup.h \
226220
string/strdup/strndupa.c \
227221
string/strdup/strndupa.h \
228-
string/strdup/xstrdup.c \
229-
string/strdup/xstrdup.h \
230-
string/strdup/xstrndup.c \
231-
string/strdup/xstrndup.h \
222+
string/strdup/strndup.c \
223+
string/strdup/strndup.h \
232224
string/strftime.c \
233225
string/strftime.h \
234226
string/strspn/stpspn.c \
@@ -249,8 +241,6 @@ libshadow_la_SOURCES = \
249241
string/strtok/strsep2arr.h \
250242
string/strtok/strsep2ls.c \
251243
string/strtok/strsep2ls.h \
252-
string/strtok/xastrsep2ls.c \
253-
string/strtok/xastrsep2ls.h \
254244
strtoday.c \
255245
sub.c \
256246
subordinateio.h \

lib/alloc/calloc.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <[email protected]>
1+
// SPDX-FileCopyrightText: 2023-2025, Alejandro Colomar <[email protected]>
22
// SPDX-License-Identifier: BSD-3-Clause
33

44

@@ -10,11 +10,16 @@
1010

1111
#include <stdlib.h>
1212

13+
#include "x.h"
14+
1315

1416
#define CALLOC(n, type) \
1517
( \
1618
(type *) calloc(n, sizeof(type)) \
1719
)
1820

1921

22+
#define XCALLOC(n, type) X(CALLOC(n, type))
23+
24+
2025
#endif // include guard

lib/alloc/malloc.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <[email protected]>
1+
// SPDX-FileCopyrightText: 2023-2025, Alejandro Colomar <[email protected]>
22
// SPDX-License-Identifier: BSD-3-Clause
33

44

@@ -11,6 +11,7 @@
1111
#include <stdlib.h>
1212

1313
#include "attr.h"
14+
#include "x.h"
1415

1516

1617
#define MALLOC(n, type) \
@@ -19,6 +20,9 @@
1920
)
2021

2122

23+
#define XMALLOC(n, type) X(MALLOC(n, type))
24+
25+
2226
ATTR_ALLOC_SIZE(1, 2)
2327
ATTR_MALLOC(free)
2428
inline void *mallocarray(size_t nmemb, size_t size);

lib/alloc/realloc.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <[email protected]>
1+
// SPDX-FileCopyrightText: 2023-2025, Alejandro Colomar <[email protected]>
22
// SPDX-License-Identifier: BSD-3-Clause
33

44

@@ -9,6 +9,7 @@
99
#include <config.h>
1010

1111
#include <stdlib.h>
12+
#include "x.h"
1213

1314

1415
#define REALLOC(p, n, type) \
@@ -17,4 +18,7 @@
1718
)
1819

1920

21+
#define XREALLOC(p, n, type) X(REALLOC(p, n, type))
22+
23+
2024
#endif // include guard

lib/alloc/x/xcalloc.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

lib/alloc/x/xmalloc.c

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/alloc/x/xmalloc.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

lib/alloc/x/xrealloc.c

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/alloc/x/xrealloc.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

lib/copydir.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <stdio.h>
2020
#include <string.h>
2121

22-
#include "alloc/x/xmalloc.h"
22+
#include "alloc/malloc.h"
2323
#include "attr.h"
2424
#include "fs/readlink/areadlink.h"
2525
#include "prototypes.h"
@@ -39,7 +39,6 @@
3939
#endif /* WITH_ATTR */
4040
#include "shadowlog.h"
4141
#include "string/sprintf/aprintf.h"
42-
#include "string/sprintf/xaprintf.h"
4342
#include "string/strcmp/streq.h"
4443
#include "string/strcmp/strprefix.h"
4544

lib/env.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@
1616
#include <stdlib.h>
1717
#include <string.h>
1818

19-
#include "alloc/x/xmalloc.h"
20-
#include "alloc/x/xrealloc.h"
19+
#include "alloc/malloc.h"
20+
#include "alloc/realloc.h"
2121
#include "prototypes.h"
2222
#include "defines.h"
2323
#include "shadowlog.h"
24+
#include "string/sprintf/aprintf.h"
2425
#include "string/sprintf/snprintf.h"
25-
#include "string/sprintf/xaprintf.h"
26+
#include "string/sprintf/aprintf.h"
2627
#include "string/strcmp/strprefix.h"
27-
#include "string/strdup/xstrdup.h"
28+
#include "string/strdup/strdup.h"
2829

2930

3031
/*

lib/getdef.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#include "prototypes.h"
3131
#include "shadowlog_internal.h"
3232
#include "sizeof.h"
33-
#include "string/sprintf/xaprintf.h"
33+
#include "string/sprintf/aprintf.h"
3434
#include "string/strcmp/strcaseeq.h"
3535
#include "string/strcmp/streq.h"
3636
#include "string/strcmp/strprefix.h"

lib/gshadow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
#include "defines.h"
2424
#include "prototypes.h"
2525
#include "string/strcmp/streq.h"
26+
#include "string/strtok/astrsep2ls.h"
2627
#include "string/strtok/stpsep.h"
2728
#include "string/strtok/strsep2arr.h"
28-
#include "string/strtok/xastrsep2ls.h"
2929

3030

3131
static /*@null@*/FILE *shadow;

lib/idmapping.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#endif
1919

2020
#include "alloc/calloc.h"
21-
#include "alloc/x/xmalloc.h"
21+
#include "alloc/malloc.h"
2222
#include "atoi/a2i/a2u.h"
2323
#include "idmapping.h"
2424
#include "prototypes.h"

lib/list.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
#include <assert.h>
1414

15-
#include "alloc/x/xmalloc.h"
15+
#include "alloc/malloc.h"
1616
#include "prototypes.h"
1717
#include "defines.h"
1818
#include "string/strchr/strchrcnt.h"
1919
#include "string/strcmp/streq.h"
20-
#include "string/strdup/xstrdup.h"
20+
#include "string/strdup/strdup.h"
2121
#include "string/strtok/strsep2ls.h"
2222

2323

lib/mail.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <string.h>
1717

1818
#include "getdef.h"
19-
#include "string/sprintf/xaprintf.h"
19+
#include "string/sprintf/aprintf.h"
2020

2121
#ident "$Id$"
2222

lib/obscure.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#include "getdef.h"
2121
#include "string/ctype/strtoascii/strtolower.h"
2222
#include "string/memset/memzero.h"
23-
#include "string/sprintf/xaprintf.h"
23+
#include "string/sprintf/aprintf.h"
2424
#include "string/strcmp/streq.h"
25-
#include "string/strdup/xstrdup.h"
25+
#include "string/strdup/strdup.h"
2626

2727

2828
#if WITH_LIBBSD == 0

lib/prefix_flag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#endif /* ENABLE_SUBIDS */
2929
#include "getdef.h"
3030
#include "shadowlog.h"
31-
#include "string/sprintf/xaprintf.h"
31+
#include "string/sprintf/aprintf.h"
3232
#include "string/strcmp/streq.h"
3333
#include "string/strcmp/strprefix.h"
3434

lib/setupenv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
#include <pwd.h>
2727
#include "getdef.h"
2828
#include "shadowlog.h"
29-
#include "string/sprintf/xaprintf.h"
29+
#include "string/sprintf/aprintf.h"
3030
#include "string/strcmp/streq.h"
3131
#include "string/strcmp/strprefix.h"
32-
#include "string/strdup/xstrdup.h"
32+
#include "string/strdup/strdup.h"
3333
#include "string/strspn/stpspn.h"
3434
#include "string/strtok/stpsep.h"
3535

lib/string/sprintf/aprintf.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
#include <stdlib.h>
1515

1616
#include "attr.h"
17+
#include "x.h"
18+
19+
20+
// exit-on-error allocate print formatted
21+
#define xaprintf(...) X(aprintf(__VA_ARGS__))
1722

1823

1924
ATTR_MALLOC(free)

lib/string/sprintf/xaprintf.c

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/string/sprintf/xaprintf.h

Lines changed: 0 additions & 19 deletions
This file was deleted.

lib/alloc/x/xcalloc.c renamed to lib/string/strdup/strdup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
#include <config.h>
66

7-
#include "alloc/x/xcalloc.h"
7+
#include "string/strdup/strdup.h"

lib/string/strdup/xstrdup.h renamed to lib/string/strdup/strdup.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// SPDX-License-Identifier: BSD-3-Clause
77

88

9-
#ifndef SHADOW_INCLUDE_LIB_STRING_STRDUP_XSTRDUP_H_
10-
#define SHADOW_INCLUDE_LIB_STRING_STRDUP_XSTRDUP_H_
9+
#ifndef SHADOW_INCLUDE_LIB_STRING_STRDUP_STRDUP_H_
10+
#define SHADOW_INCLUDE_LIB_STRING_STRDUP_STRDUP_H_
1111

1212

1313
#include <config.h>

lib/string/strdup/xstrndup.c renamed to lib/string/strdup/strndup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
#include <config.h>
66

7-
#include "string/strdup/xstrndup.h"
7+
#include "string/strdup/strndup.h"

lib/string/strdup/xstrndup.h renamed to lib/string/strdup/strndup.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// SPDX-License-Identifier: BSD-3-Clause
33

44

5-
#ifndef SHADOW_INCLUDE_LIB_STRING_STRDUP_XSTRNDUP_H_
6-
#define SHADOW_INCLUDE_LIB_STRING_STRDUP_XSTRNDUP_H_
5+
#ifndef SHADOW_INCLUDE_LIB_STRING_STRDUP_STRNDUP_H_
6+
#define SHADOW_INCLUDE_LIB_STRING_STRDUP_STRNDUP_H_
77

88

99
#include <config.h>

lib/string/strdup/xstrdup.c

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)