summaryrefslogtreecommitdiff
path: root/src/busctl
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-12-11 19:50:30 +0100
committerLennart Poettering <lennart@poettering.net>2017-12-14 10:42:25 +0100
commit0d5366733428b657e1b5b7700b461e878e00b578 (patch)
treee2bcdb9f85e01c79221a9f4797e11fae60166c48 /src/busctl
parent966c04cf012f48686cf5359067a7b26c080f44ea (diff)
downloadsystemd-0d5366733428b657e1b5b7700b461e878e00b578.tar.gz
tree-wide: use __fsetlocking() instead of fxyz_unlocked()
Let's replace usage of fputc_unlocked() and friends by __fsetlocking(f, FSETLOCKING_BYCALLER). This turns off locking for the entire FILE*, instead of doing individual per-call decision whether to use normal calls or _unlocked() calls. This has various benefits: 1. It's easier to read and easier not to forget 2. It's more comprehensive, as fprintf() and friends are covered too (as these functions have no _unlocked() counterpart) 3. Philosophically, it's a bit more correct, because it's more a property of the file handle really whether we ever pass it on to another thread, not of the operations we then apply to it. This patch reworks all pieces of codes that so far used fxyz_unlocked() calls to use __fsetlocking() instead. It also reworks all places that use open_memstream(), i.e. use stdio FILE* for string manipulations. Note that this in some way a revert of 4b61c8751135c58be043d86b9fef4c8ec7aadf18.
Diffstat (limited to 'src/busctl')
-rw-r--r--src/busctl/busctl.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c
index 953816c46d..81140f9d36 100644
--- a/src/busctl/busctl.c
+++ b/src/busctl/busctl.c
@@ -19,6 +19,7 @@
***/
#include <getopt.h>
+#include <stdio_ext.h>
#include "sd-bus.h"
@@ -949,6 +950,8 @@ static int introspect(sd_bus *bus, char **argv) {
if (!mf)
return log_oom();
+ (void) __fsetlocking(mf, FSETLOCKING_BYCALLER);
+
r = format_cmdline(reply, mf, false);
if (r < 0)
return bus_log_parse_error(r);