mirror of
https://github.com/systemd/systemd.git
synced 2025-01-12 13:18:14 +03:00
Merge pull request #26686 from yuwata/iovec
tree-wide: replace IOVEC_INIT with IOVEC_MAKE
This commit is contained in:
commit
df40b7ef5a
@ -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);
|
||||
|
@ -298,8 +298,8 @@ static int pick_uid(char **suggested_paths, const char *name, uid_t *ret_uid) {
|
||||
/* Let's store the user name in the lock file, so that we can use it for looking up the username for a UID */
|
||||
l = pwritev(lock_fd,
|
||||
(struct iovec[2]) {
|
||||
IOVEC_INIT_STRING(name),
|
||||
IOVEC_INIT((char[1]) { '\n' }, 1),
|
||||
IOVEC_MAKE_STRING(name),
|
||||
IOVEC_MAKE((char[1]) { '\n' }, 1),
|
||||
}, 2, 0);
|
||||
if (l < 0) {
|
||||
r = -errno;
|
||||
@ -320,7 +320,7 @@ static int pick_uid(char **suggested_paths, const char *name, uid_t *ret_uid) {
|
||||
|
||||
static int dynamic_user_pop(DynamicUser *d, uid_t *ret_uid, int *ret_lock_fd) {
|
||||
uid_t uid = UID_INVALID;
|
||||
struct iovec iov = IOVEC_INIT(&uid, sizeof(uid));
|
||||
struct iovec iov = IOVEC_MAKE(&uid, sizeof(uid));
|
||||
int lock_fd;
|
||||
ssize_t k;
|
||||
|
||||
@ -342,7 +342,7 @@ static int dynamic_user_pop(DynamicUser *d, uid_t *ret_uid, int *ret_lock_fd) {
|
||||
}
|
||||
|
||||
static int dynamic_user_push(DynamicUser *d, uid_t uid, int lock_fd) {
|
||||
struct iovec iov = IOVEC_INIT(&uid, sizeof(uid));
|
||||
struct iovec iov = IOVEC_MAKE(&uid, sizeof(uid));
|
||||
|
||||
assert(d);
|
||||
|
||||
|
@ -3992,9 +3992,9 @@ static int send_user_lookup(
|
||||
|
||||
if (writev(user_lookup_fd,
|
||||
(struct iovec[]) {
|
||||
IOVEC_INIT(&uid, sizeof(uid)),
|
||||
IOVEC_INIT(&gid, sizeof(gid)),
|
||||
IOVEC_INIT_STRING(unit->id) }, 3) < 0)
|
||||
IOVEC_MAKE(&uid, sizeof(uid)),
|
||||
IOVEC_MAKE(&gid, sizeof(gid)),
|
||||
IOVEC_MAKE_STRING(unit->id) }, 3) < 0)
|
||||
return -errno;
|
||||
|
||||
return 0;
|
||||
|
@ -148,7 +148,13 @@ _public_ int sd_journal_printv(int priority, const char *format, va_list ap) {
|
||||
return sd_journal_sendv(iov, 2);
|
||||
}
|
||||
|
||||
_printf_(1, 0) static int fill_iovec_sprintf(const char *format, va_list ap, size_t extra, struct iovec **ret_iov, size_t *ret_n_iov) {
|
||||
_printf_(1, 0) static int fill_iovec_sprintf(
|
||||
const char *format,
|
||||
va_list ap,
|
||||
size_t extra,
|
||||
struct iovec **ret_iov,
|
||||
size_t *ret_n_iov) {
|
||||
|
||||
PROTECT_ERRNO;
|
||||
struct iovec *iov = NULL;
|
||||
size_t n = 0;
|
||||
|
@ -434,7 +434,7 @@ static int portable_extract_by_path(
|
||||
* identical to NAME_MAX. For now we use that, but this should be updated one day when the final
|
||||
* limit is known. */
|
||||
char iov_buffer[PATH_MAX + NAME_MAX + 2];
|
||||
struct iovec iov = IOVEC_INIT(iov_buffer, sizeof(iov_buffer));
|
||||
struct iovec iov = IOVEC_MAKE(iov_buffer, sizeof(iov_buffer));
|
||||
|
||||
ssize_t n = receive_one_fd_iov(seq[0], &iov, 1, 0, &fd);
|
||||
if (n == -EIO)
|
||||
|
@ -248,7 +248,7 @@ TEST(passfd_read) {
|
||||
|
||||
/* Parent */
|
||||
char buf[64];
|
||||
struct iovec iov = IOVEC_INIT(buf, sizeof(buf)-1);
|
||||
struct iovec iov = IOVEC_MAKE(buf, sizeof(buf)-1);
|
||||
_cleanup_close_ int fd;
|
||||
|
||||
pair[1] = safe_close(pair[1]);
|
||||
@ -275,7 +275,7 @@ TEST(passfd_contents_read) {
|
||||
|
||||
if (r == 0) {
|
||||
/* Child */
|
||||
struct iovec iov = IOVEC_INIT_STRING(wire_contents);
|
||||
struct iovec iov = IOVEC_MAKE_STRING(wire_contents);
|
||||
char tmpfile[] = "/tmp/test-socket-util-passfd-contents-read-XXXXXX";
|
||||
|
||||
pair[0] = safe_close(pair[0]);
|
||||
@ -292,7 +292,7 @@ TEST(passfd_contents_read) {
|
||||
|
||||
/* Parent */
|
||||
char buf[64];
|
||||
struct iovec iov = IOVEC_INIT(buf, sizeof(buf)-1);
|
||||
struct iovec iov = IOVEC_MAKE(buf, sizeof(buf)-1);
|
||||
_cleanup_close_ int fd;
|
||||
ssize_t k;
|
||||
|
||||
@ -322,7 +322,7 @@ TEST(receive_nopassfd) {
|
||||
|
||||
if (r == 0) {
|
||||
/* Child */
|
||||
struct iovec iov = IOVEC_INIT_STRING(wire_contents);
|
||||
struct iovec iov = IOVEC_MAKE_STRING(wire_contents);
|
||||
|
||||
pair[0] = safe_close(pair[0]);
|
||||
|
||||
@ -332,7 +332,7 @@ TEST(receive_nopassfd) {
|
||||
|
||||
/* Parent */
|
||||
char buf[64];
|
||||
struct iovec iov = IOVEC_INIT(buf, sizeof(buf)-1);
|
||||
struct iovec iov = IOVEC_MAKE(buf, sizeof(buf)-1);
|
||||
int fd = -999;
|
||||
ssize_t k;
|
||||
|
||||
@ -366,7 +366,7 @@ TEST(send_nodata_nofd) {
|
||||
|
||||
/* Parent */
|
||||
char buf[64];
|
||||
struct iovec iov = IOVEC_INIT(buf, sizeof(buf)-1);
|
||||
struct iovec iov = IOVEC_MAKE(buf, sizeof(buf)-1);
|
||||
int fd = -999;
|
||||
ssize_t k;
|
||||
|
||||
@ -391,7 +391,7 @@ TEST(send_emptydata) {
|
||||
|
||||
if (r == 0) {
|
||||
/* Child */
|
||||
struct iovec iov = IOVEC_INIT_STRING(""); /* zero-length iov */
|
||||
struct iovec iov = IOVEC_MAKE_STRING(""); /* zero-length iov */
|
||||
assert_se(iov.iov_len == 0);
|
||||
|
||||
pair[0] = safe_close(pair[0]);
|
||||
@ -403,7 +403,7 @@ TEST(send_emptydata) {
|
||||
|
||||
/* Parent */
|
||||
char buf[64];
|
||||
struct iovec iov = IOVEC_INIT(buf, sizeof(buf)-1);
|
||||
struct iovec iov = IOVEC_MAKE(buf, sizeof(buf)-1);
|
||||
int fd = -999;
|
||||
ssize_t k;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user