mirror of
https://github.com/systemd/systemd.git
synced 2026-08-05 07:30:30 +00:00
basic/iovec-wrapper: drop unused code
All non-test users iovec_wrapper define the struct as a field in a bigger structure, so we never free it individually. Let's simplify the code and assume it is never null.
This commit is contained in:
@@ -7,10 +7,6 @@
|
||||
#include "iovec-wrapper.h"
|
||||
#include "string-util.h"
|
||||
|
||||
struct iovec_wrapper *iovw_new(void) {
|
||||
return new0(struct iovec_wrapper, 1);
|
||||
}
|
||||
|
||||
void iovw_done(struct iovec_wrapper *iovw) {
|
||||
assert(iovw);
|
||||
|
||||
@@ -27,22 +23,6 @@ void iovw_done_free(struct iovec_wrapper *iovw) {
|
||||
iovw_done(iovw);
|
||||
}
|
||||
|
||||
struct iovec_wrapper *iovw_free_free(struct iovec_wrapper *iovw) {
|
||||
if (!iovw)
|
||||
return NULL;
|
||||
|
||||
iovw_done_free(iovw);
|
||||
return mfree(iovw);
|
||||
}
|
||||
|
||||
struct iovec_wrapper *iovw_free(struct iovec_wrapper *iovw) {
|
||||
if (!iovw)
|
||||
return NULL;
|
||||
|
||||
iovw_done(iovw);
|
||||
return mfree(iovw);
|
||||
}
|
||||
|
||||
int iovw_put(struct iovec_wrapper *iovw, void *data, size_t len) {
|
||||
assert(iovw);
|
||||
|
||||
@@ -118,8 +98,7 @@ void iovw_rebase(struct iovec_wrapper *iovw, void *old, void *new) {
|
||||
}
|
||||
|
||||
size_t iovw_size(const struct iovec_wrapper *iovw) {
|
||||
if (!iovw)
|
||||
return 0;
|
||||
assert(iovw);
|
||||
|
||||
return iovec_total_size(iovw->iovec, iovw->count);
|
||||
}
|
||||
|
||||
@@ -8,12 +8,6 @@ struct iovec_wrapper {
|
||||
size_t count;
|
||||
};
|
||||
|
||||
struct iovec_wrapper *iovw_new(void);
|
||||
struct iovec_wrapper *iovw_free(struct iovec_wrapper *iovw);
|
||||
struct iovec_wrapper *iovw_free_free(struct iovec_wrapper *iovw);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct iovec_wrapper*, iovw_free_free);
|
||||
|
||||
void iovw_done_free(struct iovec_wrapper *iovw);
|
||||
void iovw_done(struct iovec_wrapper *iovw);
|
||||
|
||||
|
||||
@@ -261,13 +261,12 @@ static void test_log_context(void) {
|
||||
IOVEC_MAKE_STRING("ABC=def"),
|
||||
IOVEC_MAKE_STRING("GHI=jkl"),
|
||||
};
|
||||
_cleanup_free_ struct iovec_wrapper *iovw = NULL;
|
||||
ASSERT_NOT_NULL(iovw = iovw_new());
|
||||
ASSERT_OK(iovw_consume(iovw, strdup("MNO=pqr"), STRLEN("MNO=pqr") + 1));
|
||||
struct iovec_wrapper iovw = {};
|
||||
ASSERT_OK(iovw_consume(&iovw, strdup("MNO=pqr"), STRLEN("MNO=pqr") + 1));
|
||||
|
||||
LOG_CONTEXT_PUSH_IOV(iov, ELEMENTSOF(iov));
|
||||
LOG_CONTEXT_PUSH_IOV(iov, ELEMENTSOF(iov));
|
||||
LOG_CONTEXT_CONSUME_IOV(iovw->iovec, iovw->count);
|
||||
LOG_CONTEXT_CONSUME_IOV(iovw.iovec, iovw.count);
|
||||
LOG_CONTEXT_PUSH("STU=vwx");
|
||||
|
||||
ASSERT_EQ(log_context_num_contexts(), 3U);
|
||||
|
||||
Reference in New Issue
Block a user