From: Zbigniew Jędrzejewski-Szmek Date: Wed, 29 Apr 2020 07:01:18 +0000 (+0200) Subject: sd-device: use string hash ops in device enumerator X-Git-Tag: v246-rc1~418^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c73bb51364457f049082eb84447755e53892f542;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c index cd3d75c5177..d6ceb2aff38 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;