tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy

GLIB has recently started to officially support the gcc cleanup
attribute in its public API, hence let's do the same for our APIs.

With this patch we'll define an xyz_unrefp() call for each public
xyz_unref() call, to make it easy to use inside a
__attribute__((cleanup())) expression. Then, all code is ported over to
make use of this.

The new calls are also documented in the man pages, with examples how to
use them (well, I only added docs where the _unref() call itself already
had docs, and the examples, only cover sd_bus_unrefp() and
sd_event_unrefp()).

This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we
tend to call our destructors these days.

Note that this defines no public macro that wraps gcc's attribute and
makes it easier to use. While I think it's our duty in the library to
make our stuff easy to use, I figure it's not our duty to make gcc's own
features easy to use on its own. Most likely, client code which wants to
make use of this should define its own:

       #define _cleanup_(function) __attribute__((cleanup(function)))

Or similar, to make the gcc feature easier to use.

Making this logic public has the benefit that we can remove three header
files whose only purpose was to define these functions internally.

See #2008.
This commit is contained in:
Lennart Poettering 2015-11-27 19:13:45 +01:00
parent f5edf80e29
commit 4afd3348c7
189 changed files with 934 additions and 897 deletions

View File

@ -285,6 +285,7 @@ MANPAGES_ALIAS += \
man/sd_bus_creds_has_permitted_cap.3 \
man/sd_bus_creds_ref.3 \
man/sd_bus_creds_unref.3 \
man/sd_bus_creds_unrefp.3 \
man/sd_bus_default_system.3 \
man/sd_bus_default_user.3 \
man/sd_bus_error_copy.3 \
@ -320,6 +321,7 @@ MANPAGES_ALIAS += \
man/sd_bus_ref.3 \
man/sd_bus_release_name.3 \
man/sd_bus_unref.3 \
man/sd_bus_unrefp.3 \
man/sd_event.3 \
man/sd_event_add_exit.3 \
man/sd_event_add_post.3 \
@ -354,8 +356,10 @@ MANPAGES_ALIAS += \
man/sd_event_source_set_io_fd.3 \
man/sd_event_source_set_time.3 \
man/sd_event_source_set_time_accuracy.3 \
man/sd_event_source_unrefp.3 \
man/sd_event_time_handler_t.3 \
man/sd_event_unref.3 \
man/sd_event_unrefp.3 \
man/sd_id128_equal.3 \
man/sd_id128_from_string.3 \
man/sd_id128_get_boot.3 \
@ -608,6 +612,7 @@ man/sd_bus_creds_has_inheritable_cap.3: man/sd_bus_creds_get_pid.3
man/sd_bus_creds_has_permitted_cap.3: man/sd_bus_creds_get_pid.3
man/sd_bus_creds_ref.3: man/sd_bus_creds_new_from_pid.3
man/sd_bus_creds_unref.3: man/sd_bus_creds_new_from_pid.3
man/sd_bus_creds_unrefp.3: man/sd_bus_creds_new_from_pid.3
man/sd_bus_default_system.3: man/sd_bus_default.3
man/sd_bus_default_user.3: man/sd_bus_default.3
man/sd_bus_error_copy.3: man/sd_bus_error.3
@ -643,6 +648,7 @@ man/sd_bus_path_encode_many.3: man/sd_bus_path_encode.3
man/sd_bus_ref.3: man/sd_bus_new.3
man/sd_bus_release_name.3: man/sd_bus_request_name.3
man/sd_bus_unref.3: man/sd_bus_new.3
man/sd_bus_unrefp.3: man/sd_bus_new.3
man/sd_event.3: man/sd_event_new.3
man/sd_event_add_exit.3: man/sd_event_add_defer.3
man/sd_event_add_post.3: man/sd_event_add_defer.3
@ -677,8 +683,10 @@ man/sd_event_source_set_io_events.3: man/sd_event_add_io.3
man/sd_event_source_set_io_fd.3: man/sd_event_add_io.3
man/sd_event_source_set_time.3: man/sd_event_add_time.3
man/sd_event_source_set_time_accuracy.3: man/sd_event_add_time.3
man/sd_event_source_unrefp.3: man/sd_event_source_unref.3
man/sd_event_time_handler_t.3: man/sd_event_add_time.3
man/sd_event_unref.3: man/sd_event_new.3
man/sd_event_unrefp.3: man/sd_event_new.3
man/sd_id128_equal.3: man/sd-id128.3
man/sd_id128_from_string.3: man/sd_id128_to_string.3
man/sd_id128_get_boot.3: man/sd_id128_get_machine.3
@ -1157,6 +1165,9 @@ man/sd_bus_creds_ref.html: man/sd_bus_creds_new_from_pid.html
man/sd_bus_creds_unref.html: man/sd_bus_creds_new_from_pid.html
$(html-alias)
man/sd_bus_creds_unrefp.html: man/sd_bus_creds_new_from_pid.html
$(html-alias)
man/sd_bus_default_system.html: man/sd_bus_default.html
$(html-alias)
@ -1262,6 +1273,9 @@ man/sd_bus_release_name.html: man/sd_bus_request_name.html
man/sd_bus_unref.html: man/sd_bus_new.html
$(html-alias)
man/sd_bus_unrefp.html: man/sd_bus_new.html
$(html-alias)
man/sd_event.html: man/sd_event_new.html
$(html-alias)
@ -1364,12 +1378,18 @@ man/sd_event_source_set_time.html: man/sd_event_add_time.html
man/sd_event_source_set_time_accuracy.html: man/sd_event_add_time.html
$(html-alias)
man/sd_event_source_unrefp.html: man/sd_event_source_unref.html
$(html-alias)
man/sd_event_time_handler_t.html: man/sd_event_add_time.html
$(html-alias)
man/sd_event_unref.html: man/sd_event_new.html
$(html-alias)
man/sd_event_unrefp.html: man/sd_event_new.html
$(html-alias)
man/sd_id128_equal.html: man/sd-id128.html
$(html-alias)
@ -2138,6 +2158,7 @@ MANPAGES_ALIAS += \
man/sd_login_monitor_get_fd.3 \
man/sd_login_monitor_get_timeout.3 \
man/sd_login_monitor_unref.3 \
man/sd_login_monitor_unrefp.3 \
man/sd_peer_get_cgroup.3 \
man/sd_peer_get_machine_name.3 \
man/sd_peer_get_owner_uid.3 \
@ -2184,6 +2205,7 @@ man/sd_login_monitor_get_events.3: man/sd_login_monitor_new.3
man/sd_login_monitor_get_fd.3: man/sd_login_monitor_new.3
man/sd_login_monitor_get_timeout.3: man/sd_login_monitor_new.3
man/sd_login_monitor_unref.3: man/sd_login_monitor_new.3
man/sd_login_monitor_unrefp.3: man/sd_login_monitor_new.3
man/sd_peer_get_cgroup.3: man/sd_pid_get_session.3
man/sd_peer_get_machine_name.3: man/sd_pid_get_session.3
man/sd_peer_get_owner_uid.3: man/sd_pid_get_session.3
@ -2248,6 +2270,9 @@ man/sd_login_monitor_get_timeout.html: man/sd_login_monitor_new.html
man/sd_login_monitor_unref.html: man/sd_login_monitor_new.html
$(html-alias)
man/sd_login_monitor_unrefp.html: man/sd_login_monitor_new.html
$(html-alias)
man/sd_peer_get_cgroup.html: man/sd_pid_get_session.html
$(html-alias)

View File

@ -3041,7 +3041,6 @@ libsystemd_internal_la_SOURCES = \
src/libsystemd/sd-bus/bus-dump.h \
src/libsystemd/sd-utf8/sd-utf8.c \
src/libsystemd/sd-event/sd-event.c \
src/libsystemd/sd-event/event-util.h \
src/libsystemd/sd-netlink/sd-netlink.c \
src/libsystemd/sd-netlink/netlink-internal.h \
src/libsystemd/sd-netlink/netlink-message.c \
@ -3070,8 +3069,7 @@ libsystemd_internal_la_SOURCES = \
src/libsystemd/sd-device/sd-device.c \
src/libsystemd/sd-device/device-private.c \
src/libsystemd/sd-device/device-private.h \
src/libsystemd/sd-resolve/sd-resolve.c \
src/libsystemd/sd-resolve/resolve-util.h
src/libsystemd/sd-resolve/sd-resolve.c
libsystemd_internal_la_LIBADD = \
libbasic.la \
@ -3353,7 +3351,6 @@ libsystemd_network_la_SOURCES = \
src/libsystemd-network/lldp-port.c \
src/libsystemd-network/lldp-internal.h \
src/libsystemd-network/lldp-internal.c \
src/libsystemd-network/lldp-util.h \
src/libsystemd-network/sd-lldp.c
libsystemd_network_la_LIBADD = \

View File

@ -48,6 +48,7 @@
<refname>sd_bus_creds_get_augmented_mask</refname>
<refname>sd_bus_creds_ref</refname>
<refname>sd_bus_creds_unref</refname>
<refname>sd_bus_creds_unrefp</refname>
<refpurpose>Retrieve credentials object for the specified PID</refpurpose>
</refnamediv>
@ -82,6 +83,11 @@
<funcdef>sd_bus_creds *<function>sd_bus_creds_unref</function></funcdef>
<paramdef>sd_bus_creds *<parameter>c</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>void <function>sd_bus_creds_unrefp</function></funcdef>
<paramdef>sd_bus_creds **<parameter>c</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
@ -235,6 +241,21 @@
<para><function>sd_bus_creds_unref()</function> destroys a reference
to <parameter>c</parameter>.</para>
<para><function>sd_bus_creds_unrefp()</function> is similar to
<function>sd_bus_creds_unref()</function> but takes a pointer to a
pointer to an <type>sd_bus_creds</type> object. This call is useful in
conjunction with GCC's and LLVM's <ulink
url="https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html">Clean-up
Variable Attribute</ulink>. Note that this function is defined as
inline function.</para>
<para><function>sd_bus_creds_ref()</function>,
<function>sd_bus_creds_unref()</function> and
<function>sd_bus_creds_unrefp()</function> execute no operation if
the passed in bus credentials object is
<constant>NULL</constant>.</para>
</refsect1>
<refsect1>

View File

@ -46,6 +46,7 @@
<refname>sd_bus_new</refname>
<refname>sd_bus_ref</refname>
<refname>sd_bus_unref</refname>
<refname>sd_bus_unrefp</refname>
<refpurpose>Create a new bus object and create or destroy references to it</refpurpose>
</refnamediv>
@ -68,6 +69,11 @@
<funcdef>sd_bus *<function>sd_bus_unref</function></funcdef>
<paramdef>sd_bus *<parameter>bus</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>void <function>sd_bus_unrefp</function></funcdef>
<paramdef>sd_bus **<parameter>bus</parameter></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
@ -93,14 +99,40 @@
only allocate a bus object but also start the connection to a
well-known bus in a single function invocation.</para>
<para><function>sd_bus_ref()</function> creates a new reference to
<parameter>bus</parameter>.</para>
<para><function>sd_bus_ref()</function> increases the reference
counter of <parameter>bus</parameter> by one.</para>
<para><function>sd_bus_unref()</function> destroys a reference to
<parameter>bus</parameter>. Once the reference count has dropped
to zero, <parameter>bus</parameter> cannot be used anymore, so
further calls to <function>sd_bus_ref()</function> or
<para><function>sd_bus_unref()</function> decreases the reference
counter of <parameter>bus</parameter> by one. Once the reference
count has dropped to zero, <parameter>bus</parameter> is destroyed
and cannot be used anymore, so further calls to
<function>sd_bus_ref()</function> or
<function>sd_bus_unref()</function> are illegal.</para>
<para><function>sd_bus_unrefp()</function> is similar to
<function>sd_bus_unref()</function> but takes a pointer to a
pointer to an <type>sd_bus</type> object. This call is useful in
conjunction with GCC's and LLVM's <ulink
url="https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html">Clean-up
Variable Attribute</ulink>. Note that this function is defined as
inline function. Use a declaration like the following, in order to
allocate a bus object that is freed automatically as the code
block is left:</para>
<programlisting>{
__attribute__((cleanup(sd_bus_unrefp)) sd_bus *bus = NULL;
int r;
r = sd_bus_default(&amp;bus);
if (r &lt; 0)
fprintf(stderr, "Failed to allocate bus: %s\n", strerror(-r));
}</programlisting>
<para><function>sd_bus_ref()</function>,
<function>sd_bus_unref()</function> and
<function>sd_bus_unrefp()</function> execute no operation if the
passed in bus object is <constant>NULL</constant>.</para>
</refsect1>
<refsect1>
@ -110,10 +142,10 @@
positive integer. On failure, it returns a negative errno-style
error code.</para>
<para><function>sd_bus_ref</function> always returns the argument.
<para><function>sd_bus_ref()</function> always returns the argument.
</para>
<para><function>sd_bus_unref</function> always returns
<para><function>sd_bus_unref()</function> always returns
<constant>NULL</constant>.</para>
</refsect1>

View File

@ -47,6 +47,7 @@
<refname>sd_event_default</refname>
<refname>sd_event_ref</refname>
<refname>sd_event_unref</refname>
<refname>sd_event_unrefp</refname>
<refname>sd_event_get_tid</refname>
<refname>sd_event</refname>
@ -79,6 +80,11 @@
<paramdef>sd_event *<parameter>event</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>void <function>sd_event_unrefp</function></funcdef>
<paramdef>sd_event **<parameter>event</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_event_get_tid</function></funcdef>
<paramdef>sd_event *<parameter>event</parameter></paramdef>
@ -139,8 +145,29 @@
all remaining event sources of the event loop also need to be
freed as each keeps a reference to it.</para>
<para>Both <function>sd_event_ref()</function> and
<function>sd_event_unref()</function> execute no operation if the
<para><function>sd_event_unrefp()</function> is similar to
<function>sd_event_unref()</function> but takes a pointer to a
pointer to an <type>sd_event</type> object. This call is useful in
conjunction with GCC's and LLVM's <ulink
url="https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html">Clean-up
Variable Attribute</ulink>. Note that this function is defined as
inline function. Use a declaration like the following,
in order to allocate an event loop object that is freed
automatically as the code block is left:</para>
<programlisting>{
__attribute__((cleanup(sd_event_unrefp)) sd_event *event = NULL;
int r;
r = sd_event_default(&amp;event);
if (r &lt; 0)
fprintf(stderr, "Failed to allocate event loop: %s\n", strerror(-r));
}</programlisting>
<para><function>sd_event_ref()</function>,
<function>sd_event_unref()</function> and
<function>sd_event_unrefp()</function> execute no operation if the
passed in event loop object is <constant>NULL</constant>.</para>
<para><function>sd_event_get_tid()</function> retrieves the thread

View File

@ -44,6 +44,7 @@
<refnamediv>
<refname>sd_event_source_unref</refname>
<refname>sd_event_source_unrefp</refname>
<refname>sd_event_source_ref</refname>
<refpurpose>Increase or decrease event source reference counters</refpurpose>
@ -58,6 +59,11 @@
<paramdef>sd_event_source *<parameter>source</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>void <function>sd_event_source_unrefp</function></funcdef>
<paramdef>sd_event_source **<parameter>source</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>sd_event_source* <function>sd_event_source_ref</function></funcdef>
<paramdef>sd_event_source *<parameter>source</parameter></paramdef>
@ -80,12 +86,23 @@
the reference counter reaches zero it is removed from its event loop
object and destroyed.</para>
<para><function>sd_event_source_unrefp()</function> is similar to
<function>sd_event_source_unref()</function> but takes a pointer to a
pointer to an <type>sd_event_source</type> object. This call is useful in
conjunction with GCC's and LLVM's <ulink
url="https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html">Clean-up
Variable Attribute</ulink>. Note that this function is defined as
inline function.</para>
<para><function>sd_event_source_ref()</function> may be used
to increase by one the reference counter of the event source object
specified as <parameter>source</parameter>.</para>
<para>Both functions execute no operation if the passed event
source object is <constant>NULL</constant>.</para>
<para><function>sd_event_source_unref()</function>,
<function>sd_bus_creds_unrefp()</function> and
<function>sd_bus_creds_ref()</function> execute no operation if
the passed event source object is
<constant>NULL</constant>.</para>
<para>Note that event source objects stay alive and may be
dispatched as long as they have a reference counter greater than

View File

@ -45,6 +45,7 @@
<refnamediv>
<refname>sd_login_monitor_new</refname>
<refname>sd_login_monitor_unref</refname>
<refname>sd_login_monitor_unrefp</refname>
<refname>sd_login_monitor_flush</refname>
<refname>sd_login_monitor_get_fd</refname>
<refname>sd_login_monitor_get_events</refname>
@ -68,6 +69,11 @@
<paramdef>sd_login_monitor *<parameter>m</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>void <function>sd_login_monitor_unrefp</function></funcdef>
<paramdef>sd_login_monitor **<parameter>m</parameter></paramdef>
</funcprototype>
<funcprototype>
<funcdef>int <function>sd_login_monitor_flush</function></funcdef>
<paramdef>sd_login_monitor *<parameter>m</parameter></paramdef>
@ -121,6 +127,26 @@
descriptor returned by
<function>sd_login_monitor_get_fd()</function>.</para>
<para><function>sd_login_monitor_unrefp()</function> is similar to
<function>sd_login_monitor_unref()</function> but takes a pointer
to a pointer to an <type>sd_login_monitor</type> object. This call
is useful in conjunction with GCC's and LLVM's <ulink
url="https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html">Clean-up
Variable Attribute</ulink>. Note that this function is defined as
inline function. Use a declaration like the following, in order to
allocate a login monitor object that is freed automatically as the
code block is left:</para>
<programlisting>{
__attribute__((cleanup(sd_login_monitor_unrefp)) sd_login_monitor *m = NULL;
int r;
r = sd_login_monitor_default(&amp;m);
if (r &lt; 0)
fprintf(stderr, "Failed to allocate login monitor object: %s\n", strerror(-r));
}</programlisting>
<para><function>sd_login_monitor_flush()</function> may be used to
reset the wakeup state of the monitor object. Whenever an event
causes the monitor to wake up the event loop via the file
@ -128,6 +154,11 @@
state. If this call is not invoked, the file descriptor will
immediately wake up the event loop again.</para>
<para><function>sd_login_monitor_unref()</function> and
<function>sd_login_monitor_unrefp()</function> execute no
operation if the passed in monitor object is
<constant>NULL</constant>.</para>
<para><function>sd_login_monitor_get_fd()</function> may be used
to retrieve the file descriptor of the monitor object that may be
integrated in an application defined event loop, based around

View File

@ -164,7 +164,7 @@ static int verify_documentation(Unit *u, bool check_man) {
}
static int verify_unit(Unit *u, bool check_man) {
_cleanup_bus_error_free_ sd_bus_error err = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error err = SD_BUS_ERROR_NULL;
int r, k;
assert(u);
@ -193,7 +193,7 @@ static int verify_unit(Unit *u, bool check_man) {
}
int verify_units(char **filenames, ManagerRunningAs running_as, bool check_man) {
_cleanup_bus_error_free_ sd_bus_error err = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error err = SD_BUS_ERROR_NULL;
Manager *m = NULL;
FILE *serial = NULL;
FDSet *fdset = NULL;

View File

@ -134,7 +134,7 @@ static void pager_open_if_enabled(void) {
}
static int bus_get_uint64_property(sd_bus *bus, const char *path, const char *interface, const char *property, uint64_t *val) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
assert(bus);
@ -161,7 +161,7 @@ static int bus_get_uint64_property(sd_bus *bus, const char *path, const char *in
}
static int bus_get_unit_property_strv(sd_bus *bus, const char *path, const char *property, char ***strv) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
assert(bus);
@ -339,8 +339,8 @@ static void free_host_info(struct host_info *hi) {
DEFINE_TRIVIAL_CLEANUP_FUNC(struct host_info*, free_host_info);
static int acquire_time_data(sd_bus *bus, struct unit_times **out) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r, c = 0;
struct boot_times *boot_times = NULL;
struct unit_times *unit_times = NULL;
@ -455,7 +455,7 @@ static int acquire_host_info(sd_bus *bus, struct host_info **hi) {
{}
};
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(free_host_infop) struct host_info *host;
int r;
@ -899,8 +899,8 @@ static int list_dependencies(sd_bus *bus, const char *name) {
int r;
const char *id;
_cleanup_free_ char *path = NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
struct boot_times *boot;
assert(bus);
@ -1096,7 +1096,7 @@ static int expand_patterns(sd_bus *bus, char **patterns, char ***ret) {
int r;
STRV_FOREACH(pattern, patterns) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_free_ char *unit = NULL, *unit_id = NULL;
if (strv_extend(&expanded_patterns, *pattern) < 0)
@ -1133,8 +1133,8 @@ static int expand_patterns(sd_bus *bus, char **patterns, char ***ret) {
}
static int dot(sd_bus *bus, char* patterns[]) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_strv_free_ char **expanded_patterns = NULL;
_cleanup_strv_free_ char **expanded_from_patterns = NULL;
_cleanup_strv_free_ char **expanded_to_patterns = NULL;
@ -1198,8 +1198,8 @@ static int dot(sd_bus *bus, char* patterns[]) {
}
static int dump(sd_bus *bus, char **args) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const char *text = NULL;
int r;
@ -1231,7 +1231,7 @@ static int dump(sd_bus *bus, char **args) {
}
static int set_log_level(sd_bus *bus, char **args) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
assert(bus);
@ -1258,7 +1258,7 @@ static int set_log_level(sd_bus *bus, char **args) {
}
static int set_log_target(sd_bus *bus, char **args) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
assert(bus);
@ -1456,7 +1456,7 @@ int main(int argc, char *argv[]) {
arg_user ? MANAGER_USER : MANAGER_SYSTEM,
arg_man);
else {
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
r = bus_connect_transport_systemd(arg_transport, arg_host, arg_user, &bus);
if (r < 0) {

View File

@ -40,7 +40,7 @@
#include "util.h"
static int get_creds_by_name(sd_bus *bus, const char *name, uint64_t mask, sd_bus_creds **_creds, sd_bus_error *error) {
_cleanup_bus_creds_unref_ sd_bus_creds *c = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *c = NULL;
int r;
assert(bus);
@ -75,7 +75,7 @@ static int get_creds_by_message(sd_bus *bus, sd_bus_message *m, uint64_t mask, s
}
static int driver_activation(sd_bus_message *reply, void *userdata, sd_bus_error *error) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
ProxyActivation *activation = userdata;
/*
@ -239,9 +239,9 @@ int bus_proxy_process_driver(Proxy *p, sd_bus *a, sd_bus *b, sd_bus_message *m,
return synthetic_reply_method_return(m, NULL);
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "GetConnectionCredentials")) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
if (!sd_bus_message_has_signature(m, "s"))
return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
@ -305,9 +305,9 @@ int bus_proxy_process_driver(Proxy *p, sd_bus *a, sd_bus *b, sd_bus_message *m,
return synthetic_driver_send(m->bus, reply);
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "GetConnectionSELinuxSecurityContext")) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
if (!sd_bus_message_has_signature(m, "s"))
return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
@ -330,8 +330,8 @@ int bus_proxy_process_driver(Proxy *p, sd_bus *a, sd_bus *b, sd_bus_message *m,
return synthetic_driver_send(m->bus, reply);
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "GetConnectionUnixProcessID")) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
if (!sd_bus_message_has_signature(m, "s"))
return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
@ -346,8 +346,8 @@ int bus_proxy_process_driver(Proxy *p, sd_bus *a, sd_bus *b, sd_bus_message *m,
return synthetic_reply_method_return(m, "u", (uint32_t) creds->pid);
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "GetConnectionUnixUser")) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
if (!sd_bus_message_has_signature(m, "s"))
return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
@ -376,8 +376,8 @@ int bus_proxy_process_driver(Proxy *p, sd_bus *a, sd_bus *b, sd_bus_message *m,
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "GetNameOwner")) {
const char *name;
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
if (!sd_bus_message_has_signature(m, "s"))
return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
@ -439,7 +439,7 @@ int bus_proxy_process_driver(Proxy *p, sd_bus *a, sd_bus *b, sd_bus_message *m,
};
struct kdbus_info *name_list, *name;
_cleanup_strv_free_ char **owners = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
char *arg0;
int err = 0;
@ -610,7 +610,7 @@ int bus_proxy_process_driver(Proxy *p, sd_bus *a, sd_bus *b, sd_bus_message *m,
return synthetic_reply_method_return(m, "u", BUS_NAME_PRIMARY_OWNER);
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "StartServiceByName")) {
_cleanup_bus_message_unref_ sd_bus_message *msg = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *msg = NULL;
ProxyActivation *activation;
const char *name;
uint64_t cookie;
@ -674,7 +674,7 @@ int bus_proxy_process_driver(Proxy *p, sd_bus *a, sd_bus *b, sd_bus_message *m,
return 1;
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "UpdateActivationEnvironment")) {
_cleanup_bus_message_unref_ sd_bus_message *msg = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *msg = NULL;
_cleanup_strv_free_ char **args = NULL;
if (!sd_bus_message_has_signature(m, "a{ss}"))
@ -738,7 +738,7 @@ int bus_proxy_process_driver(Proxy *p, sd_bus *a, sd_bus *b, sd_bus_message *m,
return synthetic_reply_method_return(m, NULL);
} else {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
r = sd_bus_error_setf(&error, SD_BUS_ERROR_UNKNOWN_METHOD, "Unknown method '%s'.", m->member);

View File

@ -49,7 +49,7 @@
#include "util.h"
static int proxy_create_destination(Proxy *p, const char *destination, const char *local_sec, bool negotiate_fds) {
_cleanup_bus_flush_close_unref_ sd_bus *b = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *b = NULL;
int r;
r = sd_bus_new(&b);
@ -491,7 +491,7 @@ static int process_policy_unlocked(sd_bus *from, sd_bus *to, sd_bus_message *m,
(void) sd_bus_creds_get_egid(&m->creds, &sender_gid);
if (sender_uid == UID_INVALID || sender_gid == GID_INVALID) {
_cleanup_bus_creds_unref_ sd_bus_creds *sender_creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *sender_creds = NULL;
/* If the message came from another legacy
* client, then the message creds will be
@ -522,7 +522,7 @@ static int process_policy_unlocked(sd_bus *from, sd_bus *to, sd_bus_message *m,
}
if (to->is_kernel) {
_cleanup_bus_creds_unref_ sd_bus_creds *destination_creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *destination_creds = NULL;
uid_t destination_uid = UID_INVALID;
gid_t destination_gid = GID_INVALID;
const char *destination_unique = NULL;
@ -609,7 +609,7 @@ static int process_policy(sd_bus *from, sd_bus *to, sd_bus_message *m, SharedPol
}
static int process_hello(Proxy *p, sd_bus_message *m) {
_cleanup_bus_message_unref_ sd_bus_message *n = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *n = NULL;
bool is_hello;
int r;
@ -723,7 +723,7 @@ static int patch_sender(sd_bus *a, sd_bus_message *m) {
}
static int proxy_process_destination_to_local(Proxy *p) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
bool matched, matched_synthetic;
int r;
@ -832,7 +832,7 @@ static int proxy_process_destination_to_local(Proxy *p) {
}
static int proxy_process_local_to_destination(Proxy *p) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
assert(p);

View File

@ -146,7 +146,7 @@ static int parse_argv(int argc, char *argv[]) {
}
static int rename_service(sd_bus *a, sd_bus *b) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
_cleanup_free_ char *p = NULL, *name = NULL;
const char *comm;
char **cmdline;

View File

@ -50,7 +50,7 @@ int synthetic_driver_send(sd_bus *b, sd_bus_message *m) {
}
int synthetic_reply_method_error(sd_bus_message *call, const sd_bus_error *e) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
assert(call);
@ -66,7 +66,7 @@ int synthetic_reply_method_error(sd_bus_message *call, const sd_bus_error *e) {
}
int synthetic_reply_method_errorf(sd_bus_message *call, const char *name, const char *format, ...) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
va_list ap;
va_start(ap, format);
@ -77,7 +77,7 @@ int synthetic_reply_method_errorf(sd_bus_message *call, const char *name, const
}
int synthetic_reply_method_errno(sd_bus_message *call, int error, const sd_bus_error *p) {
_cleanup_bus_error_free_ sd_bus_error berror = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error berror = SD_BUS_ERROR_NULL;
assert(call);
@ -93,7 +93,7 @@ int synthetic_reply_method_errno(sd_bus_message *call, int error, const sd_bus_e
}
int synthetic_reply_method_errnof(sd_bus_message *call, int error, const char *format, ...) {
_cleanup_bus_error_free_ sd_bus_error berror = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error berror = SD_BUS_ERROR_NULL;
va_list ap;
assert(call);
@ -109,7 +109,7 @@ int synthetic_reply_method_errnof(sd_bus_message *call, int error, const char *f
}
int synthetic_reply_method_return(sd_bus_message *call, const char *types, ...) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
assert(call);
@ -135,7 +135,7 @@ int synthetic_reply_method_return(sd_bus_message *call, const char *types, ...)
}
int synthetic_reply_method_return_strv(sd_bus_message *call, char **l) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
assert(call);
@ -155,7 +155,7 @@ int synthetic_reply_method_return_strv(sd_bus_message *call, char **l) {
}
int synthesize_name_acquired(Proxy *p, sd_bus *a, sd_bus *b, sd_bus_message *m) {
_cleanup_bus_message_unref_ sd_bus_message *n = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *n = NULL;
const char *name, *old_owner, *new_owner;
int r;

View File

@ -123,8 +123,8 @@ static int parse_argv(int argc, char *argv[]) {
}
static int get_cgroup_root(char **ret) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_free_ char *unit = NULL, *path = NULL;
const char *m;
int r;

View File

@ -27,7 +27,7 @@
#include "log.h"
int main(int argc, char *argv[]) {
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r;
if (argc != 2) {

View File

@ -841,8 +841,8 @@ static const char* counting_what(void) {
}
static int get_cgroup_root(char **ret) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_free_ char *unit = NULL, *path = NULL;
const char *m;
int r;

View File

@ -702,7 +702,7 @@ static int automount_start_expire(Automount *a) {
}
static void automount_enter_runnning(Automount *a) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
struct stat st;
int r;
@ -897,7 +897,7 @@ static bool automount_check_gc(Unit *u) {
}
static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, void *userdata) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
union autofs_v5_packet_union packet;
Automount *a = AUTOMOUNT(userdata);
struct stat st;

View File

@ -557,7 +557,7 @@ fail:
}
static void busname_enter_running(BusName *n) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
bool pending = false;
Unit *other;
Iterator i;

View File

@ -93,7 +93,7 @@ const sd_bus_vtable bus_job_vtable[] = {
};
static int send_new_signal(sd_bus *bus, void *userdata) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *p = NULL;
Job *j = userdata;
int r;
@ -153,7 +153,7 @@ void bus_job_send_change_signal(Job *j) {
}
static int send_removed_signal(sd_bus *bus, void *userdata) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *p = NULL;
Job *j = userdata;
int r;

View File

@ -384,7 +384,7 @@ static int method_get_unit(sd_bus_message *message, void *userdata, sd_bus_error
return r;
if (isempty(name)) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
pid_t pid;
r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_PID, &creds);
@ -436,7 +436,7 @@ static int method_get_unit_by_pid(sd_bus_message *message, void *userdata, sd_bu
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid PID " PID_FMT, pid);
if (pid == 0) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_PID, &creds);
if (r < 0)
@ -479,7 +479,7 @@ static int method_load_unit(sd_bus_message *message, void *userdata, sd_bus_erro
return r;
if (isempty(name)) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
pid_t pid;
r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_PID, &creds);
@ -865,7 +865,7 @@ static int method_reset_failed(sd_bus_message *message, void *userdata, sd_bus_e
}
static int list_units_filtered(sd_bus_message *message, void *userdata, sd_bus_error *error, char **states) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
const char *k;
Iterator i;
@ -953,7 +953,7 @@ static int method_list_units_filtered(sd_bus_message *message, void *userdata, s
}
static int method_list_jobs(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Iterator i;
Job *j;
@ -1441,7 +1441,7 @@ static int method_set_exit_code(sd_bus_message *message, void *userdata, sd_bus_
}
static int method_list_unit_files(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
UnitFileList *item;
Hashmap *h;
@ -1547,7 +1547,7 @@ static int method_get_default_target(sd_bus_message *message, void *userdata, sd
}
static int send_unit_files_changed(sd_bus *bus, void *userdata) {
_cleanup_bus_message_unref_ sd_bus_message *message = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL;
int r;
assert(bus);
@ -1566,7 +1566,7 @@ static int reply_unit_file_changes_and_free(
UnitFileChange *changes,
unsigned n_changes) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
unsigned i;
int r;
@ -2023,7 +2023,7 @@ const sd_bus_vtable bus_manager_vtable[] = {
};
static int send_finished(sd_bus *bus, void *userdata) {
_cleanup_bus_message_unref_ sd_bus_message *message = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL;
usec_t *times = userdata;
int r;
@ -2071,7 +2071,7 @@ void bus_manager_send_finished(
}
static int send_reloading(sd_bus *bus, void *userdata) {
_cleanup_bus_message_unref_ sd_bus_message *message = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *message = NULL;
int r;
assert(bus);

View File

@ -205,7 +205,7 @@ int bus_scope_commit_properties(Unit *u) {
}
int bus_scope_send_request_stop(Scope *s) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *p = NULL;
int r;

View File

@ -399,7 +399,7 @@ static int property_get_load_error(
void *userdata,
sd_bus_error *error) {
_cleanup_bus_error_free_ sd_bus_error e = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error e = SD_BUS_ERROR_NULL;
Unit *u = userdata;
assert(bus);
@ -846,7 +846,7 @@ const sd_bus_vtable bus_unit_cgroup_vtable[] = {
};
static int send_new_signal(sd_bus *bus, void *userdata) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *p = NULL;
Unit *u = userdata;
int r;
@ -923,7 +923,7 @@ void bus_unit_send_change_signal(Unit *u) {
}
static int send_removed_signal(sd_bus *bus, void *userdata) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *p = NULL;
Unit *u = userdata;
int r;

View File

@ -74,7 +74,7 @@ int bus_send_queued_message(Manager *m) {
}
static int signal_agent_released(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
const char *cgroup, *me;
Manager *m = userdata;
uid_t sender_uid;
@ -146,8 +146,8 @@ static int signal_disconnected(sd_bus_message *message, void *userdata, sd_bus_e
}
static int signal_activation_request(sd_bus_message *message, void *userdata, sd_bus_error *ret_error) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
const char *name;
Unit *u;
@ -245,7 +245,7 @@ static int mac_selinux_filter(sd_bus_message *message, void *userdata, sd_bus_er
}
if (streq_ptr(path, "/org/freedesktop/systemd1/unit/self")) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
pid_t pid;
r = sd_bus_query_sender_creds(message, SD_BUS_CREDS_PID, &creds);
@ -304,7 +304,7 @@ static int find_unit(Manager *m, sd_bus *bus, const char *path, Unit **unit, sd_
assert(path);
if (streq_ptr(path, "/org/freedesktop/systemd1/unit/self")) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
sd_bus_message *message;
pid_t pid;
@ -617,7 +617,7 @@ static int bus_setup_disconnected_match(Manager *m, sd_bus *bus) {
}
static int bus_on_connection(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
_cleanup_bus_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
_cleanup_close_ int nfd = -1;
Manager *m = userdata;
sd_id128_t id;
@ -815,7 +815,7 @@ static int bus_setup_api(Manager *m, sd_bus *bus) {
}
static int bus_init_api(Manager *m) {
_cleanup_bus_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
int r;
if (m->api_bus)
@ -883,7 +883,7 @@ static int bus_setup_system(Manager *m, sd_bus *bus) {
}
static int bus_init_system(Manager *m) {
_cleanup_bus_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
int r;
if (m->system_bus)

View File

@ -1699,7 +1699,7 @@ int config_parse_socket_service(
void *data,
void *userdata) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_free_ char *p = NULL;
Socket *s = data;
Unit *x;
@ -1914,7 +1914,7 @@ int config_parse_busname_service(
void *data,
void *userdata) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
BusName *n = data;
int r;
Unit *x;

View File

@ -29,7 +29,7 @@
#include "netlink-util.h"
static int start_loopback(sd_netlink *rtnl) {
_cleanup_netlink_message_unref_ sd_netlink_message *req = NULL;
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
int r;
r = sd_rtnl_message_new_link(rtnl, &req, RTM_SETLINK, LOOPBACK_IFINDEX);
@ -48,7 +48,7 @@ static int start_loopback(sd_netlink *rtnl) {
}
static bool check_loopback(sd_netlink *rtnl) {
_cleanup_netlink_message_unref_ sd_netlink_message *req = NULL, *reply = NULL;
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL, *reply = NULL;
unsigned flags;
int r;
@ -68,7 +68,7 @@ static bool check_loopback(sd_netlink *rtnl) {
}
int loopback_setup(void) {
_cleanup_netlink_unref_ sd_netlink *rtnl = NULL;
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
int r;
r = sd_netlink_open(&rtnl);

View File

@ -1707,7 +1707,7 @@ int main(int argc, char *argv[]) {
arg_serialization = safe_fclose(arg_serialization);
if (queue_default_job) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
Unit *target = NULL;
Job *default_unit_job;

View File

@ -1257,7 +1257,7 @@ int manager_add_job_by_name(Manager *m, JobType type, const char *name, JobMode
}
int manager_add_job_by_name_and_warn(Manager *m, JobType type, const char *name, JobMode mode, Job **ret) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
assert(m);
@ -1700,7 +1700,7 @@ static int manager_dispatch_sigchld(Manager *m) {
}
static int manager_start_target(Manager *m, const char *name, JobMode mode) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
log_debug("Activating special unit %s", name);

View File

@ -465,7 +465,7 @@ static void path_enter_dead(Path *p, PathResult f) {
}
static void path_enter_running(Path *p) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
assert(p);

View File

@ -194,7 +194,7 @@ int mac_selinux_generic_access_check(
sd_bus_error *error) {
#ifdef HAVE_SELINUX
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
const char *tclass = NULL, *scon = NULL;
struct audit_info audit_info = {};
_cleanup_free_ char *cl = NULL;

View File

@ -1829,7 +1829,7 @@ fail:
}
static void service_enter_restart(Service *s) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
assert(s);
@ -3150,7 +3150,7 @@ static void service_bus_name_owner_change(
s->state == SERVICE_RUNNING ||
s->state == SERVICE_RELOAD)) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
pid_t pid;
/* Try to acquire PID from bus service */

View File

@ -1880,7 +1880,7 @@ fail:
}
static void socket_enter_running(Socket *s, int cfd) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
assert(s);

View File

@ -553,7 +553,7 @@ fail:
}
static void timer_enter_running(Timer *t) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
assert(t);

View File

@ -1613,7 +1613,7 @@ bool unit_can_reload(Unit *u) {
static void unit_check_unneeded(Unit *u) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
static const UnitDependency needed_dependencies[] = {
UNIT_REQUIRED_BY,
@ -1660,7 +1660,7 @@ static void unit_check_unneeded(Unit *u) {
}
static void unit_check_binds_to(Unit *u) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
bool stop = false;
Unit *other;
Iterator i;

View File

@ -268,7 +268,7 @@ static char* disk_description(const char *path) {
"ID_MODEL_FROM_DATABASE\0"
"ID_MODEL\0";
_cleanup_device_unref_ sd_device *device = NULL;
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
struct stat st;
const char *i;
int r;

View File

@ -67,8 +67,8 @@ static bool arg_show_progress = false;
static const char *arg_repair = "-a";
static void start_target(const char *target, const char *mode) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r;
assert(target);
@ -276,7 +276,7 @@ static int fsck_progress_socket(void) {
int main(int argc, char *argv[]) {
_cleanup_close_pair_ int progress_pipe[2] = { -1, -1 };
_cleanup_device_unref_ sd_device *dev = NULL;
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
const char *device, *type;
bool root_directory;
siginfo_t status;

View File

@ -127,8 +127,8 @@ static void print_status_info(StatusInfo *i) {
}
static int show_one_name(sd_bus *bus, const char* attr) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const char *s;
int r;
@ -233,7 +233,7 @@ static int show_status(sd_bus *bus, char **args, unsigned n) {
}
static int set_simple_string(sd_bus *bus, const char *method, const char *value) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
int r = 0;
polkit_agent_open_if_enabled();
@ -507,7 +507,7 @@ static int hostnamectl_main(sd_bus *bus, int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r;
setlocale(LC_ALL, "");

View File

@ -28,7 +28,6 @@
#include "bus-util.h"
#include "def.h"
#include "env-util.h"
#include "event-util.h"
#include "fileio-label.h"
#include "hostname-util.h"
#include "parse-util.h"
@ -665,7 +664,7 @@ static const sd_bus_vtable hostname_vtable[] = {
};
static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r;
assert(c);
@ -696,8 +695,8 @@ static int connect_bus(Context *c, sd_event *event, sd_bus **_bus) {
int main(int argc, char *argv[]) {
Context context = {};
_cleanup_event_unref_ sd_event *event = NULL;
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r;
log_set_target(LOG_TARGET_AUTO);

View File

@ -571,7 +571,7 @@ static int import_file(struct trie *trie, const char *filename) {
}
static int hwdb_query(int argc, char *argv[], void *userdata) {
_cleanup_hwdb_unref_ sd_hwdb *hwdb = NULL;
_cleanup_(sd_hwdb_unrefp) sd_hwdb *hwdb = NULL;
const char *key, *value;
const char *modalias;
int r;

View File

@ -24,7 +24,6 @@
#include "sd-event.h"
#include "alloc-util.h"
#include "event-util.h"
#include "export-raw.h"
#include "export-tar.h"
#include "fd-util.h"
@ -76,7 +75,7 @@ static void on_tar_finished(TarExport *export, int error, void *userdata) {
static int export_tar(int argc, char *argv[], void *userdata) {
_cleanup_(tar_export_unrefp) TarExport *export = NULL;
_cleanup_event_unref_ sd_event *event = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
_cleanup_(image_unrefp) Image *image = NULL;
const char *path = NULL, *local = NULL;
_cleanup_close_ int open_fd = -1;
@ -155,7 +154,7 @@ static void on_raw_finished(RawExport *export, int error, void *userdata) {
static int export_raw(int argc, char *argv[], void *userdata) {
_cleanup_(raw_export_unrefp) RawExport *export = NULL;
_cleanup_event_unref_ sd_event *event = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
_cleanup_(image_unrefp) Image *image = NULL;
const char *path = NULL, *local = NULL;
_cleanup_close_ int open_fd = -1;

View File

@ -24,7 +24,6 @@
#include "sd-event.h"
#include "alloc-util.h"
#include "event-util.h"
#include "fd-util.h"
#include "fs-util.h"
#include "hostname-util.h"
@ -58,7 +57,7 @@ static void on_tar_finished(TarImport *import, int error, void *userdata) {
static int import_tar(int argc, char *argv[], void *userdata) {
_cleanup_(tar_import_unrefp) TarImport *import = NULL;
_cleanup_event_unref_ sd_event *event = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
const char *path = NULL, *local = NULL;
_cleanup_free_ char *ll = NULL;
_cleanup_close_ int open_fd = -1;
@ -153,7 +152,7 @@ static void on_raw_finished(RawImport *import, int error, void *userdata) {
static int import_raw(int argc, char *argv[], void *userdata) {
_cleanup_(raw_import_unrefp) RawImport *import = NULL;
_cleanup_event_unref_ sd_event *event = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
const char *path = NULL, *local = NULL;
_cleanup_free_ char *ll = NULL;
_cleanup_close_ int open_fd = -1;

View File

@ -1039,7 +1039,7 @@ static int method_pull_dkr(sd_bus_message *msg, void *userdata, sd_bus_error *er
}
static int method_list_transfers(sd_bus_message *msg, void *userdata, sd_bus_error *error) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
Manager *m = userdata;
Transfer *t;
Iterator i;

View File

@ -24,7 +24,6 @@
#include "sd-event.h"
#include "alloc-util.h"
#include "event-util.h"
#include "hostname-util.h"
#include "import-util.h"
#include "machine-image.h"
@ -61,7 +60,7 @@ static void on_tar_finished(TarPull *pull, int error, void *userdata) {
static int pull_tar(int argc, char *argv[], void *userdata) {
_cleanup_(tar_pull_unrefp) TarPull *pull = NULL;
_cleanup_event_unref_ sd_event *event = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
const char *url, *local;
_cleanup_free_ char *l = NULL, *ll = NULL;
int r;
@ -147,7 +146,7 @@ static void on_raw_finished(RawPull *pull, int error, void *userdata) {
static int pull_raw(int argc, char *argv[], void *userdata) {
_cleanup_(raw_pull_unrefp) RawPull *pull = NULL;
_cleanup_event_unref_ sd_event *event = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
const char *url, *local;
_cleanup_free_ char *l = NULL, *ll = NULL;
int r;
@ -233,7 +232,7 @@ static void on_dkr_finished(DkrPull *pull, int error, void *userdata) {
static int pull_dkr(int argc, char *argv[], void *userdata) {
_cleanup_(dkr_pull_unrefp) DkrPull *pull = NULL;
_cleanup_event_unref_ sd_event *event = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
const char *name, *reference, *local, *digest;
int r;

View File

@ -101,7 +101,7 @@ static const char *translate_runlevel(int runlevel, bool *isolate) {
static void change_runlevel(Server *s, int runlevel) {
const char *target;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const char *mode;
bool isolate = false;
int r;

View File

@ -709,7 +709,7 @@ static int request_handler_file(
}
static int get_virtualization(char **v) {
_cleanup_bus_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
char *b = NULL;
int r;

View File

@ -792,7 +792,7 @@ finish:
}
int main(int argc, char *argv[]) {
_cleanup_journal_close_ sd_journal*j = NULL;
_cleanup_(sd_journal_closep) sd_journal*j = NULL;
const char* match;
Iterator it;
int r = 0;

View File

@ -127,8 +127,5 @@ struct sd_journal {
char *journal_make_match_string(sd_journal *j);
void journal_print_header(sd_journal *j);
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_journal*, sd_journal_close);
#define _cleanup_journal_close_ _cleanup_(sd_journal_closep)
#define JOURNAL_FOREACH_DATA_RETVAL(j, data, l, retval) \
for (sd_journal_restart_data(j); ((retval) = sd_journal_enumerate_data((j), &(data), &(l))) > 0; )

View File

@ -1766,8 +1766,8 @@ static int access_check(sd_journal *j) {
}
static int flush_to_var(void) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_close_ int watch_fd = -1;
int r;
@ -1828,7 +1828,7 @@ static int flush_to_var(void) {
}
static int send_signal_and_wait(int sig, const char *watch_path) {
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_close_ int watch_fd = -1;
usec_t start;
int r;
@ -1857,7 +1857,7 @@ static int send_signal_and_wait(int sig, const char *watch_path) {
/* Let's ask for a sync, but only once. */
if (!bus) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
r = bus_connect_system_systemd(&bus);
if (r < 0)
@ -1920,7 +1920,7 @@ static int sync_journal(void) {
int main(int argc, char *argv[]) {
int r;
_cleanup_journal_close_ sd_journal *j = NULL;
_cleanup_(sd_journal_closep) sd_journal *j = NULL;
bool need_seek = false;
sd_id128_t previous_boot_id;
bool previous_boot_id_valid = false, first_line = true;

View File

@ -29,7 +29,7 @@
int main(int argc, char *argv[]) {
unsigned n = 0;
_cleanup_journal_close_ sd_journal*j = NULL;
_cleanup_(sd_journal_closep) sd_journal*j = NULL;
log_set_max_level(LOG_DEBUG);

View File

@ -30,7 +30,7 @@
#include "util.h"
int main(int argc, char *argv[]) {
_cleanup_journal_close_ sd_journal*j;
_cleanup_(sd_journal_closep) sd_journal*j = NULL;
_cleanup_free_ char *t;
log_set_max_level(LOG_DEBUG);

View File

@ -79,7 +79,7 @@ int main(int argc, char *argv[]) {
JournalFile *one, *two, *three;
char t[] = "/tmp/journal-stream-XXXXXX";
unsigned i;
_cleanup_journal_close_ sd_journal *j = NULL;
_cleanup_(sd_journal_closep) sd_journal *j = NULL;
char *z;
const void *data;
size_t l;

View File

@ -61,13 +61,10 @@ void dhcp_packet_append_ip_headers(DHCPPacket *packet, be32_t source_addr,
int dhcp_packet_verify_headers(DHCPPacket *packet, size_t len, bool checksum);
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_client*, sd_dhcp_client_unref);
#define _cleanup_dhcp_client_unref_ _cleanup_(sd_dhcp_client_unrefp)
/* If we are invoking callbacks of a dhcp-client, ensure unreffing the
* client from the callback doesn't destroy the object we are working
* on */
#define DHCP_CLIENT_DONT_DESTROY(client) \
_cleanup_dhcp_client_unref_ _unused_ sd_dhcp_client *_dont_destroy_##client = sd_dhcp_client_ref(client)
_cleanup_(sd_dhcp_client_unrefp) _unused_ sd_dhcp_client *_dont_destroy_##client = sd_dhcp_client_ref(client)
#define log_dhcp_client(client, fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCP CLIENT (0x%x): " fmt, client->xid, ##__VA_ARGS__)

View File

@ -102,6 +102,3 @@ int dhcp_lease_set_client_id(sd_dhcp_lease *lease, const void *client_id, size_t
int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file);
int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file);
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_lease*, sd_dhcp_lease_unref);
#define _cleanup_dhcp_lease_unref_ _cleanup_(sd_dhcp_lease_unrefp)

View File

@ -84,9 +84,6 @@ typedef struct DHCPRequest {
uint32_t lifetime;
} DHCPRequest;
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_server*, sd_dhcp_server_unref);
#define _cleanup_dhcp_server_unref_ _cleanup_(sd_dhcp_server_unrefp)
#define log_dhcp_server(client, fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,

View File

@ -74,6 +74,3 @@ int dhcp6_lease_set_sntp(sd_dhcp6_lease *lease, uint8_t *optval,
size_t optlen) ;
int dhcp6_lease_new(sd_dhcp6_lease **ret);
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp6_lease*, sd_dhcp6_lease_unref);
#define _cleanup_dhcp6_lease_free_ _cleanup_(sd_dhcp6_lease_unrefp)

View File

@ -335,7 +335,7 @@ int lldp_chassis_new(tlv_packet *tlv,
}
int lldp_receive_packet(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
_cleanup_lldp_packet_unref_ tlv_packet *packet = NULL;
_cleanup_(sd_lldp_packet_unrefp) tlv_packet *packet = NULL;
tlv_packet *p;
uint16_t length;
int r;

View File

@ -74,9 +74,6 @@ struct sd_lldp_packet {
int tlv_packet_new(tlv_packet **ret);
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_lldp_packet*, sd_lldp_packet_unref);
#define _cleanup_lldp_packet_unref_ _cleanup_(sd_lldp_packet_unrefp)
int lldp_tlv_packet_open_container(tlv_packet *m, uint16_t type);
int lldp_tlv_packet_close_container(tlv_packet *m);

View File

@ -1,26 +0,0 @@
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright (C) 2014 Tom Gundersen
Copyright (C) 2014 Susant Sahani
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#pragma once
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_lldp *, sd_lldp_free);
#define _cleanup_lldp_free_ _cleanup_(sd_lldp_freep)

View File

@ -1067,7 +1067,7 @@ static int client_timeout_t1(sd_event_source *s, uint64_t usec,
static int client_handle_offer(sd_dhcp_client *client, DHCPMessage *offer,
size_t len) {
_cleanup_dhcp_lease_unref_ sd_dhcp_lease *lease = NULL;
_cleanup_(sd_dhcp_lease_unrefp) sd_dhcp_lease *lease = NULL;
int r;
r = dhcp_lease_new(&lease);
@ -1132,7 +1132,7 @@ static int client_handle_forcerenew(sd_dhcp_client *client, DHCPMessage *force,
static int client_handle_ack(sd_dhcp_client *client, DHCPMessage *ack,
size_t len) {
_cleanup_dhcp_lease_unref_ sd_dhcp_lease *lease = NULL;
_cleanup_(sd_dhcp_lease_unrefp) sd_dhcp_lease *lease = NULL;
_cleanup_free_ char *error_message = NULL;
int r;
@ -1751,7 +1751,7 @@ sd_dhcp_client *sd_dhcp_client_unref(sd_dhcp_client *client) {
}
int sd_dhcp_client_new(sd_dhcp_client **ret) {
_cleanup_dhcp_client_unref_ sd_dhcp_client *client = NULL;
_cleanup_(sd_dhcp_client_unrefp) sd_dhcp_client *client = NULL;
assert_return(ret, -EINVAL);

View File

@ -865,7 +865,7 @@ fail:
int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
_cleanup_dhcp_lease_unref_ sd_dhcp_lease *lease = NULL;
_cleanup_(sd_dhcp_lease_unrefp) sd_dhcp_lease *lease = NULL;
_cleanup_free_ char
*address = NULL,
*router = NULL,

View File

@ -185,7 +185,7 @@ sd_dhcp_server *sd_dhcp_server_unref(sd_dhcp_server *server) {
}
int sd_dhcp_server_new(sd_dhcp_server **ret, int ifindex) {
_cleanup_dhcp_server_unref_ sd_dhcp_server *server = NULL;
_cleanup_(sd_dhcp_server_unrefp) sd_dhcp_server *server = NULL;
assert_return(ret, -EINVAL);
assert_return(ifindex > 0, -EINVAL);

View File

@ -107,11 +107,8 @@ const char * dhcp6_message_status_table[_DHCP6_STATUS_MAX] = {
DEFINE_STRING_TABLE_LOOKUP(dhcp6_message_status, int);
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp6_client*, sd_dhcp6_client_unref);
#define _cleanup_dhcp6_client_unref_ _cleanup_(sd_dhcp6_client_unrefp)
#define DHCP6_CLIENT_DONT_DESTROY(client) \
_cleanup_dhcp6_client_unref_ _unused_ sd_dhcp6_client *_dont_destroy_##client = sd_dhcp6_client_ref(client)
_cleanup_(sd_dhcp6_client_unrefp) _unused_ sd_dhcp6_client *_dont_destroy_##client = sd_dhcp6_client_ref(client)
static int client_start(sd_dhcp6_client *client, enum DHCP6State state);
@ -829,7 +826,7 @@ static int client_parse_message(sd_dhcp6_client *client,
static int client_receive_reply(sd_dhcp6_client *client, DHCP6Message *reply, size_t len) {
int r;
_cleanup_dhcp6_lease_free_ sd_dhcp6_lease *lease = NULL;
_cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
bool rapid_commit;
if (reply->type != DHCP6_REPLY)
@ -860,7 +857,7 @@ static int client_receive_reply(sd_dhcp6_client *client, DHCP6Message *reply, si
static int client_receive_advertise(sd_dhcp6_client *client, DHCP6Message *advertise, size_t len) {
int r;
_cleanup_dhcp6_lease_free_ sd_dhcp6_lease *lease = NULL;
_cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
uint8_t pref_advertise = 0, pref_lease = 0;
if (advertise->type != DHCP6_ADVERTISE)
@ -1277,7 +1274,7 @@ sd_dhcp6_client *sd_dhcp6_client_unref(sd_dhcp6_client *client) {
}
int sd_dhcp6_client_new(sd_dhcp6_client **ret) {
_cleanup_dhcp6_client_unref_ sd_dhcp6_client *client = NULL;
_cleanup_(sd_dhcp6_client_unrefp) sd_dhcp6_client *client = NULL;
size_t t;
assert_return(ret, -EINVAL);

View File

@ -28,7 +28,6 @@
#include "alloc-util.h"
#include "arp-util.h"
#include "event-util.h"
#include "fd-util.h"
#include "in-addr-util.h"
#include "list.h"
@ -120,11 +119,8 @@ sd_ipv4acd *sd_ipv4acd_unref(sd_ipv4acd *ll) {
return NULL;
}
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_ipv4acd*, sd_ipv4acd_unref);
#define _cleanup_ipv4acd_unref_ _cleanup_(sd_ipv4acd_unrefp)
int sd_ipv4acd_new(sd_ipv4acd **ret) {
_cleanup_ipv4acd_unref_ sd_ipv4acd *ll = NULL;
_cleanup_(sd_ipv4acd_unrefp) sd_ipv4acd *ll = NULL;
assert_return(ret, -EINVAL);
@ -189,7 +185,7 @@ int sd_ipv4acd_stop(sd_ipv4acd *ll) {
static int ipv4acd_on_timeout(sd_event_source *s, uint64_t usec, void *userdata);
static int ipv4acd_set_next_wakeup(sd_ipv4acd *ll, int sec, int random_sec) {
_cleanup_event_source_unref_ sd_event_source *timer = NULL;
_cleanup_(sd_event_source_unrefp) sd_event_source *timer = NULL;
usec_t next_timeout;
usec_t time_now;
int r;

View File

@ -28,7 +28,6 @@
#include "sd-ipv4ll.h"
#include "alloc-util.h"
#include "event-util.h"
#include "in-addr-util.h"
#include "list.h"
#include "random-util.h"
@ -41,7 +40,7 @@
#define IPV4LL_NETMASK 0xFFFF0000L
#define IPV4LL_DONT_DESTROY(ll) \
_cleanup_ipv4ll_unref_ _unused_ sd_ipv4ll *_dont_destroy_##ll = sd_ipv4ll_ref(ll)
_cleanup_(sd_ipv4ll_unrefp) _unused_ sd_ipv4ll *_dont_destroy_##ll = sd_ipv4ll_ref(ll)
struct sd_ipv4ll {
unsigned n_ref;
@ -86,13 +85,10 @@ sd_ipv4ll *sd_ipv4ll_unref(sd_ipv4ll *ll) {
return NULL;
}
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_ipv4ll*, sd_ipv4ll_unref);
#define _cleanup_ipv4ll_unref_ _cleanup_(sd_ipv4ll_unrefp)
static void ipv4ll_on_acd(sd_ipv4acd *ll, int event, void *userdata);
int sd_ipv4ll_new(sd_ipv4ll **ret) {
_cleanup_ipv4ll_unref_ sd_ipv4ll *ll = NULL;
_cleanup_(sd_ipv4ll_unrefp) sd_ipv4ll *ll = NULL;
int r;
assert_return(ret, -EINVAL);

View File

@ -31,7 +31,6 @@
#include "lldp-internal.h"
#include "lldp-port.h"
#include "lldp-tlv.h"
#include "lldp-util.h"
#include "prioq.h"
#include "siphash24.h"
#include "string-util.h"
@ -652,10 +651,10 @@ int sd_lldp_set_callback(sd_lldp *lldp, sd_lldp_cb_t cb, void *userdata) {
return 0;
}
void sd_lldp_free(sd_lldp *lldp) {
sd_lldp* sd_lldp_unref(sd_lldp *lldp) {
if (!lldp)
return;
return NULL;
/* Drop all packets */
lldp_mib_objects_flush(lldp);
@ -666,13 +665,14 @@ void sd_lldp_free(sd_lldp *lldp) {
prioq_free(lldp->by_expiry);
free(lldp);
return NULL;
}
int sd_lldp_new(int ifindex,
const char *ifname,
const struct ether_addr *mac,
sd_lldp **ret) {
_cleanup_lldp_free_ sd_lldp *lldp = NULL;
_cleanup_(sd_lldp_unrefp) sd_lldp *lldp = NULL;
int r;
assert_return(ret, -EINVAL);

View File

@ -245,11 +245,8 @@ sd_ndisc *sd_ndisc_unref(sd_ndisc *nd) {
return NULL;
}
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_ndisc*, sd_ndisc_unref);
#define _cleanup_sd_ndisc_free_ _cleanup_(sd_ndisc_unrefp)
int sd_ndisc_new(sd_ndisc **ret) {
_cleanup_sd_ndisc_free_ sd_ndisc *nd = NULL;
_cleanup_(sd_ndisc_unrefp) sd_ndisc *nd = NULL;
assert(ret);

View File

@ -30,7 +30,6 @@
#include "sd-ipv4acd.h"
#include "sd-netlink.h"
#include "event-util.h"
#include "in-addr-util.h"
#include "netlink-util.h"
#include "util.h"
@ -76,9 +75,9 @@ static int client_run(int ifindex, const struct in_addr *pa, const struct ether_
}
static int test_acd(const char *ifname, const char *address) {
_cleanup_event_unref_ sd_event *e = NULL;
_cleanup_netlink_unref_ sd_netlink *rtnl = NULL;
_cleanup_netlink_message_unref_ sd_netlink_message *m = NULL, *reply = NULL;
_cleanup_(sd_event_unrefp) sd_event *e = NULL;
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL, *reply = NULL;
union in_addr_union pa;
struct ether_addr ha;
int ifindex;

View File

@ -31,7 +31,6 @@
#include "dhcp-identifier.h"
#include "dhcp-internal.h"
#include "dhcp-protocol.h"
#include "event-util.h"
#include "fd-util.h"
#include "util.h"
@ -491,7 +490,7 @@ static void test_addr_acq(sd_event *e) {
}
int main(int argc, char *argv[]) {
_cleanup_event_unref_ sd_event *e;
_cleanup_(sd_event_unrefp) sd_event *e;
log_set_max_level(LOG_DEBUG);
log_parse_environment();

View File

@ -26,10 +26,9 @@
#include "sd-event.h"
#include "dhcp-server-internal.h"
#include "event-util.h"
static void test_pool(struct in_addr *address, unsigned size, int ret) {
_cleanup_dhcp_server_unref_ sd_dhcp_server *server = NULL;
_cleanup_(sd_dhcp_server_unrefp) sd_dhcp_server *server = NULL;
assert_se(sd_dhcp_server_new(&server, 1) >= 0);
@ -37,7 +36,7 @@ static void test_pool(struct in_addr *address, unsigned size, int ret) {
}
static int test_basic(sd_event *event) {
_cleanup_dhcp_server_unref_ sd_dhcp_server *server = NULL;
_cleanup_(sd_dhcp_server_unrefp) sd_dhcp_server *server = NULL;
struct in_addr address_lo = {
.s_addr = htonl(INADDR_LOOPBACK),
};
@ -86,7 +85,7 @@ static int test_basic(sd_event *event) {
}
static void test_message_handler(void) {
_cleanup_dhcp_server_unref_ sd_dhcp_server *server = NULL;
_cleanup_(sd_dhcp_server_unrefp) sd_dhcp_server *server = NULL;
struct {
DHCPMessage message;
struct {
@ -244,7 +243,7 @@ static void test_client_id_hash(void) {
}
int main(int argc, char *argv[]) {
_cleanup_event_unref_ sd_event *e;
_cleanup_(sd_event_unrefp) sd_event *e;
int r;
log_set_max_level(LOG_DEBUG);

View File

@ -32,7 +32,6 @@
#include "dhcp6-internal.h"
#include "dhcp6-lease-internal.h"
#include "dhcp6-protocol.h"
#include "event-util.h"
#include "fd-util.h"
#include "macro.h"
#include "socket-util.h"
@ -206,7 +205,7 @@ static uint8_t msg_reply[173] = {
};
static int test_advertise_option(sd_event *e) {
_cleanup_dhcp6_lease_free_ sd_dhcp6_lease *lease = NULL;
_cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
DHCP6Message *advertise = (DHCP6Message *)msg_advertise;
uint8_t *optval, *opt = msg_advertise + sizeof(DHCP6Message);
uint16_t optcode;
@ -408,7 +407,7 @@ static int test_client_send_reply(DHCP6Message *request) {
static int test_client_verify_request(DHCP6Message *request, uint8_t *option,
size_t len) {
_cleanup_dhcp6_lease_free_ sd_dhcp6_lease *lease = NULL;
_cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
uint8_t *optval;
uint16_t optcode;
size_t optlen;
@ -599,7 +598,7 @@ static void test_client_information_cb(sd_dhcp6_client *client, int event,
static int test_client_verify_information_request(DHCP6Message *information_request,
uint8_t *option, size_t len) {
_cleanup_dhcp6_lease_free_ sd_dhcp6_lease *lease = NULL;
_cleanup_(sd_dhcp6_lease_unrefp) sd_dhcp6_lease *lease = NULL;
uint8_t *optval;
uint16_t optcode;
size_t optlen;
@ -749,7 +748,7 @@ static int test_client_solicit(sd_event *e) {
}
int main(int argc, char *argv[]) {
_cleanup_event_unref_ sd_event *e;
_cleanup_(sd_event_unrefp) sd_event *e;
assert_se(sd_event_new(&e) >= 0);

View File

@ -30,7 +30,6 @@
#include "sd-netlink.h"
#include "alloc-util.h"
#include "event-util.h"
#include "in-addr-util.h"
#include "netlink-util.h"
#include "parse-util.h"
@ -91,9 +90,9 @@ static int client_run(int ifindex, const char *seed_str, const struct ether_addr
}
static int test_ll(const char *ifname, const char *seed) {
_cleanup_event_unref_ sd_event *e = NULL;
_cleanup_netlink_unref_ sd_netlink *rtnl = NULL;
_cleanup_netlink_message_unref_ sd_netlink_message *m = NULL, *reply = NULL;
_cleanup_(sd_event_unrefp) sd_event *e = NULL;
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
_cleanup_(sd_netlink_message_unrefp) sd_netlink_message *m = NULL, *reply = NULL;
struct ether_addr ha;
int ifindex;

View File

@ -29,7 +29,6 @@
#include "sd-ipv4ll.h"
#include "arp-util.h"
#include "event-util.h"
#include "fd-util.h"
#include "socket-util.h"
#include "util.h"
@ -207,7 +206,7 @@ static void test_basic_request(sd_event *e) {
}
int main(int argc, char *argv[]) {
_cleanup_event_unref_ sd_event *e = NULL;
_cleanup_(sd_event_unrefp) sd_event *e = NULL;
log_set_max_level(LOG_DEBUG);
log_parse_environment();

View File

@ -29,7 +29,6 @@
#include "sd-lldp.h"
#include "alloc-util.h"
#include "event-util.h"
#include "fd-util.h"
#include "lldp-network.h"
#include "lldp-tlv.h"
@ -48,7 +47,7 @@ static struct ether_addr mac_addr = {
};
static int lldp_build_tlv_packet(tlv_packet **ret) {
_cleanup_lldp_packet_unref_ tlv_packet *m = NULL;
_cleanup_(sd_lldp_packet_unrefp) tlv_packet *m = NULL;
const uint8_t lldp_dst[] = LLDP_MULTICAST_ADDR;
struct ether_header ether = {
.ether_type = htons(ETHERTYPE_LLDP),
@ -237,7 +236,7 @@ static int lldp_parse_tlv_packet(tlv_packet *m, int len) {
}
static void test_parser(void) {
_cleanup_lldp_packet_unref_ tlv_packet *tlv = NULL;
_cleanup_(sd_lldp_packet_unrefp) tlv_packet *tlv = NULL;
/* form a packet */
lldp_build_tlv_packet(&tlv);
@ -292,7 +291,7 @@ static int stop_lldp(sd_lldp *lldp) {
if (r)
return r;
sd_lldp_free(lldp);
sd_lldp_unref(lldp);
safe_close(test_fd[1]);
return 0;
@ -457,7 +456,7 @@ static void test_receive_oui_packet(sd_event *e) {
}
int main(int argc, char *argv[]) {
_cleanup_event_unref_ sd_event *e = NULL;
_cleanup_(sd_event_unrefp) sd_event *e = NULL;
test_parser();

View File

@ -91,7 +91,7 @@ static int bus_request_name_kernel(sd_bus *bus, const char *name, uint64_t flags
}
static int bus_request_name_dbus1(sd_bus *bus, const char *name, uint64_t flags) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
uint32_t ret, param = 0;
int r;
@ -187,7 +187,7 @@ static int bus_release_name_kernel(sd_bus *bus, const char *name) {
}
static int bus_release_name_dbus1(sd_bus *bus, const char *name) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
uint32_t ret;
int r;
@ -326,7 +326,7 @@ static int bus_list_names_kernel(sd_bus *bus, char ***acquired, char ***activata
}
static int bus_list_names_dbus1(sd_bus *bus, char ***acquired, char ***activatable) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_strv_free_ char **x = NULL, **y = NULL;
int r;
@ -647,7 +647,7 @@ int bus_get_name_creds_kdbus(
bool allow_activator,
sd_bus_creds **creds) {
_cleanup_bus_creds_unref_ sd_bus_creds *c = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *c = NULL;
struct kdbus_cmd_info *cmd;
struct kdbus_info *conn_info;
size_t size, l;
@ -753,8 +753,8 @@ static int bus_get_name_creds_dbus1(
uint64_t mask,
sd_bus_creds **creds) {
_cleanup_bus_message_unref_ sd_bus_message *reply_unique = NULL, *reply = NULL;
_cleanup_bus_creds_unref_ sd_bus_creds *c = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply_unique = NULL, *reply = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *c = NULL;
const char *unique = NULL;
pid_t pid = 0;
int r;
@ -858,7 +858,7 @@ static int bus_get_name_creds_dbus1(
}
if (mask & SD_BUS_CREDS_SELINUX_CONTEXT) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const void *p = NULL;
size_t sz = 0;
@ -930,7 +930,7 @@ _public_ int sd_bus_get_name_creds(
}
static int bus_get_owner_creds_kdbus(sd_bus *bus, uint64_t mask, sd_bus_creds **ret) {
_cleanup_bus_creds_unref_ sd_bus_creds *c = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *c = NULL;
struct kdbus_cmd_info cmd = {
.size = sizeof(struct kdbus_cmd_info),
};
@ -979,7 +979,7 @@ static int bus_get_owner_creds_kdbus(sd_bus *bus, uint64_t mask, sd_bus_creds **
}
static int bus_get_owner_creds_dbus1(sd_bus *bus, uint64_t mask, sd_bus_creds **ret) {
_cleanup_bus_creds_unref_ sd_bus_creds *c = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *c = NULL;
pid_t pid = 0;
bool do_label;
int r;
@ -1543,7 +1543,7 @@ int bus_remove_match_internal(
}
_public_ int sd_bus_get_name_machine_id(sd_bus *bus, const char *name, sd_id128_t *machine) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL, *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL, *m = NULL;
const char *mid;
int r;

View File

@ -33,7 +33,7 @@ _public_ int sd_bus_emit_signal(
const char *member,
const char *types, ...) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
assert_return(bus, -EINVAL);
@ -70,7 +70,7 @@ _public_ int sd_bus_call_method_async(
void *userdata,
const char *types, ...) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
assert_return(bus, -EINVAL);
@ -106,7 +106,7 @@ _public_ int sd_bus_call_method(
sd_bus_message **reply,
const char *types, ...) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
bus_assert_return(bus, -EINVAL, error);
@ -141,7 +141,7 @@ _public_ int sd_bus_reply_method_return(
sd_bus_message *call,
const char *types, ...) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
assert_return(call, -EINVAL);
@ -177,7 +177,7 @@ _public_ int sd_bus_reply_method_error(
sd_bus_message *call,
const sd_bus_error *e) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
assert_return(call, -EINVAL);
@ -206,7 +206,7 @@ _public_ int sd_bus_reply_method_errorf(
const char *format,
...) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
va_list ap;
assert_return(call, -EINVAL);
@ -233,7 +233,7 @@ _public_ int sd_bus_reply_method_errno(
int error,
const sd_bus_error *p) {
_cleanup_bus_error_free_ sd_bus_error berror = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error berror = SD_BUS_ERROR_NULL;
assert_return(call, -EINVAL);
assert_return(call->sealed, -EPERM);
@ -261,7 +261,7 @@ _public_ int sd_bus_reply_method_errnof(
const char *format,
...) {
_cleanup_bus_error_free_ sd_bus_error berror = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error berror = SD_BUS_ERROR_NULL;
va_list ap;
assert_return(call, -EINVAL);
@ -334,7 +334,7 @@ _public_ int sd_bus_get_property_trivial(
sd_bus_error *error,
char type, void *ptr) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
int r;
bus_assert_return(bus, -EINVAL, error);
@ -376,7 +376,7 @@ _public_ int sd_bus_get_property_string(
sd_bus_error *error,
char **ret) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
const char *s;
char *n;
int r;
@ -426,7 +426,7 @@ _public_ int sd_bus_get_property_strv(
sd_bus_error *error,
char ***ret) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
int r;
bus_assert_return(bus, -EINVAL, error);
@ -467,7 +467,7 @@ _public_ int sd_bus_set_property(
sd_bus_error *error,
const char *type, ...) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
va_list ap;
int r;
@ -555,7 +555,7 @@ _public_ int sd_bus_query_sender_creds(sd_bus_message *call, uint64_t mask, sd_b
}
_public_ int sd_bus_query_sender_privilege(sd_bus_message *call, int capability) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
uid_t our_uid;
bool know_caps = false;
int r;

View File

@ -75,7 +75,9 @@ void bus_creds_done(sd_bus_creds *c) {
}
_public_ sd_bus_creds *sd_bus_creds_ref(sd_bus_creds *c) {
assert_return(c, NULL);
if (!c)
return NULL;
if (c->allocated) {
assert(c->n_ref > 0);
@ -1118,7 +1120,7 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) {
}
int bus_creds_extend_by_pid(sd_bus_creds *c, uint64_t mask, sd_bus_creds **ret) {
_cleanup_bus_creds_unref_ sd_bus_creds *n = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *n = NULL;
int r;
assert(c);

View File

@ -381,7 +381,7 @@ char *bus_address_escape(const char *v);
* bus from the callback doesn't destroy the object we are working
* on */
#define BUS_DONT_DESTROY(bus) \
_cleanup_bus_unref_ _unused_ sd_bus *_dont_destroy_##bus = sd_bus_ref(bus)
_cleanup_(sd_bus_unrefp) _unused_ sd_bus *_dont_destroy_##bus = sd_bus_ref(bus)
int bus_set_address_system(sd_bus *bus);
int bus_set_address_user(sd_bus *bus);

View File

@ -1142,7 +1142,7 @@ int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call
r = ioctl(bus->output_fd, KDBUS_CMD_SEND, &cmd);
if (r < 0) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus_message *reply;
if (errno == EAGAIN || errno == EINTR)
@ -1221,7 +1221,7 @@ static int push_name_owner_changed(
const char *new_owner,
const struct kdbus_timestamp *ts) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
assert(bus);
@ -1308,7 +1308,7 @@ static int translate_reply(
const struct kdbus_item *d,
const struct kdbus_timestamp *ts) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
assert(bus);

View File

@ -317,7 +317,7 @@ int bus_match_run(
/* Run the callback. And then invoke siblings. */
if (node->leaf.callback->callback) {
_cleanup_bus_error_free_ sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
sd_bus_slot *slot;
slot = container_of(node->leaf.callback, sd_bus_slot, match_callback);

View File

@ -802,7 +802,7 @@ _public_ int sd_bus_message_new_method_errorf(
const char *format,
...) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
va_list ap;
assert_return(name, -EINVAL);
@ -821,7 +821,7 @@ _public_ int sd_bus_message_new_method_errno(
int error,
const sd_bus_error *p) {
_cleanup_bus_error_free_ sd_bus_error berror = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error berror = SD_BUS_ERROR_NULL;
if (sd_bus_error_is_set(p))
return sd_bus_message_new_method_error(call, m, p);
@ -838,7 +838,7 @@ _public_ int sd_bus_message_new_method_errnof(
const char *format,
...) {
_cleanup_bus_error_free_ sd_bus_error berror = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error berror = SD_BUS_ERROR_NULL;
va_list ap;
va_start(ap, format);
@ -919,7 +919,9 @@ fail:
}
_public_ sd_bus_message* sd_bus_message_ref(sd_bus_message *m) {
assert_return(m, NULL);
if (!m)
return NULL;
assert(m->n_ref > 0);
m->n_ref++;
@ -5838,7 +5840,7 @@ _public_ sd_bus *sd_bus_message_get_bus(sd_bus_message *m) {
}
int bus_message_remarshal(sd_bus *bus, sd_bus_message **m) {
_cleanup_bus_message_unref_ sd_bus_message *n = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *n = NULL;
usec_t timeout;
int r;

View File

@ -272,7 +272,7 @@ static int node_callbacks_run(
assert(found_object);
LIST_FOREACH(callbacks, c, first) {
_cleanup_bus_error_free_ sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
sd_bus_slot *slot;
if (bus->nodes_modified)
@ -357,7 +357,7 @@ static int method_callbacks_run(
bool require_fallback,
bool *found_object) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const char *signature;
void *u;
int r;
@ -580,8 +580,8 @@ static int property_get_set_callbacks_run(
bool is_get,
bool *found_object) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
sd_bus_slot *slot;
void *u = NULL;
int r;
@ -781,7 +781,7 @@ static int property_get_all_callbacks_run(
const char *iface,
bool *found_object) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
struct node_vtable *c;
bool found_interface;
int r;
@ -804,7 +804,7 @@ static int property_get_all_callbacks_run(
streq(iface, "org.freedesktop.DBus.Introspectable");
LIST_FOREACH(vtables, c, first) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
void *u;
if (require_fallback && !c->is_fallback)
@ -881,7 +881,7 @@ static int bus_node_exists(
}
LIST_FOREACH(vtables, c, n->vtables) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
if (require_fallback && !c->is_fallback)
continue;
@ -903,8 +903,8 @@ static int process_introspect(
bool require_fallback,
bool *found_object) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_set_free_free_ Set *s = NULL;
const char *previous_interface = NULL;
struct introspect intro;
@ -1164,8 +1164,8 @@ static int process_get_managed_objects(
bool require_fallback,
bool *found_object) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_set_free_free_ Set *s = NULL;
Iterator i;
char *path;
@ -1881,8 +1881,8 @@ static int emit_properties_changed_on_interface(
bool *found_interface,
char **names) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
bool has_invalidating = false, has_changing = false;
struct vtable_member key = {};
struct node_vtable *c;
@ -2176,7 +2176,7 @@ static int object_added_append_all_prefix(
return 0;
LIST_FOREACH(vtables, c, n->vtables) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
void *u = NULL;
if (require_fallback && !c->is_fallback)
@ -2305,7 +2305,7 @@ static int object_added_append_all(sd_bus *bus, sd_bus_message *m, const char *p
_public_ int sd_bus_emit_object_added(sd_bus *bus, const char *path) {
BUS_DONT_DESTROY(bus);
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
struct node *object_manager;
int r;
@ -2389,7 +2389,7 @@ static int object_removed_append_all_prefix(
return 0;
LIST_FOREACH(vtables, c, n->vtables) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
void *u = NULL;
if (require_fallback && !c->is_fallback)
@ -2475,7 +2475,7 @@ static int object_removed_append_all(sd_bus *bus, sd_bus_message *m, const char
_public_ int sd_bus_emit_object_removed(sd_bus *bus, const char *path) {
BUS_DONT_DESTROY(bus);
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
struct node *object_manager;
int r;
@ -2543,7 +2543,7 @@ static int interfaces_added_append_one_prefix(
const char *interface,
bool require_fallback) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
bool found_interface = false;
struct node_vtable *c;
struct node *n;
@ -2638,7 +2638,7 @@ static int interfaces_added_append_one(
_public_ int sd_bus_emit_interfaces_added_strv(sd_bus *bus, const char *path, char **interfaces) {
BUS_DONT_DESTROY(bus);
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
struct node *object_manager;
char **i;
int r;
@ -2722,7 +2722,7 @@ _public_ int sd_bus_emit_interfaces_added(sd_bus *bus, const char *path, const c
}
_public_ int sd_bus_emit_interfaces_removed_strv(sd_bus *bus, const char *path, char **interfaces) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
struct node *object_manager;
int r;

View File

@ -57,7 +57,9 @@ sd_bus_slot *bus_slot_allocate(
}
_public_ sd_bus_slot* sd_bus_slot_ref(sd_bus_slot *slot) {
assert_return(slot, NULL);
if (!slot)
return NULL;
assert(slot->n_ref > 0);

View File

@ -111,7 +111,9 @@ _public_ int sd_bus_track_new(
}
_public_ sd_bus_track* sd_bus_track_ref(sd_bus_track *track) {
assert_return(track, NULL);
if (!track)
return NULL;
assert(track->n_ref > 0);
@ -161,7 +163,7 @@ static int on_name_owner_changed(sd_bus_message *message, void *userdata, sd_bus
}
_public_ int sd_bus_track_add_name(sd_bus_track *track, const char *name) {
_cleanup_bus_slot_unref_ sd_bus_slot *slot = NULL;
_cleanup_(sd_bus_slot_unrefp) sd_bus_slot *slot = NULL;
_cleanup_free_ char *n = NULL;
const char *match;
int r;
@ -207,7 +209,7 @@ _public_ int sd_bus_track_add_name(sd_bus_track *track, const char *name) {
}
_public_ int sd_bus_track_remove_name(sd_bus_track *track, const char *name) {
_cleanup_bus_slot_unref_ sd_bus_slot *slot = NULL;
_cleanup_(sd_bus_slot_unrefp) sd_bus_slot *slot = NULL;
_cleanup_free_ char *n = NULL;
assert_return(name, -EINVAL);

View File

@ -137,7 +137,7 @@ static int list_bus_names(sd_bus *bus, char **argv) {
}
STRV_FOREACH(i, merged) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
sd_id128_t mid;
if (hashmap_get(names, *i) == NAME_IS_ACTIVATABLE) {
@ -334,8 +334,8 @@ static int find_nodes(sd_bus *bus, const char *service, const char *path, Set *p
.on_path = on_path,
};
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const char *xml;
int r;
@ -867,8 +867,8 @@ static int introspect(sd_bus *bus, char **argv) {
.on_property = on_property,
};
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(member_set_freep) Set *members = NULL;
Iterator i;
Member *m;
@ -1132,7 +1132,7 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL
log_info("Monitoring bus message stream.");
for (;;) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = sd_bus_process(bus, &m);
if (r < 0)
@ -1182,7 +1182,7 @@ static int capture(sd_bus *bus, char *argv[]) {
}
static int status(sd_bus *bus, char *argv[]) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
pid_t pid;
int r;
@ -1489,8 +1489,8 @@ static int message_append_cmdline(sd_bus_message *m, const char *signature, char
}
static int call(sd_bus *bus, char *argv[]) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL;
int r;
assert(bus);
@ -1576,7 +1576,7 @@ static int call(sd_bus *bus, char *argv[]) {
}
static int get_property(sd_bus *bus, char *argv[]) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
unsigned n;
char **i;
int r;
@ -1590,7 +1590,7 @@ static int get_property(sd_bus *bus, char *argv[]) {
}
STRV_FOREACH(i, argv + 4) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
const char *contents = NULL;
char type;
@ -1634,8 +1634,8 @@ static int get_property(sd_bus *bus, char *argv[]) {
}
static int set_property(sd_bus *bus, char *argv[]) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
unsigned n;
char **p;
int r;
@ -1976,7 +1976,7 @@ static int busctl_main(sd_bus *bus, int argc, char *argv[]) {
}
int main(int argc, char *argv[]) {
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r;
log_parse_environment();

View File

@ -419,7 +419,7 @@ static int hello_callback(sd_bus_message *reply, void *userdata, sd_bus_error *e
}
static int bus_send_hello(sd_bus *bus) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
assert(bus);
@ -1480,7 +1480,9 @@ static void bus_enter_closing(sd_bus *bus) {
}
_public_ sd_bus *sd_bus_ref(sd_bus *bus) {
assert_return(bus, NULL);
if (!bus)
return NULL;
assert_se(REFCNT_INC(bus->n_ref) >= 2);
@ -1734,7 +1736,7 @@ static int dispatch_rqueue(sd_bus *bus, bool hint_priority, int64_t priority, sd
}
static int bus_send_internal(sd_bus *bus, sd_bus_message *_m, uint64_t *cookie, bool hint_sync_call) {
_cleanup_bus_message_unref_ sd_bus_message *m = sd_bus_message_ref(_m);
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = sd_bus_message_ref(_m);
int r;
assert_return(m, -EINVAL);
@ -1882,8 +1884,8 @@ _public_ int sd_bus_call_async(
void *userdata,
uint64_t usec) {
_cleanup_bus_message_unref_ sd_bus_message *m = sd_bus_message_ref(_m);
_cleanup_bus_slot_unref_ sd_bus_slot *s = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = sd_bus_message_ref(_m);
_cleanup_(sd_bus_slot_unrefp) sd_bus_slot *s = NULL;
int r;
assert_return(m, -EINVAL);
@ -1981,7 +1983,7 @@ _public_ int sd_bus_call(
sd_bus_error *error,
sd_bus_message **reply) {
_cleanup_bus_message_unref_ sd_bus_message *m = sd_bus_message_ref(_m);
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = sd_bus_message_ref(_m);
usec_t timeout;
uint64_t cookie;
unsigned i;
@ -2220,8 +2222,8 @@ _public_ int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec) {
}
static int process_timeout(sd_bus *bus) {
_cleanup_bus_error_free_ sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
_cleanup_bus_message_unref_ sd_bus_message* m = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message* m = NULL;
struct reply_callback *c;
sd_bus_slot *slot;
usec_t n;
@ -2302,8 +2304,8 @@ static int process_hello(sd_bus *bus, sd_bus_message *m) {
}
static int process_reply(sd_bus *bus, sd_bus_message *m) {
_cleanup_bus_message_unref_ sd_bus_message *synthetic_reply = NULL;
_cleanup_bus_error_free_ sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *synthetic_reply = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
struct reply_callback *c;
sd_bus_slot *slot;
int r;
@ -2382,7 +2384,7 @@ static int process_reply(sd_bus *bus, sd_bus_message *m) {
}
static int process_filter(sd_bus *bus, sd_bus_message *m) {
_cleanup_bus_error_free_ sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
struct filter_callback *l;
int r;
@ -2448,7 +2450,7 @@ static int process_match(sd_bus *bus, sd_bus_message *m) {
}
static int process_builtin(sd_bus *bus, sd_bus_message *m) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
int r;
assert(bus);
@ -2580,7 +2582,7 @@ static int dispatch_track(sd_bus *bus) {
}
static int process_running(sd_bus *bus, bool hint_priority, int64_t priority, sd_bus_message **ret) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
assert(bus);
@ -2644,7 +2646,7 @@ null_message:
}
static int process_closing(sd_bus *bus, sd_bus_message **ret) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
struct reply_callback *c;
int r;
@ -2653,7 +2655,7 @@ static int process_closing(sd_bus *bus, sd_bus_message **ret) {
c = ordered_hashmap_first(bus->reply_callbacks);
if (c) {
_cleanup_bus_error_free_ sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error_buffer = SD_BUS_ERROR_NULL;
sd_bus_slot *slot;
/* First, fail all outstanding method calls */

View File

@ -46,7 +46,7 @@ static void server(sd_bus *b, size_t *result) {
int r;
for (;;) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
r = sd_bus_process(b, &m);
assert_se(r >= 0);
@ -80,7 +80,7 @@ static void server(sd_bus *b, size_t *result) {
}
static void transaction(sd_bus *b, size_t sz, const char *server_name) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL;
uint8_t *p;
assert_se(sd_bus_message_new_method_call(b, &m, server_name, "/", "benchmark.server", "Work") >= 0);
@ -92,7 +92,7 @@ static void transaction(sd_bus *b, size_t sz, const char *server_name) {
}
static void client_bisect(const char *address, const char *server_name) {
_cleanup_bus_message_unref_ sd_bus_message *x = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *x = NULL;
size_t lsize, rsize, csize;
sd_bus *b;
int r;
@ -166,7 +166,7 @@ static void client_bisect(const char *address, const char *server_name) {
}
static void client_chart(Type type, const char *address, const char *server_name, int fd) {
_cleanup_bus_message_unref_ sd_bus_message *x = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *x = NULL;
size_t csize;
sd_bus *b;
int r;

View File

@ -130,7 +130,7 @@ static int server(sd_bus *bus) {
bool client1_gone = false, client2_gone = false;
while (!client1_gone || !client2_gone) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
pid_t pid = 0;
const char *label = NULL;
@ -261,9 +261,9 @@ fail:
}
static void* client1(void*p) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const char *hello;
int r;
_cleanup_close_pair_ int pp[2] = { -1, -1 };
@ -331,7 +331,7 @@ static void* client1(void*p) {
finish:
if (bus) {
_cleanup_bus_message_unref_ sd_bus_message *q;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *q;
r = sd_bus_message_new_method_call(
bus,
@ -360,9 +360,9 @@ static int quit_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_er
}
static void* client2(void*p) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
bool quit = false;
const char *mid;
int r;
@ -499,7 +499,7 @@ static void* client2(void*p) {
finish:
if (bus) {
_cleanup_bus_message_unref_ sd_bus_message *q;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *q;
r = sd_bus_message_new_method_call(
bus,

View File

@ -29,14 +29,14 @@
#include "refcnt.h"
static void test_bus_new(void) {
_cleanup_bus_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
assert_se(sd_bus_new(&bus) == 0);
printf("after new: refcount %u\n", REFCNT_GET(bus->n_ref));
}
static int test_bus_open(void) {
_cleanup_bus_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
int r;
r = sd_bus_open_system(&bus);
@ -51,7 +51,7 @@ static int test_bus_open(void) {
static void test_bus_new_method_call(void) {
sd_bus *bus = NULL;
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
assert_se(sd_bus_open_system(&bus) >= 0);
@ -65,7 +65,7 @@ static void test_bus_new_method_call(void) {
static void test_bus_new_signal(void) {
sd_bus *bus = NULL;
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
assert_se(sd_bus_open_system(&bus) >= 0);

View File

@ -26,7 +26,7 @@
#include "cgroup-util.h"
int main(int argc, char *argv[]) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL;
int r;
if (cg_unified() == -ENOEXEC) {

View File

@ -27,7 +27,7 @@
#include "errno-list.h"
static void test_error(void) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL, second = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL, second = SD_BUS_ERROR_NULL;
const sd_bus_error const_error = SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_FILE_EXISTS, "const error");
const sd_bus_error temporarily_const_error = {
.name = SD_BUS_ERROR_ACCESS_DENIED,

View File

@ -133,8 +133,8 @@ static void test_bus_gvariant_get_alignment(void) {
}
static void test_marshal(void) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *n = NULL;
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *n = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_free_ void *blob;
size_t sz;
int r;

View File

@ -47,7 +47,7 @@ static void test_one(
_cleanup_close_ int bus_ref = -1;
_cleanup_free_ char *name = NULL, *bus_name = NULL, *address = NULL;
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
sd_bus *a, *b;
int r, found = 0;

View File

@ -34,8 +34,8 @@
int main(int argc, char *argv[]) {
_cleanup_close_ int bus_ref = -1;
_cleanup_free_ char *name = NULL, *bus_name = NULL, *address = NULL, *bname = NULL;
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const char *ua = NULL, *ub = NULL, *the_string = NULL;
sd_bus *a, *b;
int r, pipe_fds[2];

View File

@ -123,7 +123,7 @@ static void test_bus_label_escape(void) {
}
int main(int argc, char *argv[]) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *copy = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *copy = NULL;
int r, boolean;
const char *x, *x2, *y, *z, *a, *b, *c, *d, *a_signature;
uint8_t u, v;
@ -135,7 +135,7 @@ int main(int argc, char *argv[]) {
_cleanup_free_ char *first = NULL, *second = NULL, *third = NULL;
_cleanup_fclose_ FILE *ms = NULL;
size_t first_size = 0, second_size = 0, third_size = 0;
_cleanup_bus_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
double dbl;
uint64_t u64;

View File

@ -90,8 +90,8 @@ int main(int argc, char *argv[]) {
.type = BUS_MATCH_ROOT,
};
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
_cleanup_bus_flush_close_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
enum bus_match_node_type i;
sd_bus_slot slots[19];
int r;

View File

@ -297,9 +297,9 @@ fail:
}
static int client(struct context *c) {
_cleanup_bus_message_unref_ sd_bus_message *reply = NULL;
_cleanup_bus_unref_ sd_bus *bus = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const char *s;
int r;

View File

@ -53,7 +53,7 @@ static int test_proxy_acquired(sd_bus_message *m, void *userdata, sd_bus_error *
}
static void test_proxy_matched(void) {
_cleanup_bus_flush_close_unref_ sd_bus *a = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *a = NULL;
_cleanup_free_ char *matchstr = NULL;
TestProxyMatch match = {};
const char *me;

View File

@ -57,7 +57,7 @@ static void *server(void *p) {
assert_se(sd_bus_start(bus) >= 0);
while (!quit) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL;
r = sd_bus_process(bus, &m);
if (r < 0) {
@ -124,8 +124,8 @@ fail:
}
static int client(struct context *c) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
_cleanup_bus_unref_ sd_bus *bus = NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL, *reply = NULL;
_cleanup_(sd_bus_unrefp) sd_bus *bus = NULL;
sd_bus_error error = SD_BUS_ERROR_NULL;
int r;

View File

@ -59,7 +59,7 @@ struct sd_device_enumerator {
};
_public_ int sd_device_enumerator_new(sd_device_enumerator **ret) {
_cleanup_device_enumerator_unref_ sd_device_enumerator *enumerator = NULL;
_cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *enumerator = NULL;
assert(ret);
@ -487,7 +487,7 @@ static int enumerator_scan_dir_and_add_devices(sd_device_enumerator *enumerator,
return -errno;
FOREACH_DIRENT_ALL(dent, dir, return -errno) {
_cleanup_device_unref_ sd_device *device = NULL;
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
char syspath[strlen(path) + 1 + strlen(dent->d_name) + 1];
dev_t devnum;
int ifindex, initialized, k;
@ -640,7 +640,7 @@ static int enumerator_scan_devices_tag(sd_device_enumerator *enumerator, const c
/* TODO: filter away subsystems? */
FOREACH_DIRENT_ALL(dent, dir, return -errno) {
_cleanup_device_unref_ sd_device *device = NULL;
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
const char *subsystem, *sysname;
int k;
@ -710,7 +710,7 @@ static int enumerator_scan_devices_tags(sd_device_enumerator *enumerator) {
}
static int parent_add_child(sd_device_enumerator *enumerator, const char *path) {
_cleanup_device_unref_ sd_device *device = NULL;
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
const char *subsystem, *sysname;
int r;

View File

@ -553,7 +553,7 @@ static int device_verify(sd_device *device, DeviceAction action, uint64_t seqnum
}
int device_new_from_strv(sd_device **ret, char **strv) {
_cleanup_device_unref_ sd_device *device = NULL;
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
char **key;
const char *major = NULL, *minor = NULL;
DeviceAction action = _DEVICE_ACTION_INVALID;
@ -590,7 +590,7 @@ int device_new_from_strv(sd_device **ret, char **strv) {
}
int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len) {
_cleanup_device_unref_ sd_device *device = NULL;
_cleanup_(sd_device_unrefp) sd_device *device = NULL;
const char *major = NULL, *minor = NULL;
DeviceAction action = _DEVICE_ACTION_INVALID;
uint64_t seqnum;
@ -793,7 +793,7 @@ int device_rename(sd_device *device, const char *name) {
}
int device_shallow_clone(sd_device *old_device, sd_device **new_device) {
_cleanup_device_unref_ sd_device *ret = NULL;
_cleanup_(sd_device_unrefp) sd_device *ret = NULL;
int r;
assert(old_device);
@ -820,7 +820,7 @@ int device_shallow_clone(sd_device *old_device, sd_device **new_device) {
}
int device_clone_with_db(sd_device *old_device, sd_device **new_device) {
_cleanup_device_unref_ sd_device *ret = NULL;
_cleanup_(sd_device_unrefp) sd_device *ret = NULL;
int r;
assert(old_device);
@ -843,7 +843,7 @@ int device_clone_with_db(sd_device *old_device, sd_device **new_device) {
}
int device_new_from_synthetic_event(sd_device **new_device, const char *syspath, const char *action) {
_cleanup_device_unref_ sd_device *ret = NULL;
_cleanup_(sd_device_unrefp) sd_device *ret = NULL;
int r;
assert(new_device);

View File

@ -23,12 +23,6 @@
#include "util.h"
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_device*, sd_device_unref);
#define _cleanup_device_unref_ _cleanup_(sd_device_unrefp)
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_device_enumerator*, sd_device_enumerator_unref);
#define _cleanup_device_enumerator_unref_ _cleanup_(sd_device_enumerator_unrefp)
#define FOREACH_DEVICE_PROPERTY(device, key, value) \
for (key = sd_device_get_property_first(device, &(value)); \
key; \

Some files were not shown because too many files have changed in this diff Show More