summaryrefslogtreecommitdiffstats
path: root/src/udev/udevadm-trigger.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-04-29 08:47:51 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-05-06 16:54:06 +0200
commitbe32732168e07b7d52ec77fa67cf93a80a9a8293 (patch)
tree0feb0a006050702078fd41b5fea2eee9c4d00b08 /src/udev/udevadm-trigger.c
parentresolve: fix type of parameter and update man page (diff)
downloadsystemd-be32732168e07b7d52ec77fa67cf93a80a9a8293.tar.xz
systemd-be32732168e07b7d52ec77fa67cf93a80a9a8293.zip
basic/set: let set_put_strdup() create the set with string hash ops
If we're using a set with _put_strdup(), most of the time we want to use string hash ops on the set, and free the strings when done. This defines the appropriate a new string_hash_ops_free structure to automatically free the keys when removing the set, and makes set_put_strdup() and set_put_strdupv() instantiate the set with those hash ops. hashmap_put_strdup() was already doing something similar. (It is OK to instantiate the set earlier, possibly with a different hash ops structure. set_put_strdup() will then use the existing set. It is also OK to call set_free_free() instead of set_free() on a set with string_hash_ops_free, the effect is the same, we're just overriding the override of the cleanup function.) No functional change intended.
Diffstat (limited to 'src/udev/udevadm-trigger.c')
-rw-r--r--src/udev/udevadm-trigger.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c
index 60c68b5029..39113d2fa2 100644
--- a/src/udev/udevadm-trigger.c
+++ b/src/udev/udevadm-trigger.c
@@ -23,7 +23,7 @@
static bool arg_verbose = false;
static bool arg_dry_run = false;
-static int exec_list(sd_device_enumerator *e, const char *action, Set *settle_set) {
+static int exec_list(sd_device_enumerator *e, const char *action, Set **settle_set) {
sd_device *d;
int r, ret = 0;
@@ -172,7 +172,7 @@ int trigger_main(int argc, char *argv[], void *userdata) {
_cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL;
_cleanup_(sd_device_monitor_unrefp) sd_device_monitor *m = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
- _cleanup_set_free_free_ Set *settle_set = NULL;
+ _cleanup_set_free_ Set *settle_set = NULL;
usec_t ping_timeout_usec = 5 * USEC_PER_SEC;
bool settle = false, ping = false;
int c, r;
@@ -342,7 +342,7 @@ int trigger_main(int argc, char *argv[], void *userdata) {
}
if (settle) {
- settle_set = set_new(&string_hash_ops);
+ settle_set = set_new(&string_hash_ops_free);
if (!settle_set)
return log_oom();
@@ -377,7 +377,8 @@ int trigger_main(int argc, char *argv[], void *userdata) {
default:
assert_not_reached("Unknown device type");
}
- r = exec_list(e, action, settle_set);
+
+ r = exec_list(e, action, settle ? &settle_set : NULL);
if (r < 0)
return r;