]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/coredump/coredump.c
io-util: add new IOVEC_INIT/IOVEC_MAKE macros
authorLennart Poettering <lennart@poettering.net>
Thu, 21 Sep 2017 11:52:34 +0000 (13:52 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Sep 2017 13:28:04 +0000 (15:28 +0200)
commite6a7ec4b8e33f38f578e12af9ae9ca7ddde80aac
tree3c621376866d1265c4456702e02d5351098b9567
parent646cc98dc81c4d0edbc1b57e7bca0f474b47e270
io-util: add new IOVEC_INIT/IOVEC_MAKE macros

This adds IOVEC_INIT() and IOVEC_MAKE() for initializing iovec structures
from a pointer and a size. On top of these IOVEC_INIT_STRING() and
IOVEC_MAKE_STRING() are added which take a string and automatically
determine the size of the string using strlen().

This patch removes the old IOVEC_SET_STRING() macro, given that
IOVEC_MAKE_STRING() is now useful for similar purposes. Note that the
old IOVEC_SET_STRING() invocations were two characters shorter than the
new ones using IOVEC_MAKE_STRING(), but I think the new syntax is more
readable and more generic as it simply resolves to a C99 literal
structure initialization. Moreover, we can use very similar syntax now
for initializing strings and pointer+size iovec entries. We canalso use
the new macros to initialize function parameters on-the-fly or array
definitions. And given that we shouldn't have so many ways to do the
same stuff, let's just settle on the new macros.

(This also converts some code to use _cleanup_ where dynamically
allocated strings were using IOVEC_SET_STRING() before, to modernize
things a bit)
16 files changed:
src/basic/io-util.h
src/basic/journal-importer.c
src/basic/log.c
src/core/dynamic-user.c
src/core/execute.c
src/core/show-status.c
src/coredump/coredump.c
src/journal/journal-send.c
src/journal/journald-audit.c
src/journal/journald-console.c
src/journal/journald-kmsg.c
src/journal/journald-native.c
src/journal/journald-server.c
src/journal/journald-stream.c
src/journal/journald-syslog.c
src/test/test-fileio.c