diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-04-25 12:31:45 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-04-25 12:31:45 +0200 |
commit | 8e766630f006fcb17ad575bd4f3000e2d2dc890f (patch) | |
tree | 5b80e86c17142add180769d82db29e2627874304 /src/network | |
parent | 0d6f0ea6c1994a5769704d2150ce907a1132a8c8 (diff) | |
download | systemd-8e766630f006fcb17ad575bd4f3000e2d2dc890f.tar.gz |
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.
Diffstat (limited to 'src/network')
28 files changed, 101 insertions, 112 deletions
diff --git a/src/network/netdev/bridge.c b/src/network/netdev/bridge.c index 3a6cf67df9..967c2dfc76 100644 --- a/src/network/netdev/bridge.c +++ b/src/network/netdev/bridge.c @@ -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); diff --git a/src/network/netdev/geneve.c b/src/network/netdev/geneve.c index 0303943981..175acb4cfb 100644 --- a/src/network/netdev/geneve.c +++ b/src/network/netdev/geneve.c @@ -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); diff --git a/src/network/netdev/netdev.c b/src/network/netdev/netdev.c index af426aebd5..a0b2697183 100644 --- a/src/network/netdev/netdev.c +++ b/src/network/netdev/netdev.c @@ -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; diff --git a/src/network/netdev/netdev.h b/src/network/netdev/netdev.h index 7adec38e38..2b01d4190f 100644 --- a/src/network/netdev/netdev.h +++ b/src/network/netdev/netdev.h @@ -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); diff --git a/src/network/networkd-address-label.c b/src/network/networkd-address-label.c index 1e868ec2de..6cdbd82561 100644 --- a/src/network/networkd-address-label.c +++ b/src/network/networkd-address-label.c @@ -17,7 +17,7 @@ #include "socket-util.h" int address_label_new(AddressLabel **ret) { - _cleanup_address_label_free_ AddressLabel *addrlabel = NULL; + _cleanup_(address_label_freep) AddressLabel *addrlabel = NULL; addrlabel = new0(AddressLabel, 1); if (!addrlabel) @@ -47,8 +47,8 @@ void address_label_free(AddressLabel *label) { } static int address_label_new_static(Network *network, const char *filename, unsigned section_line, AddressLabel **ret) { - _cleanup_network_config_section_free_ NetworkConfigSection *n = NULL; - _cleanup_address_label_free_ AddressLabel *label = NULL; + _cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL; + _cleanup_(address_label_freep) AddressLabel *label = NULL; int r; assert(network); @@ -137,7 +137,7 @@ int config_parse_address_label_prefix(const char *unit, void *data, void *userdata) { - _cleanup_address_label_free_ AddressLabel *n = NULL; + _cleanup_(address_label_freep) AddressLabel *n = NULL; Network *network = userdata; int r; @@ -174,7 +174,7 @@ int config_parse_address_label( void *data, void *userdata) { - _cleanup_address_label_free_ AddressLabel *n = NULL; + _cleanup_(address_label_freep) AddressLabel *n = NULL; Network *network = userdata; uint32_t k; int r; diff --git a/src/network/networkd-address-label.h b/src/network/networkd-address-label.h index 7d5e7609c8..f4a805a877 100644 --- a/src/network/networkd-address-label.h +++ b/src/network/networkd-address-label.h @@ -38,7 +38,6 @@ int address_label_new(AddressLabel **ret); void address_label_free(AddressLabel *label); DEFINE_TRIVIAL_CLEANUP_FUNC(AddressLabel*, address_label_free); -#define _cleanup_address_label_free_ _cleanup_(address_label_freep) int address_label_configure(AddressLabel *address, Link *link, sd_netlink_message_handler_t callback, bool update); diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index 727eeda166..b77586959f 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -24,7 +24,7 @@ #define STATIC_ADDRESSES_PER_NETWORK_MAX 1024U int address_new(Address **ret) { - _cleanup_address_free_ Address *address = NULL; + _cleanup_(address_freep) Address *address = NULL; address = new0(Address, 1); if (!address) @@ -41,8 +41,8 @@ int address_new(Address **ret) { } int address_new_static(Network *network, const char *filename, unsigned section_line, Address **ret) { - _cleanup_network_config_section_free_ NetworkConfigSection *n = NULL; - _cleanup_address_free_ Address *address = NULL; + _cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL; + _cleanup_(address_freep) Address *address = NULL; int r; assert(network); @@ -241,7 +241,7 @@ static int address_add_internal(Link *link, Set **addresses, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret) { - _cleanup_address_free_ Address *address = NULL; + _cleanup_(address_freep) Address *address = NULL; int r; assert(link); @@ -471,7 +471,7 @@ int address_remove( static int address_acquire(Link *link, Address *original, Address **ret) { union in_addr_union in_addr = {}; struct in_addr broadcast = {}; - _cleanup_address_free_ Address *na = NULL; + _cleanup_(address_freep) Address *na = NULL; int r; assert(link); @@ -667,7 +667,7 @@ int config_parse_broadcast( void *userdata) { Network *network = userdata; - _cleanup_address_free_ Address *n = NULL; + _cleanup_(address_freep) Address *n = NULL; int r; assert(filename); @@ -709,7 +709,7 @@ int config_parse_address(const char *unit, void *userdata) { Network *network = userdata; - _cleanup_address_free_ Address *n = NULL; + _cleanup_(address_freep) Address *n = NULL; const char *address, *e; union in_addr_union buffer; int r, f; @@ -795,7 +795,7 @@ int config_parse_label( void *data, void *userdata) { - _cleanup_address_free_ Address *n = NULL; + _cleanup_(address_freep) Address *n = NULL; Network *network = userdata; int r; @@ -834,7 +834,7 @@ int config_parse_lifetime(const char *unit, void *data, void *userdata) { Network *network = userdata; - _cleanup_address_free_ Address *n = NULL; + _cleanup_(address_freep) Address *n = NULL; unsigned k; int r; @@ -882,7 +882,7 @@ int config_parse_address_flags(const char *unit, void *data, void *userdata) { Network *network = userdata; - _cleanup_address_free_ Address *n = NULL; + _cleanup_(address_freep) Address *n = NULL; int r; assert(filename); @@ -926,7 +926,7 @@ int config_parse_address_scope(const char *unit, void *data, void *userdata) { Network *network = userdata; - _cleanup_address_free_ Address *n = NULL; + _cleanup_(address_freep) Address *n = NULL; int r; assert(filename); diff --git a/src/network/networkd-address.h b/src/network/networkd-address.h index bc8d068a8d..23ff941770 100644 --- a/src/network/networkd-address.h +++ b/src/network/networkd-address.h @@ -65,7 +65,6 @@ bool address_equal(Address *a1, Address *a2); bool address_is_ready(const Address *a); DEFINE_TRIVIAL_CLEANUP_FUNC(Address*, address_free); -#define _cleanup_address_free_ _cleanup_(address_freep) int config_parse_address(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_broadcast(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index 6bab7647d6..a1d300166b 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -22,7 +22,7 @@ static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(link); @@ -98,7 +98,7 @@ static int link_set_dhcp_routes(Link *link) { } for (i = 0; i < n; i++) { - _cleanup_route_free_ Route *route = NULL; + _cleanup_(route_freep) Route *route = NULL; /* if the DHCP server returns both a Classless Static Routes option and a Static Routes option, the DHCP client MUST ignore the Static Routes option. */ @@ -137,8 +137,8 @@ static int link_set_dhcp_routes(Link *link) { log_link_warning(link, "Classless static routes received from DHCP server: ignoring static-route option and router option"); if (r >= 0 && !classless_route) { - _cleanup_route_free_ Route *route = NULL; - _cleanup_route_free_ Route *route_gw = NULL; + _cleanup_(route_freep) Route *route = NULL; + _cleanup_(route_freep) Route *route_gw = NULL; r = route_new(&route); if (r < 0) @@ -188,7 +188,7 @@ static int link_set_dhcp_routes(Link *link) { } static int dhcp_lease_lost(Link *link) { - _cleanup_address_free_ Address *address = NULL; + _cleanup_(address_freep) Address *address = NULL; struct in_addr addr; struct in_addr netmask; struct in_addr gateway; @@ -207,7 +207,7 @@ static int dhcp_lease_lost(Link *link) { n = sd_dhcp_lease_get_routes(link->dhcp_lease, &routes); if (n >= 0) { for (i = 0; i < n; i++) { - _cleanup_route_free_ Route *route = NULL; + _cleanup_(route_freep) Route *route = NULL; r = route_new(&route); if (r >= 0) { @@ -227,8 +227,8 @@ static int dhcp_lease_lost(Link *link) { if (r >= 0) { r = sd_dhcp_lease_get_router(link->dhcp_lease, &gateway); if (r >= 0) { - _cleanup_route_free_ Route *route_gw = NULL; - _cleanup_route_free_ Route *route = NULL; + _cleanup_(route_freep) Route *route_gw = NULL; + _cleanup_(route_freep) Route *route = NULL; r = route_new(&route_gw); if (r >= 0) { @@ -305,7 +305,7 @@ static int dhcp_lease_lost(Link *link) { static int dhcp4_address_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(link); @@ -331,7 +331,7 @@ static int dhcp4_update_address(Link *link, struct in_addr *address, struct in_addr *netmask, uint32_t lifetime) { - _cleanup_address_free_ Address *addr = NULL; + _cleanup_(address_freep) Address *addr = NULL; unsigned prefixlen; int r; diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c index da38fbc453..a2ccc6e494 100644 --- a/src/network/networkd-dhcp6.c +++ b/src/network/networkd-dhcp6.c @@ -252,7 +252,7 @@ static int dhcp6_lease_pd_prefix_acquired(sd_dhcp6_client *client, Link *link) { static int dhcp6_address_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(link); @@ -284,7 +284,7 @@ static int dhcp6_address_change( uint32_t lifetime_preferred, uint32_t lifetime_valid) { - _cleanup_address_free_ Address *addr = NULL; + _cleanup_(address_freep) Address *addr = NULL; char buffer[INET6_ADDRSTRLEN]; int r; diff --git a/src/network/networkd-fdb.c b/src/network/networkd-fdb.c index c4fb7044e9..2cb014e83d 100644 --- a/src/network/networkd-fdb.c +++ b/src/network/networkd-fdb.c @@ -25,7 +25,7 @@ int fdb_entry_new_static( unsigned section, FdbEntry **ret) { - _cleanup_fdbentry_free_ FdbEntry *fdb_entry = NULL; + _cleanup_(fdb_entry_freep) FdbEntry *fdb_entry = NULL; struct ether_addr *mac_addr = NULL; assert(network); @@ -177,7 +177,7 @@ int config_parse_fdb_hwaddr( void *userdata) { Network *network = userdata; - _cleanup_fdbentry_free_ FdbEntry *fdb_entry = NULL; + _cleanup_(fdb_entry_freep) FdbEntry *fdb_entry = NULL; int r; assert(filename); @@ -223,7 +223,7 @@ int config_parse_fdb_vlan_id( void *userdata) { Network *network = userdata; - _cleanup_fdbentry_free_ FdbEntry *fdb_entry = NULL; + _cleanup_(fdb_entry_freep) FdbEntry *fdb_entry = NULL; int r; assert(filename); diff --git a/src/network/networkd-fdb.h b/src/network/networkd-fdb.h index 5479eb640b..04bf69773a 100644 --- a/src/network/networkd-fdb.h +++ b/src/network/networkd-fdb.h @@ -29,7 +29,6 @@ void fdb_entry_free(FdbEntry *fdb_entry); int fdb_entry_configure(Link *link, FdbEntry *fdb_entry); DEFINE_TRIVIAL_CLEANUP_FUNC(FdbEntry*, fdb_entry_free); -#define _cleanup_fdbentry_free_ _cleanup_(fdb_entry_freep) int config_parse_fdb_hwaddr(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_fdb_vlan_id(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); diff --git a/src/network/networkd-ipv4ll.c b/src/network/networkd-ipv4ll.c index 1586e74289..2f2da8b5ce 100644 --- a/src/network/networkd-ipv4ll.c +++ b/src/network/networkd-ipv4ll.c @@ -14,8 +14,8 @@ #include "networkd-link.h" static int ipv4ll_address_lost(Link *link) { - _cleanup_address_free_ Address *address = NULL; - _cleanup_route_free_ Route *route = NULL; + _cleanup_(address_freep) Address *address = NULL; + _cleanup_(route_freep) Route *route = NULL; struct in_addr addr; int r; @@ -61,7 +61,7 @@ static int ipv4ll_address_lost(Link *link) { } static int ipv4ll_route_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(link); @@ -82,7 +82,7 @@ static int ipv4ll_route_handler(sd_netlink *rtnl, sd_netlink_message *m, void *u } static int ipv4ll_address_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(link); @@ -104,8 +104,8 @@ static int ipv4ll_address_handler(sd_netlink *rtnl, sd_netlink_message *m, void } static int ipv4ll_address_claimed(sd_ipv4ll *ll, Link *link) { - _cleanup_address_free_ Address *ll_addr = NULL; - _cleanup_route_free_ Route *route = NULL; + _cleanup_(address_freep) Address *ll_addr = NULL; + _cleanup_(route_freep) Route *route = NULL; struct in_addr address; int r; diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index e51ea88213..6f5dcb843a 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -404,7 +404,7 @@ static int link_update_flags(Link *link, sd_netlink_message *m) { } static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) { - _cleanup_link_unref_ Link *link = NULL; + _cleanup_(link_unrefp) Link *link = NULL; uint16_t type; const char *ifname, *kind = NULL; int r, ifindex; @@ -807,7 +807,7 @@ static int link_set_routing_policy_rule(Link *link) { } static int route_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(link->route_messages > 0); @@ -866,7 +866,7 @@ static int link_enter_set_routes(Link *link) { } int link_route_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(m); @@ -884,7 +884,7 @@ int link_route_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, void *use } static int address_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(rtnl); @@ -915,7 +915,7 @@ static int address_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userda } static int address_label_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(rtnl); @@ -1217,7 +1217,7 @@ static int link_enter_set_addresses(Link *link) { } int link_address_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(m); @@ -1261,7 +1261,7 @@ static int link_set_proxy_arp(Link *link) { } static int link_set_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; log_link_debug(link, "Set link"); @@ -1277,7 +1277,7 @@ static int link_set_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userd } static int set_mtu_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(m); @@ -1324,7 +1324,7 @@ int link_set_mtu(Link *link, uint32_t mtu) { } static int set_flags_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(m); @@ -1703,7 +1703,7 @@ bool link_has_carrier(Link *link) { } static int link_up_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(link); @@ -1826,7 +1826,7 @@ int link_up(Link *link) { } static int link_down_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(link); @@ -2190,7 +2190,7 @@ static int link_joined(Link *link) { } static int netdev_join_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(link); @@ -2742,7 +2742,7 @@ static int link_configure(Link *link) { static int link_initialized_and_synced(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; Network *network; int r; @@ -3033,7 +3033,7 @@ ipv4ll_address_fail: int link_add(Manager *m, sd_netlink_message *message, Link **ret) { Link *link; - _cleanup_udev_device_unref_ struct udev_device *device = NULL; + _cleanup_(udev_device_unrefp) struct udev_device *device = NULL; char ifindex_str[2 + DECIMAL_STR_MAX(int)]; int r; diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h index a23dec5752..c17ac3f3ce 100644 --- a/src/network/networkd-link.h +++ b/src/network/networkd-link.h @@ -179,7 +179,6 @@ int link_object_find(sd_bus *bus, const char *path, const char *interface, void int link_send_changed(Link *link, const char *property, ...) _sentinel_; DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref); -#define _cleanup_link_unref_ _cleanup_(link_unrefp) /* Macros which append INTERFACE= to the message */ diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index 0d85ba6e72..34c496f552 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -220,7 +220,7 @@ static int manager_udev_process_link(Manager *m, struct udev_device *device) { static int manager_dispatch_link_udev(sd_event_source *source, int fd, uint32_t revents, void *userdata) { Manager *m = userdata; struct udev_monitor *monitor = m->udev_monitor; - _cleanup_udev_device_unref_ struct udev_device *device = NULL; + _cleanup_(udev_device_unrefp) struct udev_device *device = NULL; device = udev_monitor_receive_device(monitor); if (!device) @@ -1376,7 +1376,7 @@ static const struct hash_ops dhcp6_prefixes_hash_ops = { }; int manager_new(Manager **ret, sd_event *event) { - _cleanup_manager_free_ Manager *m = NULL; + _cleanup_(manager_freep) Manager *m = NULL; int r; m = new0(Manager, 1); diff --git a/src/network/networkd-manager.h b/src/network/networkd-manager.h index b1d6585df2..01705f4ae3 100644 --- a/src/network/networkd-manager.h +++ b/src/network/networkd-manager.h @@ -107,4 +107,3 @@ int manager_dhcp6_prefix_remove(Manager *m, struct in6_addr *addr); int manager_dhcp6_prefix_remove_all(Manager *m, Link *link); DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free); -#define _cleanup_manager_free_ _cleanup_(manager_freep) diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 80e8f5891b..63b047e4dd 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -18,7 +18,7 @@ #define NDISC_PREFIX_LFT_MIN 7200U static int ndisc_netlink_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(link); @@ -39,7 +39,7 @@ static int ndisc_netlink_handler(sd_netlink *rtnl, sd_netlink_message *m, void * } static void ndisc_router_process_default(Link *link, sd_ndisc_router *rt) { - _cleanup_route_free_ Route *route = NULL; + _cleanup_(route_freep) Route *route = NULL; struct in6_addr gateway; uint16_t lifetime; unsigned preference; @@ -138,7 +138,7 @@ static void ndisc_router_process_default(Link *link, sd_ndisc_router *rt) { } static void ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *rt) { - _cleanup_address_free_ Address *address = NULL; + _cleanup_(address_freep) Address *address = NULL; Address *existing_address; uint32_t lifetime_valid, lifetime_preferred, lifetime_remaining; usec_t time_now; @@ -236,7 +236,7 @@ static void ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router * } static void ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) { - _cleanup_route_free_ Route *route = NULL; + _cleanup_(route_freep) Route *route = NULL; usec_t time_now; uint32_t lifetime; unsigned prefixlen; @@ -294,7 +294,7 @@ static void ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) } static void ndisc_router_process_route(Link *link, sd_ndisc_router *rt) { - _cleanup_route_free_ Route *route = NULL; + _cleanup_(route_freep) Route *route = NULL; struct in6_addr gateway; uint32_t lifetime; unsigned preference, prefixlen; diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index 17d6a62983..03dfd4e510 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -109,7 +109,7 @@ void network_apply_anonymize_if_set(Network *network) { } static int network_load_one(Manager *manager, const char *filename) { - _cleanup_network_free_ Network *network = NULL; + _cleanup_(network_freep) Network *network = NULL; _cleanup_fclose_ FILE *file = NULL; char *d; const char *dropin_dirname; diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index c34788d620..f58c2d32d3 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -96,7 +96,6 @@ int network_config_section_new(const char *filename, unsigned line, NetworkConfi void network_config_section_free(NetworkConfigSection *network); DEFINE_TRIVIAL_CLEANUP_FUNC(NetworkConfigSection*, network_config_section_free); -#define _cleanup_network_config_section_free_ _cleanup_(network_config_section_freep) typedef struct Manager Manager; @@ -264,7 +263,6 @@ struct Network { void network_free(Network *network); DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_free); -#define _cleanup_network_free_ _cleanup_(network_freep) int network_load(Manager *manager); diff --git a/src/network/networkd-radv.c b/src/network/networkd-radv.c index 1273ed53de..464e636876 100644 --- a/src/network/networkd-radv.c +++ b/src/network/networkd-radv.c @@ -120,8 +120,8 @@ int prefix_new(Prefix **ret) { int prefix_new_static(Network *network, const char *filename, unsigned section_line, Prefix **ret) { - _cleanup_network_config_section_free_ NetworkConfigSection *n = NULL; - _cleanup_prefix_free_ Prefix *prefix = NULL; + _cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL; + _cleanup_(prefix_freep) Prefix *prefix = NULL; int r; assert(network); @@ -177,7 +177,7 @@ int config_parse_prefix(const char *unit, void *userdata) { Network *network = userdata; - _cleanup_prefix_free_ Prefix *p = NULL; + _cleanup_(prefix_freep) Prefix *p = NULL; uint8_t prefixlen = 64; union in_addr_union in6addr; int r; @@ -219,7 +219,7 @@ int config_parse_prefix_flags(const char *unit, void *data, void *userdata) { Network *network = userdata; - _cleanup_prefix_free_ Prefix *p = NULL; + _cleanup_(prefix_freep) Prefix *p = NULL; int r, val; assert(filename); @@ -263,7 +263,7 @@ int config_parse_prefix_lifetime(const char *unit, void *data, void *userdata) { Network *network = userdata; - _cleanup_prefix_free_ Prefix *p = NULL; + _cleanup_(prefix_freep) Prefix *p = NULL; usec_t usec; int r; diff --git a/src/network/networkd-radv.h b/src/network/networkd-radv.h index 362f108f17..1e3be1f924 100644 --- a/src/network/networkd-radv.h +++ b/src/network/networkd-radv.h @@ -27,7 +27,6 @@ int prefix_new_static(Network *network, const char *filename, unsigned section, Prefix **ret); DEFINE_TRIVIAL_CLEANUP_FUNC(Prefix*, prefix_free); -#define _cleanup_prefix_free_ _cleanup_(prefix_freep) int config_parse_router_prefix_delegation(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_router_preference(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index af7009c4c5..3c5127bb88 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -49,7 +49,7 @@ static unsigned routes_max(void) { } int route_new(Route **ret) { - _cleanup_route_free_ Route *route = NULL; + _cleanup_(route_freep) Route *route = NULL; route = new0(Route, 1); if (!route) @@ -69,8 +69,8 @@ int route_new(Route **ret) { } int route_new_static(Network *network, const char *filename, unsigned section_line, Route **ret) { - _cleanup_network_config_section_free_ NetworkConfigSection *n = NULL; - _cleanup_route_free_ Route *route = NULL; + _cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL; + _cleanup_(route_freep) Route *route = NULL; int r; assert(network); @@ -261,7 +261,7 @@ static int route_add_internal( uint32_t table, Route **ret) { - _cleanup_route_free_ Route *route = NULL; + _cleanup_(route_freep) Route *route = NULL; int r; assert(link); @@ -689,7 +689,7 @@ int config_parse_gateway(const char *unit, void *userdata) { Network *network = userdata; - _cleanup_route_free_ Route *n = NULL; + _cleanup_(route_freep) Route *n = NULL; union in_addr_union buffer; int r, f; @@ -734,7 +734,7 @@ int config_parse_preferred_src(const char *unit, void *userdata) { Network *network = userdata; - _cleanup_route_free_ Route *n = NULL; + _cleanup_(route_freep) Route *n = NULL; union in_addr_union buffer; int r, f; @@ -774,7 +774,7 @@ int config_parse_destination(const char *unit, void *userdata) { Network *network = userdata; - _cleanup_route_free_ Route *n = NULL; + _cleanup_(route_freep) Route *n = NULL; union in_addr_union buffer; unsigned char prefixlen; int r; @@ -828,7 +828,7 @@ int config_parse_route_priority(const char *unit, void *data, void *userdata) { Network *network = userdata; - _cleanup_route_free_ Route *n = NULL; + _cleanup_(route_freep) Route *n = NULL; uint32_t k; int r; @@ -866,7 +866,7 @@ int config_parse_route_scope(const char *unit, void *data, void *userdata) { Network *network = userdata; - _cleanup_route_free_ Route *n = NULL; + _cleanup_(route_freep) Route *n = NULL; int r; assert(filename); @@ -905,7 +905,7 @@ int config_parse_route_table(const char *unit, const char *rvalue, void *data, void *userdata) { - _cleanup_route_free_ Route *n = NULL; + _cleanup_(route_freep) Route *n = NULL; Network *network = userdata; uint32_t k; int r; @@ -945,7 +945,7 @@ int config_parse_gateway_onlink(const char *unit, void *data, void *userdata) { Network *network = userdata; - _cleanup_route_free_ Route *n = NULL; + _cleanup_(route_freep) Route *n = NULL; int r; assert(filename); @@ -982,7 +982,7 @@ int config_parse_ipv6_route_preference(const char *unit, void *data, void *userdata) { Network *network = userdata; - _cleanup_route_free_ Route *n = NULL; + _cleanup_(route_freep) Route *n = NULL; int r; r = route_new_static(network, filename, section_line, &n); @@ -1016,7 +1016,7 @@ int config_parse_route_protocol(const char *unit, void *data, void *userdata) { Network *network = userdata; - _cleanup_route_free_ Route *n = NULL; + _cleanup_(route_freep) Route *n = NULL; int r; r = route_new_static(network, filename, section_line, &n); @@ -1053,7 +1053,7 @@ int config_parse_route_type(const char *unit, void *data, void *userdata) { Network *network = userdata; - _cleanup_route_free_ Route *n = NULL; + _cleanup_(route_freep) Route *n = NULL; int r; r = route_new_static(network, filename, section_line, &n); @@ -1088,7 +1088,7 @@ int config_parse_tcp_window(const char *unit, const char *rvalue, void *data, void *userdata) { - _cleanup_route_free_ Route *n = NULL; + _cleanup_(route_freep) Route *n = NULL; Network *network = userdata; uint64_t k; int r; @@ -1134,7 +1134,7 @@ int config_parse_quickack(const char *unit, const char *rvalue, void *data, void *userdata) { - _cleanup_route_free_ Route *n = NULL; + _cleanup_(route_freep) Route *n = NULL; Network *network = userdata; int k, r; diff --git a/src/network/networkd-route.h b/src/network/networkd-route.h index 169476e6a4..cda6d58205 100644 --- a/src/network/networkd-route.h +++ b/src/network/networkd-route.h @@ -60,7 +60,6 @@ void route_update(Route *route, const union in_addr_union *src, unsigned char sr int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata); DEFINE_TRIVIAL_CLEANUP_FUNC(Route*, route_free); -#define _cleanup_route_free_ _cleanup_(route_freep) int config_parse_gateway(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); int config_parse_preferred_src(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata); diff --git a/src/network/networkd-routing-policy-rule.c b/src/network/networkd-routing-policy-rule.c index 0fb79c1deb..0abb8803b7 100644 --- a/src/network/networkd-routing-policy-rule.c +++ b/src/network/networkd-routing-policy-rule.c @@ -238,7 +238,7 @@ static int routing_policy_rule_add_internal(Manager *m, char *oif, RoutingPolicyRule **ret) { - _cleanup_routing_policy_rule_free_ RoutingPolicyRule *rule = NULL; + _cleanup_(routing_policy_rule_freep) RoutingPolicyRule *rule = NULL; int r; assert_return(rules, -EINVAL); @@ -307,7 +307,7 @@ int routing_policy_rule_add_foreign(Manager *m, } static int routing_policy_rule_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(m); @@ -379,8 +379,8 @@ int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *lin } static int routing_policy_rule_new_static(Network *network, const char *filename, unsigned section_line, RoutingPolicyRule **ret) { - _cleanup_routing_policy_rule_free_ RoutingPolicyRule *rule = NULL; - _cleanup_network_config_section_free_ NetworkConfigSection *n = NULL; + _cleanup_(routing_policy_rule_freep) RoutingPolicyRule *rule = NULL; + _cleanup_(network_config_section_freep) NetworkConfigSection *n = NULL; int r; assert(network); @@ -419,7 +419,7 @@ static int routing_policy_rule_new_static(Network *network, const char *filename } int link_routing_policy_rule_handler(sd_netlink *rtnl, sd_netlink_message *m, void *userdata) { - _cleanup_link_unref_ Link *link = userdata; + _cleanup_(link_unrefp) Link *link = userdata; int r; assert(rtnl); @@ -592,7 +592,7 @@ int config_parse_routing_policy_rule_tos( void *data, void *userdata) { - _cleanup_routing_policy_rule_free_ RoutingPolicyRule *n = NULL; + _cleanup_(routing_policy_rule_freep) RoutingPolicyRule *n = NULL; Network *network = userdata; int r; @@ -629,7 +629,7 @@ int config_parse_routing_policy_rule_priority( void *data, void *userdata) { - _cleanup_routing_policy_rule_free_ RoutingPolicyRule *n = NULL; + _cleanup_(routing_policy_rule_freep) RoutingPolicyRule *n = NULL; Network *network = userdata; int r; @@ -666,7 +666,7 @@ int config_parse_routing_policy_rule_table( void *data, void *userdata) { - _cleanup_routing_policy_rule_free_ RoutingPolicyRule *n = NULL; + _cleanup_(routing_policy_rule_freep) RoutingPolicyRule *n = NULL; Network *network = userdata; int r; @@ -703,7 +703,7 @@ int config_parse_routing_policy_rule_fwmark_mask( void *data, void *userdata) { - _cleanup_routing_policy_rule_free_ RoutingPolicyRule *n = NULL; + _cleanup_(routing_policy_rule_freep) RoutingPolicyRule *n = NULL; Network *network = userdata; int r; @@ -740,7 +740,7 @@ int config_parse_routing_policy_rule_prefix( void *data, void *userdata) { - _cleanup_routing_policy_rule_free_ RoutingPolicyRule *n = NULL; + _cleanup_(routing_policy_rule_freep) RoutingPolicyRule *n = NULL; Network *network = userdata; union in_addr_union buffer; uint8_t prefixlen; @@ -793,7 +793,7 @@ int config_parse_routing_policy_rule_device( void *data, void *userdata) { - _cleanup_routing_policy_rule_free_ RoutingPolicyRule *n = NULL; + _cleanup_(routing_policy_rule_freep) RoutingPolicyRule *n = NULL; Network *network = userdata; int r; @@ -940,7 +940,7 @@ int routing_policy_load_rules(const char *state_file, Set **rules) { return r; STRV_FOREACH(i, l) { - _cleanup_routing_policy_rule_free_ RoutingPolicyRule *rule = NULL; + _cleanup_(routing_policy_rule_freep) RoutingPolicyRule *rule = NULL; p = startswith(*i, "RULE="); if (!p) diff --git a/src/network/networkd-routing-policy-rule.h b/src/network/networkd-routing-policy-rule.h index 102dd70586..f176d9a088 100644 --- a/src/network/networkd-routing-policy-rule.h +++ b/src/network/networkd-routing-policy-rule.h @@ -52,7 +52,6 @@ int routing_policy_rule_new(RoutingPolicyRule **ret); void routing_policy_rule_free(RoutingPolicyRule *rule); DEFINE_TRIVIAL_CLEANUP_FUNC(RoutingPolicyRule*, routing_policy_rule_free); -#define _cleanup_routing_policy_rule_free_ _cleanup_(routing_policy_rule_freep) int routing_policy_rule_configure(RoutingPolicyRule *address, Link *link, sd_netlink_message_handler_t callback, bool update); int routing_policy_rule_remove(RoutingPolicyRule *routing_policy_rule, Link *link, sd_netlink_message_handler_t callback); diff --git a/src/network/networkd.c b/src/network/networkd.c index 48bc9820a9..4100b4c219 100644 --- a/src/network/networkd.c +++ b/src/network/networkd.c @@ -16,7 +16,7 @@ int main(int argc, char *argv[]) { sd_event *event = NULL; - _cleanup_manager_free_ Manager *m = NULL; + _cleanup_(manager_freep) Manager *m = NULL; const char *user = "systemd-network"; uid_t uid; gid_t gid; diff --git a/src/network/test-network.c b/src/network/test-network.c index 5ca7550457..3ffc4b95ab 100644 --- a/src/network/test-network.c +++ b/src/network/test-network.c @@ -133,7 +133,7 @@ static void test_network_get(Manager *manager, struct udev_device *loopback) { } static void test_address_equality(void) { - _cleanup_address_free_ Address *a1 = NULL, *a2 = NULL; + _cleanup_(address_freep) Address *a1 = NULL, *a2 = NULL; assert_se(address_new(&a1) >= 0); assert_se(address_new(&a2) >= 0); @@ -223,10 +223,10 @@ static void test_dhcp_hostname_shorten_overlong(void) { } int main(void) { - _cleanup_manager_free_ Manager *manager = NULL; + _cleanup_(manager_freep) Manager *manager = NULL; _cleanup_(sd_event_unrefp) sd_event *event = NULL; - _cleanup_udev_unref_ struct udev *udev = NULL; - _cleanup_udev_device_unref_ struct udev_device *loopback = NULL; + _cleanup_(udev_unrefp) struct udev *udev = NULL; + _cleanup_(udev_device_unrefp) struct udev_device *loopback = NULL; int r; test_deserialize_in_addr(); |