Commit Graph
20 Commits
Author SHA1 Message Date
Mike Yuan 6da2ea9fa9 basic: use _nonnull_if_nonzero_ where appropriate 2025-02-16 12:37:10 +09:00
Lennart Poettering 664570f531 iovec-util: add iovec_append() for appending to an existing iovec 2024-09-06 15:23:14 +02:00
Lennart Poettering ba694646ea iovec-util: make "struct iovec" and some helpers also available in EFI mode
The construct is a POSIX invention, but it's just so useful, let's also
define it in EFI mode, so that we can use similar constructs in EFI mode
and userspace.
2024-06-26 16:01:35 +02:00
Lennart Poettering 432977a0a4 iovec-util: add exported constant empty but valid (i.e. non-NULL) iovec
Also, make sure the NUL byte iovec becomes an exported constant too.

This is better than the previous situation where this was a macro
resolving to a compount expression, since the lifetime of the expression
is limited to its invoking scope. By turning this into a proper variable
the lifetime becomes unbounded, which makes it easier to use in various
scenarios, such as "if" blocks.
2024-06-14 12:42:07 +01:00
Lennart Poettering 045f7b8fe4 iovec-util: add helper for a single NUL byte iovec 2024-01-11 16:05:20 +01:00
Lennart Poettering dddc12f9eb iovec-util: add CONST_IOVEC_MAKE_STRING() 2024-01-05 11:10:22 +01:00
Lennart Poettering 4cc467b67c iovec-util: add new iovec_memdup() helper 2024-01-05 11:10:22 +01:00
Lennart Poettering bf38e4c0c1 iovec-util: add new iovec_memcmp() helper 2024-01-05 11:10:22 +01:00
Lennart Poettering 39f586873d iovec-util: add iovec_is_valid() helper 2024-01-05 11:10:22 +01:00
Lennart Poettering 33d1febbd7 iovec-util: rework IOVEC_MAKE_STRING() to work with compound initialized input
This avoids the ({}) that IOVEC_MAKE_STRING() so far used and might
cause a memory corruption if the parameter passed in is itself allocated
via a compount initialized array or so.

Also, this makes sure both IOVEC_MAKE_STRING() and IOVEC_MAKE() accept
'const' parameters without this causing a compiler warning.
2024-01-05 11:10:22 +01:00
Mike Yuan ba354c164f iovec-util: add missing assertion 2023-12-13 20:42:05 +08:00
Zbigniew Jędrzejewski-Szmek 3c9783c7f4 basic/iovec-util: drop TAKE_IOVEC
As suggested in
https://github.com/systemd/systemd/pull/29679#discussion_r1368678932.
2023-10-23 22:23:13 +02:00
Zbigniew Jędrzejewski-Szmek 7dc951ef91 basic/iovec-util: drop IOVEC_NULL
The macro isn't very useful, we can just use the direct setting to increase
readability.
2023-10-23 15:04:08 +02:00
Zbigniew Jędrzejewski-Szmek 1ca0b482b6 basic/iovec-util: always call the iovec "iovec"
We were using "i", "iov", and "iovec" in variuos places. Let's be
consistent.
2023-10-23 15:04:08 +02:00
Lennart Poettering 3a856171c2 iovec-util: add some useful helpers for dealing with iovecs that refer to dynamic memory 2023-10-20 14:38:16 +02:00
Lennart Poettering 986235a99a iovec-util: make IOVEC_INCREMENT a regular function too
Even more than with the previous commit, this is not a trivial function
and there's no reason to believe this will actually be inlined nor that
it would be beneficial.
2023-10-20 10:43:50 +02:00
Lennart Poettering 9599ea28b4 iovec-util: make IOVEC_MAKE_STRING() safer
Let's not accept arbitrary types, but only char* and const char*.
2023-10-20 10:43:50 +02:00
Lennart Poettering e2a3bb22c8 iovec-util: make IOVEC_NULL const
compound initialized structs can be placed im immutable memory if const,
hence there's benefit in making this one const too
2023-10-20 10:43:50 +02:00
Lennart Poettering c24e0dbea1 iovec-util: make IOVEC_TOTAL_SIZE() a regular function
The function isn't necessarily fast (it's O(n)), and there's no reason
to have it defined as inline function, since it's neither fast, nor
entirely trivial.
2023-10-20 10:43:50 +02:00
Lennart Poettering bd1ae17833 io-util: split out "struct iovec" related calls into their own .c/.h files
This is preparation for #28891, which adds a bunch more helpers around
"struct iovec", at which point this really deserves its own .c/.h file.

The idea is that we sooner or later can consider "struct iovec" as an
entirely generic mechanism to reference some binary blob, and is the
go-to type for this purpose whenever we need one.
2023-10-20 10:34:33 +02:00