git: 3eb80ef831e1 - main - efivar: Use memcmp instead of uuid_ functions to compare
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 01 May 2025 18:06:35 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=3eb80ef831e1b82b38fc23bfe0114fc5f90e5c5f
commit 3eb80ef831e1b82b38fc23bfe0114fc5f90e5c5f
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2025-05-01 17:52:59 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-05-01 17:52:59 +0000
efivar: Use memcmp instead of uuid_ functions to compare
In these cases, memcmp is a perfectly fine substitute for the uuid
functions. We don't need checking to make sure the uuids are good, we
know the pointers are non-ULL, etc. memcmp will reduce the number of
places we need to know these are actually UUIDs, or similar.
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D50033
---
lib/libefivar/efivar.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/lib/libefivar/efivar.c b/lib/libefivar/efivar.c
index bb838e8a1399..a74deeae1e03 100644
--- a/lib/libefivar/efivar.c
+++ b/lib/libefivar/efivar.c
@@ -287,9 +287,7 @@ done:
int
efi_guid_cmp(const efi_guid_t *guid1, const efi_guid_t *guid2)
{
- uint32_t status;
-
- return uuid_compare((const uuid_t *)guid1, (const uuid_t *)guid2, &status);
+ return (memcmp(guid1, guid2, sizeof(*guid1)));
}
int
@@ -304,11 +302,10 @@ int
efi_guid_to_name(efi_guid_t *guid, char **name)
{
size_t i;
- uint32_t status;
efi_guid_tbl_compile();
for (i = 0; i < nitems(guid_tbl); i++) {
- if (uuid_equal((const uuid_t *)guid, (const uuid_t *)&guid_tbl[i].guid, &status)) {
+ if (memcmp(guid, &guid_tbl[i].guid, sizeof(*guid)) == 0) {
*name = strdup(guid_tbl[i].name);
return (0);
}