git: 20c5e4b39368 - main - efivar: Allow uuid_t and efi_guid_t to be different types.

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 01 May 2025 18:06:37 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=20c5e4b393682b00694a1ef184ec4bd460b49ab1

commit 20c5e4b393682b00694a1ef184ec4bd460b49ab1
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2025-05-01 17:53:12 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2025-05-01 17:53:12 +0000

    efivar: Allow uuid_t and efi_guid_t to be different types.
    
    While they are binarily the same, the API are different. To use EDK2
    more effectively, we need to transition to using EDK@'s API rather than
    the uuid_t API. This change makes the code neutral on the subject.
    
    Sponsored by:           Netflix
    Reviewed by:            tsoome
    Differential Revision:  https://reviews.freebsd.org/D50035
---
 lib/libefivar/efivar.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/libefivar/efivar.c b/lib/libefivar/efivar.c
index 0089ed608a6f..e28987ff001d 100644
--- a/lib/libefivar/efivar.c
+++ b/lib/libefivar/efivar.c
@@ -172,7 +172,7 @@ efi_get_variable(efi_guid_t guid, const char *name,
 	rv = utf8_to_ucs2(name, &var.name, &var.namesize);
 	if (rv != 0)
 		goto errout;
-	var.vendor = guid;
+	memcpy(&var.vendor, &guid, sizeof(guid));
 	var.data = buf;
 	var.datasize = sizeof(buf);
 	rv = ioctl(efi_fd, EFIIOC_VAR_GET, &var);
@@ -240,7 +240,7 @@ again:
 		rv = utf8_to_ucs2(*name, &var.name, &size);
 		if (rv != 0)
 			goto errout;
-		var.vendor = **guid;
+		memcpy(&var.vendor, *guid, sizeof(**guid));
 	}
 	rv = ioctl(efi_fd, EFIIOC_VAR_NEXT, &var);
 	if (rv == 0 && var.name == NULL) {
@@ -266,7 +266,7 @@ again:
 		rv = ucs2_to_utf8(var.name, name);
 		if (rv != 0)
 			goto errout;
-		retguid = var.vendor;
+		memcpy(&retguid, &var.vendor, sizeof(retguid));
 		*guid = &retguid;
 	}
 errout:
@@ -361,7 +361,7 @@ efi_set_variable(efi_guid_t guid, const char *name,
 	rv = utf8_to_ucs2(name, &var.name, &var.namesize);
 	if (rv != 0)
 		goto errout;
-	var.vendor = guid;
+	memcpy(&var.vendor, &guid, sizeof(guid));
 	var.data = data;
 	var.datasize = data_size;
 	var.attrib = attributes;