[PATCH] Correct and simplify full kernel path output

1 view
Skip to first unread message

Jan Kiszka

unread,
Apr 22, 2022, 12:48:01 PM4/22/22
to efibootguard-dev
From: Jan Kiszka <jan.k...@siemens.com>

We already generate to the path as EFI_DEVICE_PATH, we just need to
convert and dump that object. This not only simplifies the code, it also
ensures that there is proper path separator between prefix and file.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
utils.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/utils.c b/utils.c
index 324d77d..af0d739 100644
--- a/utils.c
+++ b/utils.c
@@ -211,7 +211,6 @@ EFI_DEVICE_PATH *FileDevicePathFromConfig(EFI_HANDLE device,
{
UINTN prefixlen = 0;
EFI_DEVICE_PATH *devpath = NULL;
- CHAR16 *fullpath;

LABELMODE lm = NOLABEL;
/* Check if payload path contains a
@@ -258,25 +257,17 @@ EFI_DEVICE_PATH *FileDevicePathFromConfig(EFI_HANDLE device,
return FileDevicePath(device, payloadpath);
}

- CHAR16 *pathprefix = DevicePathToStr(devpath);
- fullpath = AllocatePool(sizeof(CHAR16) *
- (StrLen(pathprefix) + StrLen(payloadpath) + 1));
-
- StrCpy(fullpath, pathprefix);
- StrCat(fullpath, payloadpath + prefixlen + 3);
- INFO(L"Full path for kernel is: %s\n", fullpath);
-
- FreePool(fullpath);
- FreePool(pathprefix);
-
EFI_DEVICE_PATH *filedevpath;
EFI_DEVICE_PATH *appendeddevpath;

filedevpath = FileDevicePath(NULL, payloadpath + prefixlen + 3);
appendeddevpath = AppendDevicePath(devpath, filedevpath);
-
FreePool(filedevpath);

+ CHAR16 *pathstr = DevicePathToStr(appendeddevpath);
+ INFO(L"Full path for kernel is: %s\n", pathstr);
+ FreePool(pathstr);
+
return appendeddevpath;
}

--
2.34.1


--
Siemens AG, Technology
Competence Center Embedded Linux
Reply all
Reply to author
Forward
0 new messages