diff options
Diffstat (limited to 'src/interface/efi')
-rw-r--r-- | src/interface/efi/efi_debug.c | 12 | ||||
-rw-r--r-- | src/interface/efi/efi_snp.c | 3 | ||||
-rw-r--r-- | src/interface/efi/efi_utils.c | 12 |
3 files changed, 15 insertions, 12 deletions
diff --git a/src/interface/efi/efi_debug.c b/src/interface/efi/efi_debug.c index ed18ff9..069ca3f 100644 --- a/src/interface/efi/efi_debug.c +++ b/src/interface/efi/efi_debug.c @@ -359,9 +359,6 @@ const __attribute__ (( pure )) char * efi_devpath_text ( EFI_DEVICE_PATH_PROTOCOL *path ) { EFI_BOOT_SERVICES *bs = efi_systab->BootServices; static char text[256]; - void *start; - void *end; - size_t max_len; size_t len; CHAR16 *wtext; @@ -374,13 +371,8 @@ efi_devpath_text ( EFI_DEVICE_PATH_PROTOCOL *path ) { /* If we have no DevicePathToText protocol then use a raw hex string */ if ( ! efidpt ) { DBG ( "[No DevicePathToText]" ); - start = path; - end = efi_devpath_end ( path ); - len = ( end - start ); - max_len = ( ( sizeof ( text ) - 1 /* NUL */ ) / 2 /* "xx" */ ); - if ( len > max_len ) - len = max_len; - base16_encode ( start, len, text, sizeof ( text ) ); + len = efi_devpath_len ( path ); + base16_encode ( path, len, text, sizeof ( text ) ); return text; } diff --git a/src/interface/efi/efi_snp.c b/src/interface/efi/efi_snp.c index 2ff1e97..5729a39 100644 --- a/src/interface/efi/efi_snp.c +++ b/src/interface/efi/efi_snp.c @@ -1033,8 +1033,7 @@ static int efi_snp_probe ( struct net_device *netdev ) { } /* Allocate the new device path */ - path_end = efi_devpath_end ( path.path ); - path_prefix_len = ( ( ( void * ) path_end ) - ( ( void * ) path.path )); + path_prefix_len = efi_devpath_len ( path.path ); snpdev->path = zalloc ( path_prefix_len + sizeof ( *macpath ) + sizeof ( *path_end ) ); if ( ! snpdev->path ) { diff --git a/src/interface/efi/efi_utils.c b/src/interface/efi/efi_utils.c index 1bebaa5..4dc7541 100644 --- a/src/interface/efi/efi_utils.c +++ b/src/interface/efi/efi_utils.c @@ -51,6 +51,18 @@ EFI_DEVICE_PATH_PROTOCOL * efi_devpath_end ( EFI_DEVICE_PATH_PROTOCOL *path ) { } /** + * Find length of device path (excluding terminator) + * + * @v path Path to device + * @ret path_len Length of device path + */ +size_t efi_devpath_len ( EFI_DEVICE_PATH_PROTOCOL *path ) { + EFI_DEVICE_PATH_PROTOCOL *end = efi_devpath_end ( path ); + + return ( ( ( void * ) end ) - ( ( void * ) path ) ); +} + +/** * Locate parent device supporting a given protocol * * @v device EFI device handle |