From: Zbigniew Jędrzejewski-Szmek Date: Tue, 14 Apr 2026 06:28:28 +0000 (+0200) Subject: basic/iovec-wrapper: drop unused code X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=267b16f33c5636617927f15d7ae6b945c862a587;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/basic/iovec-wrapper.c b/src/basic/iovec-wrapper.c index b4519f808d5..7f91f5e893b 100644 --- a/src/basic/iovec-wrapper.c +++ b/src/basic/iovec-wrapper.c @@ -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); } diff --git a/src/basic/iovec-wrapper.h b/src/basic/iovec-wrapper.h index 94b39feb152..bfe739ecf1e 100644 --- a/src/basic/iovec-wrapper.h +++ b/src/basic/iovec-wrapper.h @@ -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); diff --git a/src/test/test-log.c b/src/test/test-log.c index f77ed205a70..a62f54006e2 100644 --- a/src/test/test-log.c +++ b/src/test/test-log.c @@ -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);