/* Make sure we really only got file paths. */
for (const EFI_DEVICE_PATH *node = file_path; !IsDevicePathEnd(node); node = NextDevicePathNode(node))
- if (DevicePathType(node) != MEDIA_DEVICE_PATH || DevicePathSubType(node) != MEDIA_FILEPATH_DP)
+ if (node->Type != MEDIA_DEVICE_PATH || node->SubType != MEDIA_FILEPATH_DP)
return NULL;
_cleanup_free_ char16_t *file_path_str = NULL;
for (const EFI_DEVICE_PATH *node = dp; !IsDevicePathEnd(node);
node = NextDevicePathNode(node)) {
- if (DevicePathType(node) != MEDIA_DEVICE_PATH ||
- DevicePathSubType(node) != MEDIA_FILEPATH_DP)
+ if (node->Type != MEDIA_DEVICE_PATH || node->SubType != MEDIA_FILEPATH_DP)
return err;
- size_t path_size = DevicePathNodeLength(node);
+ size_t path_size = node->Length;
if (path_size <= offsetof(FILEPATH_DEVICE_PATH, PathName) || path_size % sizeof(char16_t))
return EFI_INVALID_PARAMETER;
path_size -= offsetof(FILEPATH_DEVICE_PATH, PathName);
return true;
if (IsDevicePathEnd(dp))
return false;
- size_t l1 = DevicePathNodeLength(start);
- size_t l2 = DevicePathNodeLength(dp);
- if (l1 != l2)
+ if (start->Length != dp->Length)
return false;
- if (memcmp(dp, start, l1) != 0)
+ if (memcmp(dp, start, start->Length) != 0)
return false;
start = NextDevicePathNode(start);
dp = NextDevicePathNode(dp);
assert(path);
assert(node);
- size_t len = (uint8_t *) node - (uint8_t *) path, new_node_len = 0;
- if (new_node)
- new_node_len = DevicePathNodeLength(new_node);
-
- EFI_DEVICE_PATH *ret = xmalloc(len + new_node_len + sizeof(EFI_DEVICE_PATH));
+ size_t len = (uint8_t *) node - (uint8_t *) path;
+ EFI_DEVICE_PATH *ret = xmalloc(len + (new_node ? new_node->Length : 0) + sizeof(EFI_DEVICE_PATH));
EFI_DEVICE_PATH *end = mempcpy(ret, path, len);
if (new_node)
- end = mempcpy(end, new_node, new_node_len);
+ end = mempcpy(end, new_node, new_node->Length);
SetDevicePathEndNode(end);
return ret;
/* Find the (last) partition node itself. */
EFI_DEVICE_PATH *part_node = NULL;
for (EFI_DEVICE_PATH *node = partition_path; !IsDevicePathEnd(node); node = NextDevicePathNode(node)) {
- if (DevicePathType(node) != MEDIA_DEVICE_PATH)
- continue;
-
- if (DevicePathSubType(node) != MEDIA_HARDDRIVE_DP)
+ if (node->Type != MEDIA_DEVICE_PATH || node->SubType != MEDIA_HARDDRIVE_DP)
continue;
part_node = node;
return NULL;
for (; !IsDevicePathEnd(dp); dp = NextDevicePathNode(dp)) {
- if (DevicePathType(dp) != MEDIA_DEVICE_PATH)
- continue;
- if (DevicePathSubType(dp) != MEDIA_HARDDRIVE_DP)
+ if (dp->Type != MEDIA_DEVICE_PATH || dp->SubType != MEDIA_HARDDRIVE_DP)
continue;
/* The HD device path may be misaligned. */
HARDDRIVE_DEVICE_PATH hd;
- memcpy(&hd, dp, MIN(sizeof(hd), (size_t) DevicePathNodeLength(dp)));
+ memcpy(&hd, dp, MIN(sizeof(hd), dp->Length));
if (hd.SignatureType != SIGNATURE_TYPE_GUID)
continue;
const char16_t *ConvertTextToDevicPath);
} EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL;
-#define DevicePathType(dp) ((dp)->Type)
-#define DevicePathSubType(dp) ((dp)->SubType)
-#define DevicePathNodeLength(dp) ((dp)->Length)
-
static inline EFI_DEVICE_PATH *NextDevicePathNode(const EFI_DEVICE_PATH *dp) {
assert(dp);
return (EFI_DEVICE_PATH *) ((uint8_t *) dp + dp->Length);