mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 08:25:20 +09:00
iovec-util: Reduce transitive includes
This commit is contained in:
committed by
Yu Watanabe
parent
dc7b151264
commit
e53d4f343d
@@ -1,5 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "analyze.h"
|
||||
#include "analyze-pcrs.h"
|
||||
#include "fileio.h"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "analyze.h"
|
||||
#include "analyze-srk.h"
|
||||
#include "fileio.h"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "iovec-util.h"
|
||||
#include "string-util.h"
|
||||
|
||||
@@ -51,6 +52,20 @@ bool iovec_increment(struct iovec *iovec, size_t n, size_t k) {
|
||||
return true;
|
||||
}
|
||||
|
||||
struct iovec* iovec_make_string(struct iovec *iovec, const char *s) {
|
||||
assert(iovec);
|
||||
|
||||
*iovec = IOVEC_MAKE(s, strlen_ptr(s));
|
||||
return iovec;
|
||||
}
|
||||
|
||||
void iovec_done_erase(struct iovec *iovec) {
|
||||
assert(iovec);
|
||||
|
||||
iovec->iov_base = erase_and_free(iovec->iov_base);
|
||||
iovec->iov_len = 0;
|
||||
}
|
||||
|
||||
char* set_iovec_string_field(struct iovec *iovec, size_t *n_iovec, const char *field, const char *value) {
|
||||
char *x;
|
||||
|
||||
@@ -83,6 +98,33 @@ void iovec_array_free(struct iovec *iovec, size_t n_iovec) {
|
||||
free(iovec);
|
||||
}
|
||||
|
||||
int iovec_memcmp(const struct iovec *a, const struct iovec *b) {
|
||||
|
||||
if (a == b)
|
||||
return 0;
|
||||
|
||||
return memcmp_nn(a ? a->iov_base : NULL,
|
||||
a ? a->iov_len : 0,
|
||||
b ? b->iov_base : NULL,
|
||||
b ? b->iov_len : 0);
|
||||
}
|
||||
|
||||
struct iovec* iovec_memdup(const struct iovec *source, struct iovec *ret) {
|
||||
assert(ret);
|
||||
|
||||
if (!iovec_is_set(source))
|
||||
*ret = (struct iovec) {};
|
||||
else {
|
||||
void *p = memdup(source->iov_base, source->iov_len);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
*ret = IOVEC_MAKE(p, source->iov_len);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct iovec* iovec_append(struct iovec *iovec, const struct iovec *append) {
|
||||
assert(iovec_is_valid(iovec));
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "iovec-util-fundamental.h"
|
||||
#include "macro.h"
|
||||
|
||||
@@ -16,12 +15,7 @@ size_t iovec_total_size(const struct iovec *iovec, size_t n) _nonnull_if_nonzero
|
||||
|
||||
bool iovec_increment(struct iovec *iovec, size_t n, size_t k) _nonnull_if_nonzero_(1, 2);
|
||||
|
||||
static inline struct iovec* iovec_make_string(struct iovec *iovec, const char *s) {
|
||||
assert(iovec);
|
||||
/* We don't use strlen_ptr() here, because we don't want to include string-util.h for now */
|
||||
*iovec = IOVEC_MAKE(s, s ? strlen(s) : 0);
|
||||
return iovec;
|
||||
}
|
||||
struct iovec* iovec_make_string(struct iovec *iovec, const char *s);
|
||||
|
||||
#define IOVEC_MAKE_STRING(s) \
|
||||
*iovec_make_string(&(struct iovec) {}, s)
|
||||
@@ -32,43 +26,15 @@ static inline struct iovec* iovec_make_string(struct iovec *iovec, const char *s
|
||||
.iov_len = STRLEN(s), \
|
||||
}
|
||||
|
||||
static inline void iovec_done_erase(struct iovec *iovec) {
|
||||
assert(iovec);
|
||||
|
||||
iovec->iov_base = erase_and_free(iovec->iov_base);
|
||||
iovec->iov_len = 0;
|
||||
}
|
||||
void iovec_done_erase(struct iovec *iovec);
|
||||
|
||||
char* set_iovec_string_field(struct iovec *iovec, size_t *n_iovec, const char *field, const char *value);
|
||||
char* set_iovec_string_field_free(struct iovec *iovec, size_t *n_iovec, const char *field, char *value);
|
||||
|
||||
void iovec_array_free(struct iovec *iovec, size_t n_iovec) _nonnull_if_nonzero_(1, 2);
|
||||
|
||||
static inline int iovec_memcmp(const struct iovec *a, const struct iovec *b) {
|
||||
int iovec_memcmp(const struct iovec *a, const struct iovec *b) _pure_;
|
||||
|
||||
if (a == b)
|
||||
return 0;
|
||||
|
||||
return memcmp_nn(a ? a->iov_base : NULL,
|
||||
a ? a->iov_len : 0,
|
||||
b ? b->iov_base : NULL,
|
||||
b ? b->iov_len : 0);
|
||||
}
|
||||
|
||||
static inline struct iovec* iovec_memdup(const struct iovec *source, struct iovec *ret) {
|
||||
assert(ret);
|
||||
|
||||
if (!iovec_is_set(source))
|
||||
*ret = (struct iovec) {};
|
||||
else {
|
||||
void *p = memdup(source->iov_base, source->iov_len);
|
||||
if (!p)
|
||||
return NULL;
|
||||
|
||||
*ret = IOVEC_MAKE(p, source->iov_len);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
struct iovec* iovec_memdup(const struct iovec *source, struct iovec *ret);
|
||||
|
||||
struct iovec* iovec_append(struct iovec *iovec, const struct iovec *append);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <threads.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "env-util.h"
|
||||
#include "iovec-util.h"
|
||||
#include "log.h"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "bootctl.h"
|
||||
#include "bootctl-install.h"
|
||||
#include "bootctl-random-seed.h"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <uchar.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "bootctl.h"
|
||||
#include "bootctl-set-efivar.h"
|
||||
#include "efi-loader.h"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "bootctl.h"
|
||||
#include "bootctl-status.h"
|
||||
#include "bootctl-util.h"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "bootctl.h"
|
||||
#include "bootctl-util.h"
|
||||
#include "errno-util.h"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "cryptsetup-keyfile.h"
|
||||
#include "fileio.h"
|
||||
#include "log.h"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <libcryptsetup.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "cryptsetup-token.h"
|
||||
#include "cryptsetup-token-util.h"
|
||||
#include "hexdecoct.h"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <errno.h>
|
||||
#include <libcryptsetup.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "cryptsetup-token.h"
|
||||
#include "cryptsetup-token-util.h"
|
||||
#include "hexdecoct.h"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <libcryptsetup.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "cryptsetup-token-util.h"
|
||||
#include "hexdecoct.h"
|
||||
#include "json-util.h"
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <fido.h>
|
||||
#endif
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "ask-password-api.h"
|
||||
#include "errno-util.h"
|
||||
#include "fido2-util.h"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <openssl/pem.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
#include "json-util.h"
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <netinet/icmp6.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "icmp6-packet.h"
|
||||
#include "icmp6-util.h"
|
||||
#include "in-addr-util.h"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <linux/ipv6.h>
|
||||
#include <netinet/icmp6.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "dns-domain.h"
|
||||
#include "dns-resolver-internal.h"
|
||||
#include "ether-addr-util.h"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "dhcp-server-lease-internal.h"
|
||||
#include "fd-util.h"
|
||||
#include "fs-util.h"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "sd-netlink.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "iovec-util.h"
|
||||
#include "log.h"
|
||||
#include "netlink-internal.h"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "af-list.h"
|
||||
#include "alloc-util.h"
|
||||
#include "daemon-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/x509v3.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "io-util.h"
|
||||
#include "openssl-util.h"
|
||||
#include "resolved-dns-server.h"
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <fnmatch.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "bootspec.h"
|
||||
#include "bootspec-fundamental.h"
|
||||
#include "chase.h"
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "sd-json.h"
|
||||
#include "sd-varlink.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "blockdev-util.h"
|
||||
#include "capability-util.h"
|
||||
#include "chattr-util.h"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "fido2-util.h"
|
||||
#include "fileio.h"
|
||||
#include "libfido2-util.h"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "env-file.h"
|
||||
#include "fd-util.h"
|
||||
#include "fileio.h"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "ask-password-api.h"
|
||||
#include "iovec-util.h"
|
||||
#include "macro.h"
|
||||
#include "memory-util.h"
|
||||
#include "sha256.h"
|
||||
|
||||
typedef enum CertificateSourceType {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "alloc-util.h"
|
||||
#include "ask-password-api.h"
|
||||
#include "dlfcn-util.h"
|
||||
#include "env-util.h"
|
||||
|
||||
Reference in New Issue
Block a user