sd-id128: rename and export sd_id128_string_equal()

We find this function useful in our code, so no reason not to export it.
I changed the order of last two words in the name to match the arguments.
(With "equal_string" I expected sd_id128_t first, string second, but in
actual use, the second argument is usually a long constant so it's nice
to keep this order of arguments.)
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2022-06-30 10:35:27 +02:00
parent 870c2aaf8c
commit e16144844b
8 changed files with 30 additions and 26 deletions
+2
View File
@@ -783,6 +783,8 @@ LIBSYSTEMD_252 {
global:
sd_bus_error_setfv;
sd_id128_string_equal;
sd_hwdb_new_from_path;
sd_netlink_new_from_fd;
-16
View File
@@ -206,19 +206,3 @@ int id128_get_product(sd_id128_t *ret) {
*ret = uuid;
return 0;
}
int id128_equal_string(const char *s, sd_id128_t id) {
sd_id128_t parsed;
int r;
if (!s)
return false;
/* Checks if the specified string matches a valid string representation of the specified 128 bit ID/uuid */
r = sd_id128_from_string(s, &parsed);
if (r < 0)
return r;
return sd_id128_equal(parsed, id);
}
-2
View File
@@ -34,5 +34,3 @@ extern const struct hash_ops id128_hash_ops;
sd_id128_t id128_make_v4_uuid(sd_id128_t id);
int id128_get_product(sd_id128_t *ret);
int id128_equal_string(const char *s, sd_id128_t id);
+16
View File
@@ -101,6 +101,22 @@ _public_ int sd_id128_from_string(const char s[], sd_id128_t *ret) {
return 0;
}
_public_ int sd_id128_string_equal(const char *s, sd_id128_t id) {
sd_id128_t parsed;
int r;
if (!s)
return false;
/* Checks if the specified string matches a valid string representation of the specified 128 bit ID/uuid */
r = sd_id128_from_string(s, &parsed);
if (r < 0)
return r;
return sd_id128_equal(parsed, id);
}
_public_ int sd_id128_get_machine(sd_id128_t *ret) {
static thread_local sd_id128_t saved_machine_id = {};
int r;