summaryrefslogtreecommitdiffstats
path: root/src/interface/efi/efi_path.c
diff options
context:
space:
mode:
authorMichael Brown2023-01-23 20:07:35 +0100
committerMichael Brown2023-01-23 20:27:11 +0100
commit204d39222a0ff9f91fdffc2809de0b7f5aaabbae (patch)
tree64e2faac8d8d6141a54c867482cd3b36755ea06d /src/interface/efi/efi_path.c
parent[arm] Inhibit linker warnings about an implied executable stack (diff)
downloadipxe-204d39222a0ff9f91fdffc2809de0b7f5aaabbae.tar.gz
ipxe-204d39222a0ff9f91fdffc2809de0b7f5aaabbae.tar.xz
ipxe-204d39222a0ff9f91fdffc2809de0b7f5aaabbae.zip
[efi] Add efi_path_terminate() utility function
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/efi/efi_path.c')
-rw-r--r--src/interface/efi/efi_path.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/src/interface/efi/efi_path.c b/src/interface/efi/efi_path.c
index fb0f3059..50027b75 100644
--- a/src/interface/efi/efi_path.c
+++ b/src/interface/efi/efi_path.c
@@ -161,9 +161,7 @@ EFI_DEVICE_PATH_PROTOCOL * efi_paths ( EFI_DEVICE_PATH_PROTOCOL *first, ... ) {
}
va_end ( args );
end = dst;
- end->Type = END_DEVICE_PATH_TYPE;
- end->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
- end->Length[0] = sizeof ( *end );
+ efi_path_terminate ( end );
return path;
}
@@ -223,9 +221,7 @@ EFI_DEVICE_PATH_PROTOCOL * efi_netdev_path ( struct net_device *netdev ) {
} else {
end = ( ( ( void * ) macpath ) + sizeof ( *macpath ) );
}
- end->Type = END_DEVICE_PATH_TYPE;
- end->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
- end->Length[0] = sizeof ( *end );
+ efi_path_terminate ( end );
return path;
}
@@ -265,9 +261,7 @@ EFI_DEVICE_PATH_PROTOCOL * efi_uri_path ( struct uri *uri ) {
uripath->Header.Length[1] = ( uripath_len >> 8 );
format_uri ( uri, uripath->Uri, uri_len );
end = ( ( ( void * ) path ) + uripath_len );
- end->Type = END_DEVICE_PATH_TYPE;
- end->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
- end->Length[0] = sizeof ( *end );
+ efi_path_terminate ( end );
return path;
}
@@ -324,9 +318,7 @@ EFI_DEVICE_PATH_PROTOCOL * efi_iscsi_path ( struct iscsi_session *iscsi ) {
name = ( ( ( void * ) iscsipath ) + sizeof ( *iscsipath ) );
memcpy ( name, iscsi->target_iqn, name_len );
end = ( ( ( void * ) name ) + name_len );
- end->Type = END_DEVICE_PATH_TYPE;
- end->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
- end->Length[0] = sizeof ( *end );
+ efi_path_terminate ( end );
/* Free temporary paths */
free ( netpath );
@@ -366,9 +358,7 @@ EFI_DEVICE_PATH_PROTOCOL * efi_aoe_path ( struct aoe_device *aoedev ) {
satapath.sata.Header.Length[0] = sizeof ( satapath.sata );
satapath.sata.HBAPortNumber = aoedev->major;
satapath.sata.PortMultiplierPortNumber = aoedev->minor;
- satapath.end.Type = END_DEVICE_PATH_TYPE;
- satapath.end.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
- satapath.end.Length[0] = sizeof ( satapath.end );
+ efi_path_terminate ( &satapath.end );
/* Construct overall device path */
path = efi_paths ( netpath, &satapath, NULL );
@@ -409,9 +399,7 @@ EFI_DEVICE_PATH_PROTOCOL * efi_fcp_path ( struct fcp_description *desc ) {
path->fc.Header.Length[0] = sizeof ( path->fc );
memcpy ( path->fc.WWN, &desc->wwn, sizeof ( path->fc.WWN ) );
memcpy ( path->fc.Lun, &desc->lun, sizeof ( path->fc.Lun ) );
- path->end.Type = END_DEVICE_PATH_TYPE;
- path->end.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
- path->end.Length[0] = sizeof ( path->end );
+ efi_path_terminate ( &path->end );
return &path->fc.Header;
}
@@ -463,9 +451,7 @@ EFI_DEVICE_PATH_PROTOCOL * efi_ib_srp_path ( struct ib_srp_device *ib_srp ) {
memcpy ( &ibpath->DeviceId, &id->ib.id_ext,
sizeof ( ibpath->DeviceId ) );
end = ( ( ( void * ) ibpath ) + sizeof ( *ibpath ) );
- end->Type = END_DEVICE_PATH_TYPE;
- end->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
- end->Length[0] = sizeof ( *end );
+ efi_path_terminate ( end );
return path;
}
@@ -511,9 +497,7 @@ EFI_DEVICE_PATH_PROTOCOL * efi_usb_path ( struct usb_function *func ) {
/* Construct device path */
memcpy ( path, efidev->path, prefix_len );
end = ( ( ( void * ) path ) + len - sizeof ( *end ) );
- end->Type = END_DEVICE_PATH_TYPE;
- end->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
- end->Length[0] = sizeof ( *end );
+ efi_path_terminate ( end );
usbpath = ( ( ( void * ) end ) - sizeof ( *usbpath ) );
usbpath->InterfaceNumber = func->interface[0];
for ( ; usb ; usbpath--, usb = usb->port->hub->usb ) {