summaryrefslogtreecommitdiffstats
path: root/src/libsystemd/sd-device
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-04-29 09:01:18 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-05-06 16:55:50 +0200
commitc73bb51364457f049082eb84447755e53892f542 (patch)
tree123fa8f5d64015c2f47df5f5a67953b65a84d608 /src/libsystemd/sd-device
parenttest-set: make test-set not link to libshared and test test_set_put_strdup*() (diff)
downloadsystemd-c73bb51364457f049082eb84447755e53892f542.tar.xz
systemd-c73bb51364457f049082eb84447755e53892f542.zip
sd-device: use string hash ops in device enumerator
There should be no functional change, except that when the same string is added more than once, we skip the duplicate entries.
Diffstat (limited to 'src/libsystemd/sd-device')
-rw-r--r--src/libsystemd/sd-device/device-enumerator.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c
index cd3d75c517..d6ceb2aff3 100644
--- a/src/libsystemd/sd-device/device-enumerator.c
+++ b/src/libsystemd/sd-device/device-enumerator.c
@@ -71,14 +71,14 @@ static sd_device_enumerator *device_enumerator_free(sd_device_enumerator *enumer
sd_device_unref(enumerator->devices[i]);
free(enumerator->devices);
- set_free_free(enumerator->match_subsystem);
- set_free_free(enumerator->nomatch_subsystem);
+ set_free(enumerator->match_subsystem);
+ set_free(enumerator->nomatch_subsystem);
hashmap_free_free_free(enumerator->match_sysattr);
hashmap_free_free_free(enumerator->nomatch_sysattr);
hashmap_free_free_free(enumerator->match_property);
- set_free_free(enumerator->match_sysname);
- set_free_free(enumerator->match_tag);
- set_free_free(enumerator->match_parent);
+ set_free(enumerator->match_sysname);
+ set_free(enumerator->match_tag);
+ set_free(enumerator->match_parent);
return mfree(enumerator);
}
@@ -97,10 +97,6 @@ _public_ int sd_device_enumerator_add_match_subsystem(sd_device_enumerator *enum
else
set = &enumerator->nomatch_subsystem;
- r = set_ensure_allocated(set, NULL);
- if (r < 0)
- return r;
-
r = set_put_strdup(set, subsystem);
if (r < 0)
return r;
@@ -188,10 +184,6 @@ _public_ int sd_device_enumerator_add_match_sysname(sd_device_enumerator *enumer
assert_return(enumerator, -EINVAL);
assert_return(sysname, -EINVAL);
- r = set_ensure_allocated(&enumerator->match_sysname, NULL);
- if (r < 0)
- return r;
-
r = set_put_strdup(&enumerator->match_sysname, sysname);
if (r < 0)
return r;
@@ -207,10 +199,6 @@ _public_ int sd_device_enumerator_add_match_tag(sd_device_enumerator *enumerator
assert_return(enumerator, -EINVAL);
assert_return(tag, -EINVAL);
- r = set_ensure_allocated(&enumerator->match_tag, NULL);
- if (r < 0)
- return r;
-
r = set_put_strdup(&enumerator->match_tag, tag);
if (r < 0)
return r;
@@ -224,7 +212,7 @@ static void device_enumerator_clear_match_parent(sd_device_enumerator *enumerato
if (!enumerator)
return;
- set_clear_free(enumerator->match_parent);
+ set_clear(enumerator->match_parent);
}
int device_enumerator_add_match_parent_incremental(sd_device_enumerator *enumerator, sd_device *parent) {
@@ -238,10 +226,6 @@ int device_enumerator_add_match_parent_incremental(sd_device_enumerator *enumera
if (r < 0)
return r;
- r = set_ensure_allocated(&enumerator->match_parent, NULL);
- if (r < 0)
- return r;
-
r = set_put_strdup(&enumerator->match_parent, path);
if (r < 0)
return r;