From: Yu Watanabe Date: Thu, 23 Feb 2023 04:10:31 +0000 (+0900) Subject: io-util: drop double evaluation in IOVEC_INIT_STRING() X-Git-Tag: v254-rc1~1174^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=de5cc016b595d0c3ad18fb3e5fdf011b3ed3363c;p=thirdparty%2Fsystemd.git io-util: drop double evaluation in IOVEC_INIT_STRING() This also makes IOVEC_INIT_STRING() and IOVEC_MAKE_STRING() identical. --- diff --git a/src/basic/io-util.h b/src/basic/io-util.h index 767c8af8fe0..a5c1f89a8dd 100644 --- a/src/basic/io-util.h +++ b/src/basic/io-util.h @@ -77,8 +77,12 @@ static inline bool FILE_SIZE_VALID_OR_INFINITY(uint64_t l) { #define IOVEC_NULL (struct iovec) {} #define IOVEC_INIT(base, len) { .iov_base = (base), .iov_len = (len) } #define IOVEC_MAKE(base, len) (struct iovec) IOVEC_INIT(base, len) -#define IOVEC_INIT_STRING(string) IOVEC_INIT((char*) string, strlen(string)) -#define IOVEC_MAKE_STRING(string) (struct iovec) IOVEC_INIT_STRING(string) +#define IOVEC_INIT_STRING(string) \ + ({ \ + char *_s = (char*) (string); \ + IOVEC_MAKE(_s, strlen(_s)); \ + }) +#define IOVEC_MAKE_STRING(string) IOVEC_INIT_STRING(string) 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);