Commit Graph

24 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 5d904a6aaa tree-wide: drop !! casts to booleans
They are not needed, because anything that is non-zero is converted
to true.

C11:
> 6.3.1.2: When any scalar value is converted to _Bool, the result is 0 if the
> value compares equal to 0; otherwise, the result is 1.

https://stackoverflow.com/questions/31551888/casting-int-to-bool-in-c-c
2018-06-13 10:52:40 +02:00
Yu Watanabe c5984fe177 string-util: rename strdash_if_empty() to empty_to_dash() 2018-05-11 01:55:46 +09:00
Lennart Poettering 5d13a15b1d tree-wide: drop spurious newlines (#8764)
Double newlines (i.e. one empty lines) are great to structure code. But
let's avoid triple newlines (i.e. two empty lines), quadruple newlines,
quintuple newlines, …, that's just spurious whitespace.

It's an easy way to drop 121 lines of code, and keeps the coding style
of our sources a bit tigther.
2018-04-19 12:13:23 +02:00
Zbigniew Jędrzejewski-Szmek 11a1589223 tree-wide: drop license boilerplate
Files which are installed as-is (any .service and other unit files, .conf
files, .policy files, etc), are left as is. My assumption is that SPDX
identifiers are not yet that well known, so it's better to retain the
extended header to avoid any doubt.

I also kept any copyright lines. We can probably remove them, but it'd nice to
obtain explicit acks from all involved authors before doing that.
2018-04-06 18:58:55 +02:00
Yu Watanabe 1cc6c93a95 tree-wide: use TAKE_PTR() and TAKE_FD() macros 2018-04-05 14:26:26 +09:00
Yu Watanabe ee5324aa04 tree-wide: voidify pager_open()
Even if pager_open() fails, in general, we should continue the operations.
All erroneous cases in pager_open() show log message in the function.
So, it is not necessary to check the returned value.
2018-03-19 21:04:02 +09:00
Yu Watanabe 5488660154 busctl: drop redundant pager_open() 2018-03-19 21:03:36 +09:00
Yu Watanabe cb05d2a514 busctl: add missing oom check 2018-03-19 21:03:36 +09:00
Yu Watanabe 9bb31a0c9f busctl: use dispatch_verb() 2018-03-19 21:03:36 +09:00
Franck Bui 0a84daa5aa Comment the fact that some tools need to termintate their bus connect first 2018-01-12 16:20:36 +01:00
Franck Bui a3c5634573 Revert "tree-wide: use _cleanup_(sd_bus_flush_close_unrefp) at various appropriate places"
This reverts commit 0b3c84eb7d.

The removal of _cleanup_() usages was done on purpose, see
cf647b69ba.

Fixes: #3543
2018-01-12 16:09:21 +01:00
Lennart Poettering 56d820b6a4 busctl: add a new --watch-bind switch
This is useful for testing, and early-boot scripting.
2018-01-05 13:55:08 +01:00
Lennart Poettering fbd0b64f44
tree-wide: make use of new STRLEN() macro everywhere (#7639)
Let's employ coccinelle to do this for us.

Follow-up for #7625.
2017-12-14 19:02:29 +01:00
Lennart Poettering e51faad3d5 busctl: let's make use of the log_error_errno() calls 2017-12-14 10:46:19 +01:00
Lennart Poettering 8d3b9edc6b busctl: modernize code a bit
I am puzzled why coccinelle is unwilling to detect these cases...
2017-12-14 10:46:19 +01:00
Lennart Poettering 0d53667334 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 4b61c87511.
2017-12-14 10:42:25 +01:00
Marcus Folkesson e53fa8051d busctl: list all short options in help text
Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com>
2017-12-03 18:40:13 +01:00
Zbigniew Jędrzejewski-Szmek 224b0e7ad0 Add set/hashmap helpers for non-trivial freeing and use where straighforward
A macro is needed because otherwise we couldn't ensure type safety.
Some simple tests are included.
No functional change intended.
2017-11-28 21:30:30 +01:00
Zbigniew Jędrzejewski-Szmek 53e1b68390 Add SPDX license identifiers to source files under the LGPL
This follows what the kernel is doing, c.f.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
2017-11-19 19:08:15 +01:00
Lennart Poettering 9efebb65d4
busctl: fix minor memory leak in busctl (#7331)
Fixes: #7330
2017-11-14 17:59:50 +01:00
Lennart Poettering 0b3c84eb7d tree-wide: use _cleanup_(sd_bus_flush_close_unrefp) at various appropriate places
Let's shorten the code a bit.
2017-11-10 21:15:44 +01:00
Tom Gundersen d27d4637c8 busctl: monitor - ignore the final NameLost message
Commit f5938e8ff3 started dropping all
messages before we become a monitor, but the last one was getting
through.

This drops also the last NameLost message, which indicatse the switch
from a regular peer to a monitor.
2017-05-25 17:37:50 +02:00
Tom Gundersen f5938e8ff3 busctl: monitor - only start printing messages once we have become a monitor (#5931)
A connection becomes a monitor the moment it loses its unique name, so any
messages received before that should not be dumped to the console.

Currently, we print NameAcquired and NameLost for the unique name of the
peer that becomes the monitor, simply discard all messages until we
receive our NameLost signal.
2017-05-11 15:56:55 +02:00
Zbigniew Jędrzejewski-Szmek 3bcaf458f6 Move busctl sources to src/busctl
busctl is not part of libsystemd, and should not be stored under libsystemd.
In particular this is confusing because busctl is linked with libshared, but
stuff in libsystemd is not supposed to depend on libshared.
2017-04-04 20:36:09 -04:00
Renamed from src/libsystemd/sd-bus/busctl.c (Browse further)