mirror of
https://github.com/systemd/systemd.git
synced 2024-12-28 11:21:59 +03:00
commit
8875639a7c
@ -3,24 +3,24 @@
|
|||||||
#include "iovec-util.h"
|
#include "iovec-util.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
|
|
||||||
size_t iovec_total_size(const struct iovec *i, size_t n) {
|
size_t iovec_total_size(const struct iovec *iovec, size_t n) {
|
||||||
size_t sum = 0;
|
size_t sum = 0;
|
||||||
|
|
||||||
assert(i || n == 0);
|
assert(iovec || n == 0);
|
||||||
|
|
||||||
FOREACH_ARRAY(j, i, n)
|
FOREACH_ARRAY(j, iovec, n)
|
||||||
sum += j->iov_len;
|
sum += j->iov_len;
|
||||||
|
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool iovec_increment(struct iovec *i, size_t n, size_t k) {
|
bool iovec_increment(struct iovec *iovec, size_t n, size_t k) {
|
||||||
assert(i || n == 0);
|
assert(iovec || n == 0);
|
||||||
|
|
||||||
/* Returns true if there is nothing else to send (bytes written cover all of the iovec),
|
/* Returns true if there is nothing else to send (bytes written cover all of the iovec),
|
||||||
* false if there's still work to do. */
|
* false if there's still work to do. */
|
||||||
|
|
||||||
FOREACH_ARRAY(j, i, n) {
|
FOREACH_ARRAY(j, iovec, n) {
|
||||||
size_t sub;
|
size_t sub;
|
||||||
|
|
||||||
if (j->iov_len == 0)
|
if (j->iov_len == 0)
|
||||||
@ -62,12 +62,9 @@ char* set_iovec_string_field_free(struct iovec *iovec, size_t *n_iovec, const ch
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
void iovec_array_free(struct iovec *iov, size_t n) {
|
void iovec_array_free(struct iovec *iovec, size_t n) {
|
||||||
if (!iov)
|
FOREACH_ARRAY(i, iovec, n)
|
||||||
return;
|
free(i->iov_base);
|
||||||
|
|
||||||
for (size_t i = 0; i < n; i++)
|
free(iovec);
|
||||||
free(iov[i].iov_base);
|
|
||||||
|
|
||||||
free(iov);
|
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,9 @@
|
|||||||
#include "alloc-util.h"
|
#include "alloc-util.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
|
|
||||||
size_t iovec_total_size(const struct iovec *i, size_t n);
|
size_t iovec_total_size(const struct iovec *iovec, size_t n);
|
||||||
|
|
||||||
bool iovec_increment(struct iovec *i, size_t n, size_t k);
|
bool iovec_increment(struct iovec *iovec, size_t n, size_t k);
|
||||||
|
|
||||||
#define IOVEC_NULL (const struct iovec) {}
|
|
||||||
|
|
||||||
#define IOVEC_MAKE(base, len) (struct iovec) { .iov_base = (base), .iov_len = (len) }
|
#define IOVEC_MAKE(base, len) (struct iovec) { .iov_base = (base), .iov_len = (len) }
|
||||||
#define IOVEC_MAKE_STRING(string) \
|
#define IOVEC_MAKE_STRING(string) \
|
||||||
@ -21,8 +19,6 @@ bool iovec_increment(struct iovec *i, size_t n, size_t k);
|
|||||||
IOVEC_MAKE((char*) _s, strlen(_s)); \
|
IOVEC_MAKE((char*) _s, strlen(_s)); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define TAKE_IOVEC(p) TAKE_GENERIC((p), struct iovec, IOVEC_NULL)
|
|
||||||
|
|
||||||
static inline void iovec_done(struct iovec *iovec) {
|
static inline void iovec_done(struct iovec *iovec) {
|
||||||
/* A _cleanup_() helper that frees the iov_base in the iovec */
|
/* A _cleanup_() helper that frees the iov_base in the iovec */
|
||||||
assert(iovec);
|
assert(iovec);
|
||||||
@ -38,11 +34,11 @@ static inline void iovec_done_erase(struct iovec *iovec) {
|
|||||||
iovec->iov_len = 0;
|
iovec->iov_len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool iovec_is_set(const struct iovec *iov) {
|
static inline bool iovec_is_set(const struct iovec *iovec) {
|
||||||
return iov && iov->iov_len > 0 && iov->iov_base;
|
return iovec && iovec->iov_len > 0 && iovec->iov_base;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* set_iovec_string_field(struct iovec *iovec, size_t *n_iovec, const char *field, const char *value);
|
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);
|
char* set_iovec_string_field_free(struct iovec *iovec, size_t *n_iovec, const char *field, char *value);
|
||||||
|
|
||||||
void iovec_array_free(struct iovec *iov, size_t n);
|
void iovec_array_free(struct iovec *iovec, size_t n);
|
||||||
|
@ -530,7 +530,7 @@ _public_ int sd_journal_send_with_location(const char *file, const char *line, c
|
|||||||
|
|
||||||
r = sd_journal_sendv(iov, n_iov);
|
r = sd_journal_sendv(iov, n_iov);
|
||||||
|
|
||||||
iov[0] = iov[1] = iov[2] = IOVEC_NULL;
|
iov[0] = iov[1] = iov[2] = (struct iovec) {};
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -4087,7 +4087,7 @@ static int partition_format_verity_hash(
|
|||||||
p->new_uuid_is_set = true;
|
p->new_uuid_is_set = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
p->roothash = TAKE_IOVEC(rh);
|
p->roothash = TAKE_STRUCT(rh);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
@ -4139,7 +4139,7 @@ static int sign_verity_roothash(
|
|||||||
|
|
||||||
static int partition_format_verity_sig(Context *context, Partition *p) {
|
static int partition_format_verity_sig(Context *context, Partition *p) {
|
||||||
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
|
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
|
||||||
_cleanup_(iovec_done) struct iovec sig = IOVEC_NULL;
|
_cleanup_(iovec_done) struct iovec sig = {};
|
||||||
_cleanup_free_ char *text = NULL, *hint = NULL;
|
_cleanup_free_ char *text = NULL, *hint = NULL;
|
||||||
Partition *hp;
|
Partition *hp;
|
||||||
uint8_t fp[X509_FINGERPRINT_SIZE];
|
uint8_t fp[X509_FINGERPRINT_SIZE];
|
||||||
|
Loading…
Reference in New Issue
Block a user