From: Alejandro Colomar Date: Sat, 7 Jun 2025 17:29:10 +0000 (+0200) Subject: lib/string/strtok/: xastrsep2ls() Reimplement in terms of exit_if_null() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e5b6968406c74dd116e97446218bdb54057b0b86;p=thirdparty%2Fshadow.git lib/string/strtok/: xastrsep2ls() Reimplement in terms of exit_if_null() Signed-off-by: Alejandro Colomar --- diff --git a/lib/string/strtok/xastrsep2ls.c b/lib/string/strtok/xastrsep2ls.c index d0711e870..c3d43b90c 100644 --- a/lib/string/strtok/xastrsep2ls.c +++ b/lib/string/strtok/xastrsep2ls.c @@ -1,13 +1,7 @@ -// SPDX-FileCopyrightText: 2024, Alejandro Colomar +// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar // SPDX-License-Identifier: BSD-3-Clause #include "config.h" #include "string/strtok/xastrsep2ls.h" - -#include - - -extern inline char **xastrsep2ls(char *restrict s, const char *restrict delim, - size_t *restrict np); diff --git a/lib/string/strtok/xastrsep2ls.h b/lib/string/strtok/xastrsep2ls.h index b5382cbb2..d9710db87 100644 --- a/lib/string/strtok/xastrsep2ls.h +++ b/lib/string/strtok/xastrsep2ls.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2024, Alejandro Colomar +// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar // SPDX-License-Identifier: BSD-3-Clause @@ -8,39 +8,11 @@ #include "config.h" -#include -#include -#include -#include -#include - -#include "attr.h" -#include "shadowlog.h" +#include "exit_if_null.h" #include "string/strtok/astrsep2ls.h" -ATTR_ACCESS(read_write, 1) ATTR_ACCESS(write_only, 3) -ATTR_STRING(1) ATTR_STRING(2) -inline char **xastrsep2ls(char *restrict s, const char *restrict delim, - size_t *restrict np); - - -// exit-on-error allocate string separate to list-of-strings -inline char ** -xastrsep2ls(char *s, const char *restrict delim, size_t *restrict np) -{ - char **ls; - - ls = astrsep2ls(s, delim, np); - if (ls == NULL) - goto x; - - return ls; -x: - fprintf(log_get_logfd(), "%s: %s\n", - log_get_progname(), strerror(errno)); - exit(13); -} +#define xastrsep2ls(s, delim, np) exit_if_null(astrsep2ls(s, delim, np)) #endif // include guard