mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
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:
parent
0d6f0ea6c1
commit
8e766630f0
@ -1425,7 +1425,7 @@ static int get_or_set_log_target(int argc, char *argv[], void *userdata) {
|
||||
}
|
||||
|
||||
static int dump_unit_paths(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
int r;
|
||||
char **p;
|
||||
|
||||
|
@ -90,7 +90,7 @@ static bool same_device(struct udev_device *a, struct udev_device *b) {
|
||||
}
|
||||
|
||||
static bool validate_device(struct udev *udev, struct udev_device *device) {
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *enumerate = NULL;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *enumerate = NULL;
|
||||
struct udev_list_entry *item = NULL, *first = NULL;
|
||||
struct udev_device *parent;
|
||||
const char *v, *subsystem;
|
||||
@ -143,7 +143,7 @@ static bool validate_device(struct udev *udev, struct udev_device *device) {
|
||||
|
||||
first = udev_enumerate_get_list_entry(enumerate);
|
||||
udev_list_entry_foreach(item, first) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *other;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *other;
|
||||
struct udev_device *other_parent;
|
||||
const char *other_subsystem;
|
||||
|
||||
@ -276,8 +276,8 @@ static bool shall_clamp(struct udev_device *d) {
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_udev_device_unref_ struct udev_device *device = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *device = NULL;
|
||||
_cleanup_free_ char *escaped_ss = NULL, *escaped_sysname = NULL, *escaped_path_id = NULL;
|
||||
const char *sysname, *path_id, *ss, *saved;
|
||||
unsigned max_brightness;
|
||||
|
@ -15,5 +15,4 @@
|
||||
|
||||
#if HAVE_BLKID
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(blkid_probe, blkid_free_probe);
|
||||
#define _cleanup_blkid_free_probe_ _cleanup_(blkid_free_probep)
|
||||
#endif
|
||||
|
@ -22,6 +22,4 @@ int make_lock_file(const char *p, int operation, LockFile *ret);
|
||||
int make_lock_file_for(const char *p, int operation, LockFile *ret);
|
||||
void release_lock_file(LockFile *f);
|
||||
|
||||
#define _cleanup_release_lock_file_ _cleanup_(release_lock_file)
|
||||
|
||||
#define LOCK_FILE_INIT { .fd = -1, .path = NULL }
|
||||
|
@ -681,7 +681,7 @@ static void device_shutdown(Manager *m) {
|
||||
}
|
||||
|
||||
static void device_enumerate(Manager *m) {
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *e = NULL;
|
||||
struct udev_list_entry *item = NULL, *first = NULL;
|
||||
int r;
|
||||
|
||||
@ -746,7 +746,7 @@ static void device_enumerate(Manager *m) {
|
||||
|
||||
first = udev_enumerate_get_list_entry(e);
|
||||
udev_list_entry_foreach(item, first) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *dev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *dev = NULL;
|
||||
const char *sysfs;
|
||||
|
||||
sysfs = udev_list_entry_get_name(item);
|
||||
@ -772,7 +772,7 @@ fail:
|
||||
}
|
||||
|
||||
static int device_dispatch_io(sd_event_source *source, int fd, uint32_t revents, void *userdata) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *dev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *dev = NULL;
|
||||
Manager *m = userdata;
|
||||
const char *action, *sysfs;
|
||||
int r;
|
||||
@ -873,7 +873,7 @@ static bool device_supported(void) {
|
||||
}
|
||||
|
||||
int device_found_node(Manager *m, const char *node, bool add, DeviceFound found, bool now) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *dev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *dev = NULL;
|
||||
struct stat st;
|
||||
|
||||
assert(m);
|
||||
|
@ -251,7 +251,7 @@ static int swap_verify(Swap *s) {
|
||||
}
|
||||
|
||||
static int swap_load_devnode(Swap *s) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
struct stat st;
|
||||
const char *p;
|
||||
|
||||
@ -425,7 +425,7 @@ fail:
|
||||
}
|
||||
|
||||
static int swap_process_new(Manager *m, const char *device, int prio, bool set_flags) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
struct udev_list_entry *item = NULL, *first = NULL;
|
||||
const char *dn;
|
||||
struct stat st;
|
||||
|
@ -214,9 +214,9 @@ int swap_list_get(const char *swaps, MountPoint **head) {
|
||||
}
|
||||
|
||||
static int loopback_list_get(MountPoint **head) {
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *e = NULL;
|
||||
struct udev_list_entry *item = NULL, *first = NULL;
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
int r;
|
||||
|
||||
assert(head);
|
||||
@ -247,7 +247,7 @@ static int loopback_list_get(MountPoint **head) {
|
||||
|
||||
first = udev_enumerate_get_list_entry(e);
|
||||
udev_list_entry_foreach(item, first) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d;
|
||||
const char *dn;
|
||||
_cleanup_free_ MountPoint *lb = NULL;
|
||||
|
||||
@ -275,9 +275,9 @@ static int loopback_list_get(MountPoint **head) {
|
||||
}
|
||||
|
||||
static int dm_list_get(MountPoint **head) {
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *e = NULL;
|
||||
struct udev_list_entry *item = NULL, *first = NULL;
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
int r;
|
||||
|
||||
assert(head);
|
||||
@ -304,7 +304,7 @@ static int dm_list_get(MountPoint **head) {
|
||||
|
||||
first = udev_enumerate_get_list_entry(e);
|
||||
udev_list_entry_foreach(item, first) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d;
|
||||
dev_t devnum;
|
||||
const char *dn;
|
||||
_cleanup_free_ MountPoint *m = NULL;
|
||||
|
@ -458,8 +458,8 @@ static int add_esp(DissectedPartition *p) {
|
||||
#endif
|
||||
|
||||
static int open_parent(dev_t devnum, int *ret) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
const char *name, *devtype, *node;
|
||||
struct udev_device *parent;
|
||||
dev_t pn;
|
||||
|
@ -32,7 +32,6 @@ Writer* writer_ref(Writer *w);
|
||||
Writer* writer_unref(Writer *w);
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(Writer*, writer_unref);
|
||||
#define _cleanup_writer_unref_ _cleanup_(writer_unrefp)
|
||||
|
||||
int writer_write(Writer *s,
|
||||
struct iovec_wrapper *iovw,
|
||||
|
@ -203,10 +203,9 @@ static int init_writer_hashmap(RemoteServer *s) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_writer(RemoteServer *s, const char *host,
|
||||
Writer **writer) {
|
||||
static int get_writer(RemoteServer *s, const char *host, Writer **writer) {
|
||||
_cleanup_(writer_unrefp) Writer *w = NULL;
|
||||
const void *key;
|
||||
_cleanup_writer_unref_ Writer *w = NULL;
|
||||
int r;
|
||||
|
||||
switch(arg_split_mode) {
|
||||
|
@ -182,8 +182,8 @@ typedef struct BootId {
|
||||
|
||||
static int add_matches_for_device(sd_journal *j, const char *devpath) {
|
||||
int r;
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_udev_device_unref_ struct udev_device *device = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *device = NULL;
|
||||
struct udev_device *d = NULL;
|
||||
struct stat st;
|
||||
|
||||
|
@ -78,13 +78,13 @@ int dhcp_identifier_set_duid_en(struct duid *duid, size_t *len) {
|
||||
int dhcp_identifier_set_iaid(int ifindex, uint8_t *mac, size_t mac_len, void *_id) {
|
||||
/* name is a pointer to memory in the udev_device struct, so must
|
||||
have the same scope */
|
||||
_cleanup_udev_device_unref_ struct udev_device *device = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *device = NULL;
|
||||
const char *name = NULL;
|
||||
uint64_t id;
|
||||
|
||||
if (detect_container() <= 0) {
|
||||
/* not in a container, udev will be around */
|
||||
_cleanup_udev_unref_ struct udev *udev;
|
||||
_cleanup_(udev_unrefp) struct udev *udev;
|
||||
char ifindex_str[2 + DECIMAL_STR_MAX(int)];
|
||||
|
||||
udev = udev_new();
|
||||
|
@ -645,7 +645,6 @@ static void dhcp_request_free(DHCPRequest *req) {
|
||||
}
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(DHCPRequest*, dhcp_request_free);
|
||||
#define _cleanup_dhcp_request_free_ _cleanup_(dhcp_request_freep)
|
||||
|
||||
static int ensure_sane_request(sd_dhcp_server *server, DHCPRequest *req, DHCPMessage *message) {
|
||||
assert(req);
|
||||
@ -698,7 +697,7 @@ static int get_pool_offset(sd_dhcp_server *server, be32_t requested_ip) {
|
||||
|
||||
int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
|
||||
size_t length) {
|
||||
_cleanup_dhcp_request_free_ DHCPRequest *req = NULL;
|
||||
_cleanup_(dhcp_request_freep) DHCPRequest *req = NULL;
|
||||
_cleanup_free_ char *error_message = NULL;
|
||||
DHCPLease *existing_lease;
|
||||
int type, r;
|
||||
|
@ -168,7 +168,7 @@ int devnode_acl_all(struct udev *udev,
|
||||
bool del, uid_t old_uid,
|
||||
bool add, uid_t new_uid) {
|
||||
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *e = NULL;
|
||||
struct udev_list_entry *item = NULL, *first = NULL;
|
||||
_cleanup_set_free_free_ Set *nodes = NULL;
|
||||
_cleanup_closedir_ DIR *dir = NULL;
|
||||
@ -209,7 +209,7 @@ int devnode_acl_all(struct udev *udev,
|
||||
|
||||
first = udev_enumerate_get_list_entry(e);
|
||||
udev_list_entry_foreach(item, first) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
const char *node, *sn;
|
||||
|
||||
d = udev_device_new_from_syspath(udev, udev_list_entry_get_name(item));
|
||||
|
@ -499,7 +499,7 @@ static bool manager_is_docked(Manager *m) {
|
||||
}
|
||||
|
||||
static int manager_count_external_displays(Manager *m) {
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *e = NULL;
|
||||
struct udev_list_entry *item = NULL, *first = NULL;
|
||||
int r;
|
||||
int n = 0;
|
||||
@ -518,7 +518,7 @@ static int manager_count_external_displays(Manager *m) {
|
||||
|
||||
first = udev_enumerate_get_list_entry(e);
|
||||
udev_list_entry_foreach(item, first) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
struct udev_device *p;
|
||||
const char *status, *enabled, *dash, *nn, *i;
|
||||
bool external = false;
|
||||
|
@ -1246,7 +1246,7 @@ static int method_set_user_linger(sd_bus_message *message, void *userdata, sd_bu
|
||||
}
|
||||
|
||||
static int trigger_device(Manager *m, struct udev_device *d) {
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *e = NULL;
|
||||
struct udev_list_entry *first, *item;
|
||||
int r;
|
||||
|
||||
@ -1284,7 +1284,7 @@ static int trigger_device(Manager *m, struct udev_device *d) {
|
||||
}
|
||||
|
||||
static int attach_device(Manager *m, const char *seat, const char *sysfs) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
_cleanup_free_ char *rule = NULL, *file = NULL;
|
||||
const char *id_for_seat;
|
||||
int r;
|
||||
|
@ -193,7 +193,7 @@ static void manager_free(Manager *m) {
|
||||
|
||||
static int manager_enumerate_devices(Manager *m) {
|
||||
struct udev_list_entry *item = NULL, *first = NULL;
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *e = NULL;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
@ -219,7 +219,7 @@ static int manager_enumerate_devices(Manager *m) {
|
||||
|
||||
first = udev_enumerate_get_list_entry(e);
|
||||
udev_list_entry_foreach(item, first) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
int k;
|
||||
|
||||
d = udev_device_new_from_syspath(m->udev, udev_list_entry_get_name(item));
|
||||
@ -235,7 +235,7 @@ static int manager_enumerate_devices(Manager *m) {
|
||||
}
|
||||
|
||||
static int manager_enumerate_buttons(Manager *m) {
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *e = NULL;
|
||||
struct udev_list_entry *item = NULL, *first = NULL;
|
||||
int r;
|
||||
|
||||
@ -268,7 +268,7 @@ static int manager_enumerate_buttons(Manager *m) {
|
||||
|
||||
first = udev_enumerate_get_list_entry(e);
|
||||
udev_list_entry_foreach(item, first) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
int k;
|
||||
|
||||
d = udev_device_new_from_syspath(m->udev, udev_list_entry_get_name(item));
|
||||
@ -591,7 +591,7 @@ static int manager_enumerate_inhibitors(Manager *m) {
|
||||
}
|
||||
|
||||
static int manager_dispatch_seat_udev(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
Manager *m = userdata;
|
||||
|
||||
assert(m);
|
||||
@ -605,7 +605,7 @@ static int manager_dispatch_seat_udev(sd_event_source *s, int fd, uint32_t reven
|
||||
}
|
||||
|
||||
static int manager_dispatch_device_udev(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
Manager *m = userdata;
|
||||
|
||||
assert(m);
|
||||
@ -619,7 +619,7 @@ static int manager_dispatch_device_udev(sd_event_source *s, int fd, uint32_t rev
|
||||
}
|
||||
|
||||
static int manager_dispatch_vcsa_udev(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
Manager *m = userdata;
|
||||
const char *name;
|
||||
|
||||
@ -641,7 +641,7 @@ static int manager_dispatch_vcsa_udev(sd_event_source *s, int fd, uint32_t reven
|
||||
}
|
||||
|
||||
static int manager_dispatch_button_udev(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
Manager *m = userdata;
|
||||
|
||||
assert(m);
|
||||
|
@ -43,7 +43,7 @@ static int show_sysfs_one(
|
||||
max_width = n_columns;
|
||||
|
||||
while (*item) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
struct udev_list_entry *next, *lookahead;
|
||||
const char *sn, *name, *sysfs, *subsystem, *sysname;
|
||||
_cleanup_free_ char *k = NULL, *l = NULL;
|
||||
@ -86,7 +86,7 @@ static int show_sysfs_one(
|
||||
|
||||
if (path_startswith(lookahead_sysfs, sub) &&
|
||||
!path_startswith(lookahead_sysfs, sysfs)) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *lookahead_d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *lookahead_d = NULL;
|
||||
|
||||
lookahead_d = udev_device_new_from_syspath(udev, lookahead_sysfs);
|
||||
if (lookahead_d) {
|
||||
@ -142,8 +142,8 @@ static int show_sysfs_one(
|
||||
}
|
||||
|
||||
int show_sysfs(const char *seat, const char *prefix, unsigned n_columns, OutputFlags flags) {
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *e = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
struct udev_list_entry *first = NULL;
|
||||
int r;
|
||||
|
||||
|
@ -915,8 +915,8 @@ static int stop_mounts(
|
||||
}
|
||||
|
||||
static int umount_by_device(sd_bus *bus, const char *what) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
_cleanup_strv_free_ char **list = NULL;
|
||||
struct stat st;
|
||||
const char *v;
|
||||
@ -1237,8 +1237,8 @@ static int acquire_removable(struct udev_device *d) {
|
||||
}
|
||||
|
||||
static int discover_loop_backing_file(void) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
_cleanup_free_ char *loop_dev = NULL;
|
||||
struct stat st;
|
||||
const char *v;
|
||||
@ -1312,8 +1312,8 @@ static int discover_loop_backing_file(void) {
|
||||
}
|
||||
|
||||
static int discover_device(void) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
struct stat st;
|
||||
const char *v;
|
||||
int r;
|
||||
@ -1406,8 +1406,8 @@ static int list_devices(void) {
|
||||
[COLUMN_UUID] = "UUID"
|
||||
};
|
||||
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *e = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
struct udev_list_entry *item = NULL, *first = NULL;
|
||||
size_t n_allocated = 0, n = 0, i;
|
||||
size_t column_width[_COLUMN_MAX];
|
||||
@ -1440,7 +1440,7 @@ static int list_devices(void) {
|
||||
|
||||
first = udev_enumerate_get_list_entry(e);
|
||||
udev_list_entry_foreach(item, first) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d;
|
||||
struct item *j;
|
||||
|
||||
d = udev_device_new_from_syspath(udev, udev_list_entry_get_name(item));
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 */
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -325,7 +325,7 @@ static int create_bridge(sd_netlink *rtnl, const char *bridge_name) {
|
||||
}
|
||||
|
||||
int setup_bridge(const char *veth_name, const char *bridge_name, bool create) {
|
||||
_cleanup_release_lock_file_ LockFile bridge_lock = LOCK_FILE_INIT;
|
||||
_cleanup_(release_lock_file) LockFile bridge_lock = LOCK_FILE_INIT;
|
||||
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
|
||||
int r, bridge_ifi;
|
||||
unsigned n = 0;
|
||||
@ -366,7 +366,7 @@ int setup_bridge(const char *veth_name, const char *bridge_name, bool create) {
|
||||
}
|
||||
|
||||
int remove_bridge(const char *bridge_name) {
|
||||
_cleanup_release_lock_file_ LockFile bridge_lock = LOCK_FILE_INIT;
|
||||
_cleanup_(release_lock_file) LockFile bridge_lock = LOCK_FILE_INIT;
|
||||
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
|
||||
const char *path;
|
||||
int r;
|
||||
@ -398,7 +398,7 @@ int remove_bridge(const char *bridge_name) {
|
||||
}
|
||||
|
||||
static int parse_interface(struct udev *udev, const char *name) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
char ifi_str[2 + DECIMAL_STR_MAX(int)];
|
||||
int ifi;
|
||||
|
||||
@ -420,7 +420,7 @@ static int parse_interface(struct udev *udev, const char *name) {
|
||||
}
|
||||
|
||||
int move_network_interfaces(pid_t pid, char **ifaces) {
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
|
||||
char **i;
|
||||
int r;
|
||||
@ -463,7 +463,7 @@ int move_network_interfaces(pid_t pid, char **ifaces) {
|
||||
}
|
||||
|
||||
int setup_macvlan(const char *machine_name, pid_t pid, char **ifaces) {
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
|
||||
unsigned idx = 0;
|
||||
char **i;
|
||||
@ -551,7 +551,7 @@ int setup_macvlan(const char *machine_name, pid_t pid, char **ifaces) {
|
||||
}
|
||||
|
||||
int setup_ipvlan(const char *machine_name, pid_t pid, char **ifaces) {
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
_cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL;
|
||||
char **i;
|
||||
int r;
|
||||
|
@ -2878,7 +2878,7 @@ static int uid_shift_pick(uid_t *shift, LockFile *ret_lock_file) {
|
||||
|
||||
for (;;) {
|
||||
char lock_path[STRLEN("/run/systemd/nspawn-uid/") + DECIMAL_STR_MAX(uid_t) + 1];
|
||||
_cleanup_release_lock_file_ LockFile lf = LOCK_FILE_INIT;
|
||||
_cleanup_(release_lock_file) LockFile lf = LOCK_FILE_INIT;
|
||||
|
||||
if (--n_tries <= 0)
|
||||
return -EBUSY;
|
||||
@ -3286,7 +3286,7 @@ static int run(int master,
|
||||
.sa_flags = SA_NOCLDSTOP|SA_RESTART,
|
||||
};
|
||||
|
||||
_cleanup_release_lock_file_ LockFile uid_shift_lock = LOCK_FILE_INIT;
|
||||
_cleanup_(release_lock_file) LockFile uid_shift_lock = LOCK_FILE_INIT;
|
||||
_cleanup_close_ int etc_passwd_lock = -1;
|
||||
_cleanup_close_pair_ int
|
||||
kmsg_socket_pair[2] = { -1, -1 },
|
||||
@ -3791,7 +3791,7 @@ int main(int argc, char *argv[]) {
|
||||
bool secondary = false, remove_directory = false, remove_image = false;
|
||||
pid_t pid = 0;
|
||||
union in_addr_union exposed = {};
|
||||
_cleanup_release_lock_file_ LockFile tree_global_lock = LOCK_FILE_INIT, tree_local_lock = LOCK_FILE_INIT;
|
||||
_cleanup_(release_lock_file) LockFile tree_global_lock = LOCK_FILE_INIT, tree_local_lock = LOCK_FILE_INIT;
|
||||
bool interactive, veth_created = false, remove_tmprootdir = false;
|
||||
char tmprootdir[] = "/tmp/nspawn-root-XXXXXX";
|
||||
_cleanup_(loop_device_unrefp) LoopDevice *loop = NULL;
|
||||
|
@ -97,7 +97,7 @@ static int wait_for_initialized(
|
||||
struct udev_device *device,
|
||||
struct udev_device **ret) {
|
||||
|
||||
_cleanup_udev_monitor_unref_ struct udev_monitor *monitor = NULL;
|
||||
_cleanup_(udev_monitor_unrefp) struct udev_monitor *monitor = NULL;
|
||||
struct udev_device *d;
|
||||
const char *sysname;
|
||||
int watch_fd, r;
|
||||
@ -144,7 +144,7 @@ static int wait_for_initialized(
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *t = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *t = NULL;
|
||||
|
||||
r = fd_wait_for_event(watch_fd, POLLIN, EXIT_USEC);
|
||||
if (r == -EINTR)
|
||||
@ -172,8 +172,8 @@ static int determine_state_file(
|
||||
const struct rfkill_event *event,
|
||||
char **ret) {
|
||||
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_udev_device_unref_ struct udev_device *device = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *device = NULL;
|
||||
const char *path_id, *type;
|
||||
char *state_file;
|
||||
int r;
|
||||
@ -363,7 +363,7 @@ static int save_state_write(struct write_queue_item **write_queue) {
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
LIST_HEAD(write_queue_item, write_queue);
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
_cleanup_close_ int rfkill_fd = -1;
|
||||
bool ready = false;
|
||||
int r, n;
|
||||
|
@ -397,7 +397,7 @@ static int verify_esp(
|
||||
uint64_t *ret_psize,
|
||||
sd_id128_t *ret_uuid) {
|
||||
#if HAVE_BLKID
|
||||
_cleanup_blkid_free_probe_ blkid_probe b = NULL;
|
||||
_cleanup_(blkid_free_probep) blkid_probe b = NULL;
|
||||
char t[DEV_NUM_PATH_MAX];
|
||||
const char *v;
|
||||
#endif
|
||||
|
@ -49,7 +49,7 @@ int probe_filesystem(const char *node, char **ret_fstype) {
|
||||
* different error otherwise. */
|
||||
|
||||
#if HAVE_BLKID
|
||||
_cleanup_blkid_free_probe_ blkid_probe b = NULL;
|
||||
_cleanup_(blkid_free_probep) blkid_probe b = NULL;
|
||||
const char *fstype;
|
||||
int r;
|
||||
|
||||
@ -124,12 +124,12 @@ int dissect_image(
|
||||
|
||||
#if HAVE_BLKID
|
||||
sd_id128_t root_uuid = SD_ID128_NULL, verity_uuid = SD_ID128_NULL;
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *e = NULL;
|
||||
bool is_gpt, is_mbr, generic_rw, multiple_generic = false;
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
_cleanup_(dissected_image_unrefp) DissectedImage *m = NULL;
|
||||
_cleanup_blkid_free_probe_ blkid_probe b = NULL;
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(blkid_free_probep) blkid_probe b = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
_cleanup_free_ char *generic_node = NULL;
|
||||
sd_id128_t generic_uuid = SD_ID128_NULL;
|
||||
const char *pttype = NULL;
|
||||
@ -287,7 +287,7 @@ int dissect_image(
|
||||
n = 0;
|
||||
first = udev_enumerate_get_list_entry(e);
|
||||
udev_list_entry_foreach(item, first) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *q;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *q;
|
||||
dev_t qn;
|
||||
|
||||
q = udev_device_new_from_syspath(udev, udev_list_entry_get_name(item));
|
||||
@ -360,7 +360,7 @@ int dissect_image(
|
||||
|
||||
first = udev_enumerate_get_list_entry(e);
|
||||
udev_list_entry_foreach(item, first) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *q;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *q;
|
||||
unsigned long long pflags;
|
||||
blkid_partition pp;
|
||||
const char *node;
|
||||
|
@ -1992,7 +1992,7 @@ int unit_file_mask(
|
||||
UnitFileChange **changes,
|
||||
unsigned *n_changes) {
|
||||
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
const char *config_path;
|
||||
char **i;
|
||||
int r;
|
||||
@ -2038,7 +2038,7 @@ int unit_file_unmask(
|
||||
UnitFileChange **changes,
|
||||
unsigned *n_changes) {
|
||||
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
_cleanup_set_free_free_ Set *remove_symlinks_to = NULL;
|
||||
_cleanup_strv_free_ char **todo = NULL;
|
||||
size_t n_todo = 0, n_allocated = 0;
|
||||
@ -2132,7 +2132,7 @@ int unit_file_link(
|
||||
UnitFileChange **changes,
|
||||
unsigned *n_changes) {
|
||||
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
_cleanup_strv_free_ char **todo = NULL;
|
||||
size_t n_todo = 0, n_allocated = 0;
|
||||
const char *config_path;
|
||||
@ -2233,7 +2233,7 @@ int unit_file_revert(
|
||||
unsigned *n_changes) {
|
||||
|
||||
_cleanup_set_free_free_ Set *remove_symlinks_to = NULL;
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
_cleanup_strv_free_ char **todo = NULL;
|
||||
size_t n_todo = 0, n_allocated = 0;
|
||||
char **i;
|
||||
@ -2389,7 +2389,7 @@ int unit_file_add_dependency(
|
||||
UnitFileChange **changes,
|
||||
unsigned *n_changes) {
|
||||
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
_cleanup_(install_context_done) InstallContext c = {};
|
||||
UnitFileInstallInfo *i, *target_info;
|
||||
const char *config_path;
|
||||
@ -2463,7 +2463,7 @@ int unit_file_enable(
|
||||
UnitFileChange **changes,
|
||||
unsigned *n_changes) {
|
||||
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
_cleanup_(install_context_done) InstallContext c = {};
|
||||
const char *config_path;
|
||||
UnitFileInstallInfo *i;
|
||||
@ -2509,7 +2509,7 @@ int unit_file_disable(
|
||||
UnitFileChange **changes,
|
||||
unsigned *n_changes) {
|
||||
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
_cleanup_(install_context_done) InstallContext c = {};
|
||||
_cleanup_set_free_free_ Set *remove_symlinks_to = NULL;
|
||||
const char *config_path;
|
||||
@ -2578,7 +2578,7 @@ int unit_file_set_default(
|
||||
UnitFileChange **changes,
|
||||
unsigned *n_changes) {
|
||||
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
_cleanup_(install_context_done) InstallContext c = {};
|
||||
UnitFileInstallInfo *i;
|
||||
const char *new_path;
|
||||
@ -2613,7 +2613,7 @@ int unit_file_get_default(
|
||||
const char *root_dir,
|
||||
char **name) {
|
||||
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
_cleanup_(install_context_done) InstallContext c = {};
|
||||
UnitFileInstallInfo *i;
|
||||
char *n;
|
||||
@ -2737,7 +2737,7 @@ int unit_file_get_state(
|
||||
const char *name,
|
||||
UnitFileState *ret) {
|
||||
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
int r;
|
||||
|
||||
assert(scope >= 0);
|
||||
@ -3020,7 +3020,7 @@ int unit_file_preset(
|
||||
unsigned *n_changes) {
|
||||
|
||||
_cleanup_(install_context_done) InstallContext plus = {}, minus = {};
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
_cleanup_(presets_freep) Presets presets = {};
|
||||
const char *config_path;
|
||||
char **i;
|
||||
@ -3060,7 +3060,7 @@ int unit_file_preset_all(
|
||||
unsigned *n_changes) {
|
||||
|
||||
_cleanup_(install_context_done) InstallContext plus = {}, minus = {};
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
_cleanup_(presets_freep) Presets presets = {};
|
||||
const char *config_path = NULL;
|
||||
char **i;
|
||||
@ -3143,7 +3143,7 @@ int unit_file_get_list(
|
||||
char **states,
|
||||
char **patterns) {
|
||||
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
char **i;
|
||||
int r;
|
||||
|
||||
|
@ -440,7 +440,7 @@ int image_discover(Hashmap *h) {
|
||||
}
|
||||
|
||||
int image_remove(Image *i) {
|
||||
_cleanup_release_lock_file_ LockFile global_lock = LOCK_FILE_INIT, local_lock = LOCK_FILE_INIT;
|
||||
_cleanup_(release_lock_file) LockFile global_lock = LOCK_FILE_INIT, local_lock = LOCK_FILE_INIT;
|
||||
_cleanup_strv_free_ char **settings = NULL;
|
||||
_cleanup_free_ char *roothash = NULL;
|
||||
char **j;
|
||||
@ -531,7 +531,7 @@ static int rename_auxiliary_file(const char *path, const char *new_name, const c
|
||||
}
|
||||
|
||||
int image_rename(Image *i, const char *new_name) {
|
||||
_cleanup_release_lock_file_ LockFile global_lock = LOCK_FILE_INIT, local_lock = LOCK_FILE_INIT, name_lock = LOCK_FILE_INIT;
|
||||
_cleanup_(release_lock_file) LockFile global_lock = LOCK_FILE_INIT, local_lock = LOCK_FILE_INIT, name_lock = LOCK_FILE_INIT;
|
||||
_cleanup_free_ char *new_path = NULL, *nn = NULL, *roothash = NULL;
|
||||
_cleanup_strv_free_ char **settings = NULL;
|
||||
unsigned file_attr = 0;
|
||||
@ -652,7 +652,7 @@ static int clone_auxiliary_file(const char *path, const char *new_name, const ch
|
||||
}
|
||||
|
||||
int image_clone(Image *i, const char *new_name, bool read_only) {
|
||||
_cleanup_release_lock_file_ LockFile name_lock = LOCK_FILE_INIT;
|
||||
_cleanup_(release_lock_file) LockFile name_lock = LOCK_FILE_INIT;
|
||||
_cleanup_strv_free_ char **settings = NULL;
|
||||
_cleanup_free_ char *roothash = NULL;
|
||||
const char *new_path;
|
||||
@ -735,7 +735,7 @@ int image_clone(Image *i, const char *new_name, bool read_only) {
|
||||
}
|
||||
|
||||
int image_read_only(Image *i, bool b) {
|
||||
_cleanup_release_lock_file_ LockFile global_lock = LOCK_FILE_INIT, local_lock = LOCK_FILE_INIT;
|
||||
_cleanup_(release_lock_file) LockFile global_lock = LOCK_FILE_INIT, local_lock = LOCK_FILE_INIT;
|
||||
int r;
|
||||
|
||||
assert(i);
|
||||
@ -906,7 +906,7 @@ int image_set_limit(Image *i, uint64_t referenced_max) {
|
||||
}
|
||||
|
||||
int image_read_metadata(Image *i) {
|
||||
_cleanup_release_lock_file_ LockFile global_lock = LOCK_FILE_INIT, local_lock = LOCK_FILE_INIT;
|
||||
_cleanup_(release_lock_file) LockFile global_lock = LOCK_FILE_INIT, local_lock = LOCK_FILE_INIT;
|
||||
int r;
|
||||
|
||||
assert(i);
|
||||
|
@ -158,7 +158,7 @@ fail:
|
||||
}
|
||||
|
||||
int setup_machine_directory(uint64_t size, sd_bus_error *error) {
|
||||
_cleanup_release_lock_file_ LockFile lock_file = LOCK_FILE_INIT;
|
||||
_cleanup_(release_lock_file) LockFile lock_file = LOCK_FILE_INIT;
|
||||
struct loop_info64 info = {
|
||||
.lo_flags = LO_FLAGS_AUTOCLEAR,
|
||||
};
|
||||
|
@ -69,6 +69,5 @@ void lookup_paths_trim_generator(LookupPaths *p);
|
||||
void lookup_paths_flush_generator(LookupPaths *p);
|
||||
|
||||
void lookup_paths_free(LookupPaths *p);
|
||||
#define _cleanup_lookup_paths_free_ _cleanup_(lookup_paths_free)
|
||||
|
||||
char **generator_binary_paths(UnitFileScope scope);
|
||||
|
@ -20,15 +20,4 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_ctrl_connection*, udev_ctrl_connection_u
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_ctrl_msg*, udev_ctrl_msg_unref);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_monitor*, udev_monitor_unref);
|
||||
|
||||
#define _cleanup_udev_unref_ _cleanup_(udev_unrefp)
|
||||
#define _cleanup_udev_device_unref_ _cleanup_(udev_device_unrefp)
|
||||
#define _cleanup_udev_enumerate_unref_ _cleanup_(udev_enumerate_unrefp)
|
||||
#define _cleanup_udev_event_unref_ _cleanup_(udev_event_unrefp)
|
||||
#define _cleanup_udev_rules_unref_ _cleanup_(udev_rules_unrefp)
|
||||
#define _cleanup_udev_ctrl_unref_ _cleanup_(udev_ctrl_unrefp)
|
||||
#define _cleanup_udev_ctrl_connection_unref_ _cleanup_(udev_ctrl_connection_unrefp)
|
||||
#define _cleanup_udev_ctrl_msg_unref_ _cleanup_(udev_ctrl_msg_unrefp)
|
||||
#define _cleanup_udev_monitor_unref_ _cleanup_(udev_monitor_unrefp)
|
||||
#define _cleanup_udev_list_cleanup_ _cleanup_(udev_list_cleanup)
|
||||
|
||||
int udev_parse_config(void);
|
||||
|
@ -5338,7 +5338,7 @@ static int cat_file(const char *filename, bool newline) {
|
||||
}
|
||||
|
||||
static int cat(int argc, char *argv[], void *userdata) {
|
||||
_cleanup_lookup_paths_free_ LookupPaths lp = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths lp = {};
|
||||
_cleanup_strv_free_ char **names = NULL;
|
||||
char **name;
|
||||
sd_bus *bus;
|
||||
@ -5865,7 +5865,7 @@ static int enable_sysv_units(const char *verb, char **args) {
|
||||
int r = 0;
|
||||
|
||||
#if HAVE_SYSV_COMPAT
|
||||
_cleanup_lookup_paths_free_ LookupPaths paths = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths paths = {};
|
||||
unsigned f = 0;
|
||||
|
||||
/* Processes all SysV units, and reshuffles the array so that afterwards only the native units remain */
|
||||
@ -6189,7 +6189,7 @@ static int enable_unit(int argc, char *argv[], void *userdata) {
|
||||
|
||||
if (STR_IN_SET(verb, "mask", "unmask")) {
|
||||
char **name;
|
||||
_cleanup_lookup_paths_free_ LookupPaths lp = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths lp = {};
|
||||
|
||||
r = lookup_paths_init(&lp, arg_scope, 0, arg_root);
|
||||
if (r < 0)
|
||||
@ -6871,7 +6871,7 @@ static int run_editor(char **paths) {
|
||||
}
|
||||
|
||||
static int find_paths_to_edit(sd_bus *bus, char **names, char ***paths) {
|
||||
_cleanup_lookup_paths_free_ LookupPaths lp = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths lp = {};
|
||||
char **name;
|
||||
int r;
|
||||
|
||||
|
@ -922,7 +922,7 @@ finish:
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
_cleanup_(free_sysvstub_hashmapp) Hashmap *all_services = NULL;
|
||||
_cleanup_lookup_paths_free_ LookupPaths lp = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths lp = {};
|
||||
SysvStub *service;
|
||||
Iterator j;
|
||||
int r;
|
||||
|
@ -91,7 +91,7 @@ static void print_device(struct udev_device *device) {
|
||||
}
|
||||
|
||||
static void test_device(struct udev *udev, const char *syspath) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *device;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *device;
|
||||
|
||||
log_info("looking at device: %s", syspath);
|
||||
device = udev_device_new_from_syspath(udev, syspath);
|
||||
@ -102,7 +102,7 @@ static void test_device(struct udev *udev, const char *syspath) {
|
||||
}
|
||||
|
||||
static void test_device_parents(struct udev *udev, const char *syspath) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *device;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *device;
|
||||
struct udev_device *device_parent;
|
||||
|
||||
log_info("looking at device: %s", syspath);
|
||||
@ -127,7 +127,7 @@ static void test_device_parents(struct udev *udev, const char *syspath) {
|
||||
|
||||
static void test_device_devnum(struct udev *udev) {
|
||||
dev_t devnum = makedev(1, 3);
|
||||
_cleanup_udev_device_unref_ struct udev_device *device;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *device;
|
||||
|
||||
log_info("looking up device: %u:%u", major(devnum), minor(devnum));
|
||||
device = udev_device_new_from_devnum(udev, 'c', devnum);
|
||||
@ -138,7 +138,7 @@ static void test_device_devnum(struct udev *udev) {
|
||||
}
|
||||
|
||||
static void test_device_subsys_name(struct udev *udev, const char *subsys, const char *dev) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *device;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *device;
|
||||
|
||||
log_info("looking up device: '%s:%s'", subsys, dev);
|
||||
device = udev_device_new_from_subsystem_sysname(udev, subsys, dev);
|
||||
@ -170,7 +170,7 @@ static int test_enumerate_print_list(struct udev_enumerate *enumerate) {
|
||||
}
|
||||
|
||||
static void test_monitor(struct udev *udev) {
|
||||
_cleanup_udev_monitor_unref_ struct udev_monitor *udev_monitor;
|
||||
_cleanup_(udev_monitor_unrefp) struct udev_monitor *udev_monitor;
|
||||
_cleanup_close_ int fd_ep;
|
||||
int fd_udev;
|
||||
struct epoll_event ep_udev = {
|
||||
@ -337,7 +337,7 @@ static void test_hwdb(struct udev *udev, const char *modalias) {
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
bool arg_monitor = false;
|
||||
static const struct option options[] = {
|
||||
{ "syspath", required_argument, NULL, 'p' },
|
||||
|
@ -17,8 +17,8 @@
|
||||
static void test_paths(UnitFileScope scope) {
|
||||
char template[] = "/tmp/test-path-lookup.XXXXXXX";
|
||||
|
||||
_cleanup_lookup_paths_free_ LookupPaths lp_without_env = {};
|
||||
_cleanup_lookup_paths_free_ LookupPaths lp_with_env = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths lp_without_env = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths lp_with_env = {};
|
||||
char *systemd_unit_path;
|
||||
|
||||
assert_se(mkdtemp(template));
|
||||
@ -40,7 +40,7 @@ static void test_paths(UnitFileScope scope) {
|
||||
}
|
||||
|
||||
static void test_user_and_global_paths(void) {
|
||||
_cleanup_lookup_paths_free_ LookupPaths lp_global = {}, lp_user = {};
|
||||
_cleanup_(lookup_paths_free) LookupPaths lp_global = {}, lp_user = {};
|
||||
char **u, **g, **p;
|
||||
unsigned k = 0;
|
||||
|
||||
|
@ -56,10 +56,10 @@ static int fake_filesystems(void) {
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_udev_event_unref_ struct udev_event *event = NULL;
|
||||
_cleanup_udev_device_unref_ struct udev_device *dev = NULL;
|
||||
_cleanup_udev_rules_unref_ struct udev_rules *rules = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
_cleanup_(udev_event_unrefp) struct udev_event *event = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *dev = NULL;
|
||||
_cleanup_(udev_rules_unrefp) struct udev_rules *rules = NULL;
|
||||
char syspath[UTIL_PATH_SIZE];
|
||||
const char *devpath;
|
||||
const char *action;
|
||||
|
@ -405,9 +405,8 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
int main(int argc, char *argv[]) {
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
struct hd_driveid id;
|
||||
union {
|
||||
uint8_t byte[512];
|
||||
|
@ -569,9 +569,8 @@ out:
|
||||
return retval;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
_cleanup_udev_unref_ struct udev *udev;
|
||||
int main(int argc, char **argv) {
|
||||
_cleanup_(udev_unrefp) struct udev *udev;
|
||||
int retval = 0;
|
||||
char maj_min_dev[MAX_PATH_LEN];
|
||||
int newargc;
|
||||
|
@ -228,7 +228,7 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t
|
||||
int64_t offset = 0;
|
||||
bool noraid = false;
|
||||
_cleanup_close_ int fd = -1;
|
||||
_cleanup_blkid_free_probe_ blkid_probe pr = NULL;
|
||||
_cleanup_(blkid_free_probep) blkid_probe pr = NULL;
|
||||
const char *data;
|
||||
const char *name;
|
||||
int nvals;
|
||||
|
@ -126,7 +126,7 @@ static int builtin_hwdb(struct udev_device *dev, int argc, char *argv[], bool te
|
||||
const char *device = NULL;
|
||||
const char *subsystem = NULL;
|
||||
const char *prefix = NULL;
|
||||
_cleanup_udev_device_unref_ struct udev_device *srcdev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *srcdev = NULL;
|
||||
|
||||
if (!hwdb)
|
||||
return EXIT_FAILURE;
|
||||
|
@ -296,7 +296,7 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) {
|
||||
size_t l;
|
||||
char *s;
|
||||
const char *attr, *port_name;
|
||||
_cleanup_udev_device_unref_ struct udev_device *pci = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *pci = NULL;
|
||||
struct udev_device *hotplug_slot_dev;
|
||||
char slots[PATH_MAX];
|
||||
_cleanup_closedir_ DIR *dir = NULL;
|
||||
|
@ -104,7 +104,7 @@ static struct udev_device *skip_subsystem(struct udev_device *dev, const char *s
|
||||
static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent, char **path) {
|
||||
struct udev *udev;
|
||||
struct udev_device *targetdev;
|
||||
_cleanup_udev_device_unref_ struct udev_device *fcdev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *fcdev = NULL;
|
||||
const char *port;
|
||||
_cleanup_free_ char *lun = NULL;
|
||||
|
||||
@ -133,7 +133,7 @@ static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent,
|
||||
static struct udev_device *handle_scsi_sas_wide_port(struct udev_device *parent, char **path) {
|
||||
struct udev *udev;
|
||||
struct udev_device *targetdev, *target_parent;
|
||||
_cleanup_udev_device_unref_ struct udev_device *sasdev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *sasdev = NULL;
|
||||
const char *sas_address;
|
||||
_cleanup_free_ char *lun = NULL;
|
||||
|
||||
@ -168,7 +168,7 @@ static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **pa
|
||||
{
|
||||
struct udev *udev;
|
||||
struct udev_device *targetdev, *target_parent, *port, *expander;
|
||||
_cleanup_udev_device_unref_ struct udev_device
|
||||
_cleanup_(udev_device_unrefp) struct udev_device
|
||||
*target_sasdev = NULL, *expander_sasdev = NULL, *port_sasdev = NULL;
|
||||
const char *sas_address = NULL;
|
||||
const char *phy_id;
|
||||
@ -244,7 +244,7 @@ static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **pa
|
||||
static struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char **path) {
|
||||
struct udev *udev;
|
||||
struct udev_device *transportdev;
|
||||
_cleanup_udev_device_unref_ struct udev_device
|
||||
_cleanup_(udev_device_unrefp) struct udev_device
|
||||
*sessiondev = NULL, *conndev = NULL;
|
||||
const char *target, *connname, *addr, *port;
|
||||
_cleanup_free_ char *lun = NULL;
|
||||
@ -291,7 +291,7 @@ static struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char **
|
||||
static struct udev_device *handle_scsi_ata(struct udev_device *parent, char **path) {
|
||||
struct udev *udev;
|
||||
struct udev_device *targetdev, *target_parent;
|
||||
_cleanup_udev_device_unref_ struct udev_device *atadev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *atadev = NULL;
|
||||
const char *port_no;
|
||||
|
||||
assert(parent);
|
||||
|
@ -44,7 +44,7 @@ static void print_help(void) {
|
||||
}
|
||||
|
||||
static int adm_control(struct udev *udev, int argc, char *argv[]) {
|
||||
_cleanup_udev_ctrl_unref_ struct udev_ctrl *uctrl = NULL;
|
||||
_cleanup_(udev_ctrl_unrefp) struct udev_ctrl *uctrl = NULL;
|
||||
int timeout = 60;
|
||||
int rc = 1, c;
|
||||
|
||||
|
@ -173,7 +173,7 @@ static int stat_device(const char *name, bool export, const char *prefix) {
|
||||
}
|
||||
|
||||
static int export_devices(struct udev *udev) {
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *udev_enumerate;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *udev_enumerate;
|
||||
struct udev_list_entry *list_entry;
|
||||
|
||||
udev_enumerate = udev_enumerate_new(udev);
|
||||
@ -182,7 +182,7 @@ static int export_devices(struct udev *udev) {
|
||||
|
||||
udev_enumerate_scan_devices(udev_enumerate);
|
||||
udev_list_entry_foreach(list_entry, udev_enumerate_get_list_entry(udev_enumerate)) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *device;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *device;
|
||||
|
||||
device = udev_device_new_from_syspath(udev, udev_list_entry_get_name(list_entry));
|
||||
if (device != NULL)
|
||||
@ -272,7 +272,7 @@ static void help(void) {
|
||||
}
|
||||
|
||||
static int uinfo(struct udev *udev, int argc, char *argv[]) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *device = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *device = NULL;
|
||||
bool root = 0;
|
||||
bool export = 0;
|
||||
const char *export_prefix = NULL;
|
||||
|
@ -79,10 +79,10 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[]) {
|
||||
bool prop = false;
|
||||
bool print_kernel = false;
|
||||
bool print_udev = false;
|
||||
_cleanup_udev_list_cleanup_ struct udev_list subsystem_match_list;
|
||||
_cleanup_udev_list_cleanup_ struct udev_list tag_match_list;
|
||||
_cleanup_udev_monitor_unref_ struct udev_monitor *udev_monitor = NULL;
|
||||
_cleanup_udev_monitor_unref_ struct udev_monitor *kernel_monitor = NULL;
|
||||
_cleanup_(udev_list_cleanup) struct udev_list subsystem_match_list;
|
||||
_cleanup_(udev_list_cleanup) struct udev_list tag_match_list;
|
||||
_cleanup_(udev_monitor_unrefp) struct udev_monitor *udev_monitor = NULL;
|
||||
_cleanup_(udev_monitor_unrefp) struct udev_monitor *kernel_monitor = NULL;
|
||||
_cleanup_close_ int fd_ep = -1;
|
||||
int fd_kernel = -1, fd_udev = -1;
|
||||
struct epoll_event ep_kernel, ep_udev;
|
||||
|
@ -48,9 +48,9 @@ static int adm_test(struct udev *udev, int argc, char *argv[]) {
|
||||
const char *action = "add";
|
||||
const char *syspath = NULL;
|
||||
struct udev_list_entry *entry;
|
||||
_cleanup_udev_rules_unref_ struct udev_rules *rules = NULL;
|
||||
_cleanup_udev_device_unref_ struct udev_device *dev = NULL;
|
||||
_cleanup_udev_event_unref_ struct udev_event *event = NULL;
|
||||
_cleanup_(udev_rules_unrefp) struct udev_rules *rules = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *dev = NULL;
|
||||
_cleanup_(udev_event_unrefp) struct udev_event *event = NULL;
|
||||
sigset_t mask, sigmask_orig;
|
||||
int rc = 0, c;
|
||||
|
||||
|
@ -134,8 +134,8 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) {
|
||||
TYPE_SUBSYSTEMS,
|
||||
} device_type = TYPE_DEVICES;
|
||||
const char *action = "change";
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *udev_enumerate = NULL;
|
||||
_cleanup_udev_monitor_unref_ struct udev_monitor *udev_monitor = NULL;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *udev_enumerate = NULL;
|
||||
_cleanup_(udev_monitor_unrefp) struct udev_monitor *udev_monitor = NULL;
|
||||
_cleanup_close_ int fd_ep = -1;
|
||||
int fd_udev = -1;
|
||||
struct epoll_event ep_udev;
|
||||
@ -230,7 +230,7 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) {
|
||||
}
|
||||
break;
|
||||
case 'b': {
|
||||
_cleanup_udev_device_unref_ struct udev_device *dev;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *dev;
|
||||
|
||||
dev = find_device(udev, optarg, "/sys");
|
||||
if (!dev) {
|
||||
@ -250,7 +250,7 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) {
|
||||
break;
|
||||
|
||||
case ARG_NAME: {
|
||||
_cleanup_udev_device_unref_ struct udev_device *dev;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *dev;
|
||||
|
||||
dev = find_device(udev, optarg, "/dev/");
|
||||
if (!dev) {
|
||||
@ -280,7 +280,7 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
for (; optind < argc; optind++) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *dev;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *dev;
|
||||
|
||||
dev = find_device(udev, argv[optind], NULL);
|
||||
if (!dev) {
|
||||
@ -355,7 +355,7 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[]) {
|
||||
|
||||
for (i = 0; i < fdcount; i++) {
|
||||
if (ev[i].data.fd == fd_udev && ev[i].events & EPOLLIN) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *device;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *device;
|
||||
const char *syspath = NULL;
|
||||
|
||||
device = udev_monitor_receive_device(udev_monitor);
|
||||
|
@ -326,7 +326,7 @@ static int worker_send_message(int fd) {
|
||||
|
||||
static void worker_spawn(Manager *manager, struct event *event) {
|
||||
struct udev *udev = event->udev;
|
||||
_cleanup_udev_monitor_unref_ struct udev_monitor *worker_monitor = NULL;
|
||||
_cleanup_(udev_monitor_unrefp) struct udev_monitor *worker_monitor = NULL;
|
||||
pid_t pid;
|
||||
int r = 0;
|
||||
|
||||
@ -921,8 +921,8 @@ static int on_uevent(sd_event_source *s, int fd, uint32_t revents, void *userdat
|
||||
/* receive the udevd message from userspace */
|
||||
static int on_ctrl_msg(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
|
||||
Manager *manager = userdata;
|
||||
_cleanup_udev_ctrl_connection_unref_ struct udev_ctrl_connection *ctrl_conn = NULL;
|
||||
_cleanup_udev_ctrl_msg_unref_ struct udev_ctrl_msg *ctrl_msg = NULL;
|
||||
_cleanup_(udev_ctrl_connection_unrefp) struct udev_ctrl_connection *ctrl_conn = NULL;
|
||||
_cleanup_(udev_ctrl_msg_unrefp) struct udev_ctrl_msg *ctrl_msg = NULL;
|
||||
const char *str;
|
||||
int i;
|
||||
|
||||
@ -1019,7 +1019,7 @@ static int synthesize_change(struct udev_device *dev) {
|
||||
bool has_partitions = false;
|
||||
int fd;
|
||||
struct udev *udev = udev_device_get_udev(dev);
|
||||
_cleanup_udev_enumerate_unref_ struct udev_enumerate *e = NULL;
|
||||
_cleanup_(udev_enumerate_unrefp) struct udev_enumerate *e = NULL;
|
||||
struct udev_list_entry *item;
|
||||
|
||||
/*
|
||||
@ -1057,7 +1057,7 @@ static int synthesize_change(struct udev_device *dev) {
|
||||
return r;
|
||||
|
||||
udev_list_entry_foreach(item, udev_enumerate_get_list_entry(e)) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
|
||||
d = udev_device_new_from_syspath(udev, udev_list_entry_get_name(item));
|
||||
if (!d)
|
||||
@ -1087,7 +1087,7 @@ static int synthesize_change(struct udev_device *dev) {
|
||||
write_string_file(filename, "change", WRITE_STRING_FILE_CREATE);
|
||||
|
||||
udev_list_entry_foreach(item, udev_enumerate_get_list_entry(e)) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *d = NULL;
|
||||
|
||||
d = udev_device_new_from_syspath(udev, udev_list_entry_get_name(item));
|
||||
if (!d)
|
||||
@ -1129,7 +1129,7 @@ static int on_inotify(sd_event_source *s, int fd, uint32_t revents, void *userda
|
||||
}
|
||||
|
||||
FOREACH_INOTIFY_EVENT(e, buffer, l) {
|
||||
_cleanup_udev_device_unref_ struct udev_device *dev = NULL;
|
||||
_cleanup_(udev_device_unrefp) struct udev_device *dev = NULL;
|
||||
|
||||
dev = udev_watch_lookup(manager->udev, e->wd);
|
||||
if (!dev)
|
||||
@ -1256,7 +1256,7 @@ static int on_post(sd_event_source *s, void *userdata) {
|
||||
}
|
||||
|
||||
static int listen_fds(int *rctrl, int *rnetlink) {
|
||||
_cleanup_udev_unref_ struct udev *udev = NULL;
|
||||
_cleanup_(udev_unrefp) struct udev *udev = NULL;
|
||||
int ctrl_fd = -1, netlink_fd = -1;
|
||||
int fd, n, r;
|
||||
|
||||
@ -1286,7 +1286,7 @@ static int listen_fds(int *rctrl, int *rnetlink) {
|
||||
}
|
||||
|
||||
if (ctrl_fd < 0) {
|
||||
_cleanup_udev_ctrl_unref_ struct udev_ctrl *ctrl = NULL;
|
||||
_cleanup_(udev_ctrl_unrefp) struct udev_ctrl *ctrl = NULL;
|
||||
|
||||
udev = udev_new();
|
||||
if (!udev)
|
||||
@ -1310,7 +1310,7 @@ static int listen_fds(int *rctrl, int *rnetlink) {
|
||||
}
|
||||
|
||||
if (netlink_fd < 0) {
|
||||
_cleanup_udev_monitor_unref_ struct udev_monitor *monitor = NULL;
|
||||
_cleanup_(udev_monitor_unrefp) struct udev_monitor *monitor = NULL;
|
||||
|
||||
if (!udev) {
|
||||
udev = udev_new();
|
||||
|
Loading…
Reference in New Issue
Block a user