tree-wide: replace IOVEC_INIT with IOVEC_MAKE

We use gnu11 to build, hence we can use structured initializer with
casting, and it is not necessary to use different patterns on
initialization and assignment.

Addresses https://github.com/systemd/systemd/pull/26560#discussion_r1118875447.
This commit is contained in:
Yu Watanabe
2023-03-06 09:30:28 +09:00
parent a0229fb14d
commit ce16d177dd
5 changed files with 18 additions and 20 deletions
+2 -4
View File
@@ -75,14 +75,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) \
#define IOVEC_MAKE(base, len) (struct iovec) { .iov_base = (base), .iov_len = (len) }
#define IOVEC_MAKE_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);