]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
io-util: drop double evaluation in IOVEC_INIT_STRING()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 23 Feb 2023 04:10:31 +0000 (13:10 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 23 Feb 2023 06:09:59 +0000 (15:09 +0900)
This also makes IOVEC_INIT_STRING() and IOVEC_MAKE_STRING() identical.

src/basic/io-util.h

index 767c8af8fe0b2fdb0e30e97aec5b551465ae6053..a5c1f89a8dd4f39d985e63d039e29d2d4e18fec4 100644 (file)
@@ -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);