summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-10-25 07:04:59 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-10-27 07:03:39 +0900
commitc1118ceba4886e32d89e299a0a8501d953a9918c (patch)
tree95e3cc13e0c18ca3baf049e33d1269a143ee5f62
parentd7371971546e843efd5dea059f246bfbb8eeee70 (diff)
downloadsystemd-c1118ceba4886e32d89e299a0a8501d953a9918c.tar.gz
udev-event: rename udev_event_unref() to udev_event_free()
As struct udev_event does not have a reference counter.
-rw-r--r--src/test/test-udev.c2
-rw-r--r--src/udev/udev-event.c10
-rw-r--r--src/udev/udev.h4
-rw-r--r--src/udev/udevadm-test.c2
-rw-r--r--src/udev/udevd.c4
5 files changed, 11 insertions, 11 deletions
diff --git a/src/test/test-udev.c b/src/test/test-udev.c
index 2c67e13833..1285117c32 100644
--- a/src/test/test-udev.c
+++ b/src/test/test-udev.c
@@ -52,7 +52,7 @@ static int fake_filesystems(void) {
}
int main(int argc, char *argv[]) {
- _cleanup_(udev_event_unrefp) struct udev_event *event = NULL;
+ _cleanup_(udev_event_freep) struct udev_event *event = NULL;
_cleanup_(udev_device_unrefp) struct udev_device *dev = NULL;
_cleanup_(udev_rules_unrefp) struct udev_rules *rules = NULL;
const char *devpath, *action;
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 4dcfe87cff..e29486fe18 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -58,11 +58,12 @@ struct udev_event *udev_event_new(struct udev_device *dev) {
return event;
}
-void udev_event_unref(struct udev_event *event) {
+struct udev_event *udev_event_free(struct udev_event *event) {
void *p;
- if (event == NULL)
- return;
+ if (!event)
+ return NULL;
+
sd_netlink_unref(event->rtnl);
while ((p = hashmap_steal_first_key(event->run_list)))
free(p);
@@ -70,7 +71,8 @@ void udev_event_unref(struct udev_event *event) {
hashmap_free_free_free(event->seclabel_list);
free(event->program_result);
free(event->name);
- free(event);
+
+ return mfree(event);
}
enum subst_type {
diff --git a/src/udev/udev.h b/src/udev/udev.h
index c9250edd9a..ec1662d700 100644
--- a/src/udev/udev.h
+++ b/src/udev/udev.h
@@ -61,7 +61,7 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules);
/* udev-event.c */
struct udev_event *udev_event_new(struct udev_device *dev);
-void udev_event_unref(struct udev_event *event);
+struct udev_event *udev_event_free(struct udev_event *event);
size_t udev_event_apply_format(struct udev_event *event,
const char *src, char *dest, size_t size,
bool replace_whitespace);
@@ -79,5 +79,5 @@ void udev_event_execute_rules(struct udev_event *event,
void udev_event_execute_run(struct udev_event *event, usec_t timeout_usec, usec_t timeout_warn_usec);
/* Cleanup functions */
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_event*, udev_event_unref);
+DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_event*, udev_event_free);
DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_rules*, udev_rules_unref);
diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c
index ea6471b837..20f713d738 100644
--- a/src/udev/udevadm-test.c
+++ b/src/udev/udevadm-test.c
@@ -89,7 +89,7 @@ static int parse_argv(int argc, char *argv[]) {
int test_main(int argc, char *argv[], void *userdata) {
_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;
+ _cleanup_(udev_event_freep) struct udev_event *event = NULL;
struct udev_list_entry *entry;
sigset_t mask, sigmask_orig;
const char *cmd;
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 64f7f1ff2d..7ec30b92c3 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -398,7 +398,7 @@ static void worker_spawn(Manager *manager, struct event *event) {
write_string_file("/proc/self/oom_score_adj", "0", 0);
for (;;) {
- struct udev_event *udev_event;
+ _cleanup_(udev_event_freep) struct udev_event *udev_event = NULL;
int fd_lock = -1;
assert(dev);
@@ -477,8 +477,6 @@ skip:
udev_device_unref(dev);
dev = NULL;
- udev_event_unref(udev_event);
-
/* wait for more device messages from main udevd, or term signal */
while (dev == NULL) {
struct epoll_event ev[4];