loader.efi: efi_devpath_is_prefix should return bool

efi_devpath_is_prefix() is currently returning values 0 or 1, which means
it really should return bool.

Additionally, use unsigned len, because we only get unsigned values from
DevicePathNodeLength().
This commit is contained in:
tsoome 2017-11-10 12:07:56 +00:00
parent 51458520c7
commit c2e27b84ac
2 changed files with 9 additions and 9 deletions

View File

@ -82,7 +82,7 @@ EFI_HANDLE efi_devpath_handle(EFI_DEVICE_PATH *);
EFI_DEVICE_PATH *efi_devpath_last_node(EFI_DEVICE_PATH *);
EFI_DEVICE_PATH *efi_devpath_trim(EFI_DEVICE_PATH *);
bool efi_devpath_match(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *);
int efi_devpath_is_prefix(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *);
bool efi_devpath_is_prefix(EFI_DEVICE_PATH *, EFI_DEVICE_PATH *);
CHAR16 *efi_devpath_name(EFI_DEVICE_PATH *);
void efi_free_devpath_name(CHAR16 *);

View File

@ -167,13 +167,13 @@ efi_devpath_match(EFI_DEVICE_PATH *devpath1, EFI_DEVICE_PATH *devpath2)
return (true);
}
int
bool
efi_devpath_is_prefix(EFI_DEVICE_PATH *prefix, EFI_DEVICE_PATH *path)
{
int len;
size_t len;
if (prefix == NULL || path == NULL)
return (0);
return (false);
while (1) {
if (IsDevicePathEnd(prefix))
@ -181,17 +181,17 @@ efi_devpath_is_prefix(EFI_DEVICE_PATH *prefix, EFI_DEVICE_PATH *path)
if (DevicePathType(prefix) != DevicePathType(path) ||
DevicePathSubType(prefix) != DevicePathSubType(path))
return (0);
return (false);
len = DevicePathNodeLength(prefix);
if (len != DevicePathNodeLength(path))
return (0);
return (false);
if (memcmp(prefix, path, (size_t)len) != 0)
return (0);
if (memcmp(prefix, path, len) != 0)
return (false);
prefix = NextDevicePathNode(prefix);
path = NextDevicePathNode(path);
}
return (1);
return (true);
}