]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
iovec-wrapper: make iovw_size() take NULL again
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 23 Apr 2026 18:27:36 +0000 (03:27 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 12 May 2026 06:33:21 +0000 (15:33 +0900)
This partially reverts 267b16f33c5636617927f15d7ae6b945c862a587.

We usually make xyz_size() take NULL, e.g. hashmap_size().

src/basic/iovec-wrapper.c
src/test/test-iovec-wrapper.c

index 59b1addaaf266898247edd56ce53fb38a16204a7..c5d1a878ff3cb4aeb8532f693654f59e6b860f52 100644 (file)
@@ -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);
 }
index 791a041ab8d6fbc70d75f3e6517448c46ffe331c..d38806e75e543b3b3bece7ae6624c85097d0fd60 100644 (file)
@@ -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) {