tree-wide: drop redundant _cleanup_ macros (#8810)

This drops a good number of type-specific _cleanup_ macros, and patches
all users to just use the generic ones.

In most recent code we abstained from defining type-specific macros, and
this basically removes all those added already, with the exception of
the really low-level ones.

Having explicit macros for this is not too useful, as the expression
without the extra macro is generally just 2ch wider. We should generally
emphesize generic code, unless there are really good reasons for
specific code, hence let's follow this in this case too.

Note that _cleanup_free_ and similar really low-level, libc'ish, Linux
API'ish macros continue to be defined, only the really high-level OO
ones are dropped. From now on this should really be the rule: for really
low-level stuff, such as memory allocation, fd handling and so one, go
ahead and define explicit per-type macros, but for high-level, specific
program code, just use the generic _cleanup_() macro directly, in order
to keep things simple and as readable as possible for the uninitiated.

Note that before this patch some of the APIs (notable libudev ones) were
already used with the high-level macros at some places and with the
generic _cleanup_ macro at others. With this patch we hence unify on the
latter.
This commit is contained in:
Lennart Poettering
2018-04-25 12:31:45 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent 0d6f0ea6c1
commit 8e766630f0
74 changed files with 252 additions and 283 deletions
+1 -1
View File
@@ -16,7 +16,7 @@
/* callback for brige netdev's parameter set */
static int netdev_bridge_set_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
_cleanup_netdev_unref_ NetDev *netdev = userdata;
_cleanup_(netdev_unrefp) NetDev *netdev = userdata;
int r;
assert(netdev);
+1 -1
View File
@@ -23,7 +23,7 @@
/* callback for geneve netdev's created without a backing Link */
static int geneve_netdev_create_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
_cleanup_netdev_unref_ NetDev *netdev = userdata;
_cleanup_(netdev_unrefp) NetDev *netdev = userdata;
int r;
assert(netdev->state != _NETDEV_STATE_INVALID);
+2 -2
View File
@@ -285,7 +285,7 @@ static int netdev_enter_ready(NetDev *netdev) {
/* callback for netdev's created without a backing Link */
static int netdev_create_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) {
_cleanup_netdev_unref_ NetDev *netdev = userdata;
_cleanup_(netdev_unrefp) NetDev *netdev = userdata;
int r;
assert(netdev->state != _NETDEV_STATE_INVALID);
@@ -599,7 +599,7 @@ int netdev_join(NetDev *netdev, Link *link, sd_netlink_message_handler_t callbac
}
static int netdev_load_one(Manager *manager, const char *filename) {
_cleanup_netdev_unref_ NetDev *netdev_raw = NULL, *netdev = NULL;
_cleanup_(netdev_unrefp) NetDev *netdev_raw = NULL, *netdev = NULL;
_cleanup_fclose_ FILE *file = NULL;
const char *dropin_dirname;
bool independent = false;
-1
View File
@@ -156,7 +156,6 @@ NetDev *netdev_unref(NetDev *netdev);
NetDev *netdev_ref(NetDev *netdev);
DEFINE_TRIVIAL_CLEANUP_FUNC(NetDev*, netdev_unref);
#define _cleanup_netdev_unref_ _cleanup_(netdev_unrefp)
int netdev_get(Manager *manager, const char *name, NetDev **ret);
int netdev_set_ifindex(NetDev *netdev, sd_netlink_message *newlink);