From: Yu Watanabe Date: Thu, 23 Apr 2026 18:27:36 +0000 (+0900) Subject: iovec-wrapper: make iovw_size() take NULL again X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=58863bdaec9ba4f6be5a171bdc5ffa42f22580a7;p=thirdparty%2Fsystemd.git iovec-wrapper: make iovw_size() take NULL again This partially reverts 267b16f33c5636617927f15d7ae6b945c862a587. We usually make xyz_size() take NULL, e.g. hashmap_size(). --- diff --git a/src/basic/iovec-wrapper.c b/src/basic/iovec-wrapper.c index 59b1addaaf2..c5d1a878ff3 100644 --- a/src/basic/iovec-wrapper.c +++ b/src/basic/iovec-wrapper.c @@ -237,7 +237,8 @@ void iovw_rebase(struct iovec_wrapper *iovw, void *old, void *new) { } size_t iovw_size(const struct iovec_wrapper *iovw) { - assert(iovw); + if (iovw_isempty(iovw)) + return 0; return iovec_total_size(iovw->iovec, iovw->count); } diff --git a/src/test/test-iovec-wrapper.c b/src/test/test-iovec-wrapper.c index 791a041ab8d..d38806e75e5 100644 --- a/src/test/test-iovec-wrapper.c +++ b/src/test/test-iovec-wrapper.c @@ -393,6 +393,8 @@ TEST(iovw_size) { ASSERT_OK(iovw_put(&iovw, (char*) "efghij", 6)); ASSERT_OK(iovw_put(&iovw, (char*) "kl", 2)); ASSERT_EQ(iovw_size(&iovw), 12U); + + ASSERT_EQ(iovw_size(NULL), 0U); } TEST(iovw_concat) {