BOOLEAN\r
EFIAPI\r
IsDevicePathValid (\r
- IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
- IN UINTN MaxSize\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN UINTN MaxSize\r
)\r
{\r
- UINTN Count;\r
- UINTN Size;\r
- UINTN NodeLength;\r
+ UINTN Count;\r
+ UINTN Size;\r
+ UINTN NodeLength;\r
\r
//\r
- //Validate the input whether exists and its size big enough to touch the first node\r
+ // Validate the input whether exists and its size big enough to touch the first node\r
//\r
- if (DevicePath == NULL || (MaxSize > 0 && MaxSize < END_DEVICE_PATH_LENGTH)) {\r
+ if ((DevicePath == NULL) || ((MaxSize > 0) && (MaxSize < END_DEVICE_PATH_LENGTH))) {\r
return FALSE;\r
}\r
\r
if (NodeLength > MAX_UINTN - Size) {\r
return FALSE;\r
}\r
+\r
Size += NodeLength;\r
\r
//\r
//\r
// FilePath must be a NULL-terminated string.\r
//\r
- if (DevicePathType (DevicePath) == MEDIA_DEVICE_PATH &&\r
- DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP &&\r
- *(CHAR16 *)((UINT8 *)DevicePath + NodeLength - 2) != 0) {\r
+ if ((DevicePathType (DevicePath) == MEDIA_DEVICE_PATH) &&\r
+ (DevicePathSubType (DevicePath) == MEDIA_FILEPATH_DP) &&\r
+ (*(CHAR16 *)((UINT8 *)DevicePath + NodeLength - 2) != 0))\r
+ {\r
return FALSE;\r
}\r
}\r
//\r
// Only return TRUE when the End Device Path node is valid.\r
//\r
- return (BOOLEAN) (DevicePathNodeLength (DevicePath) == END_DEVICE_PATH_LENGTH);\r
+ return (BOOLEAN)(DevicePathNodeLength (DevicePath) == END_DEVICE_PATH_LENGTH);\r
}\r
\r
-\r
/**\r
Returns the Type field of a device path node.\r
\r
)\r
{\r
ASSERT (Node != NULL);\r
- return (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength(Node));\r
+ return (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)(Node) + DevicePathNodeLength (Node));\r
}\r
\r
/**\r
)\r
{\r
ASSERT (Node != NULL);\r
- return (BOOLEAN) (DevicePathType (Node) == END_DEVICE_PATH_TYPE);\r
+ return (BOOLEAN)(DevicePathType (Node) == END_DEVICE_PATH_TYPE);\r
}\r
\r
/**\r
)\r
{\r
ASSERT (Node != NULL);\r
- return (BOOLEAN) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_ENTIRE_DEVICE_PATH_SUBTYPE);\r
+ return (BOOLEAN)(IsDevicePathEndType (Node) && DevicePathSubType (Node) == END_ENTIRE_DEVICE_PATH_SUBTYPE);\r
}\r
\r
/**\r
)\r
{\r
ASSERT (Node != NULL);\r
- return (BOOLEAN) (IsDevicePathEndType (Node) && DevicePathSubType(Node) == END_INSTANCE_DEVICE_PATH_SUBTYPE);\r
+ return (BOOLEAN)(IsDevicePathEndType (Node) && DevicePathSubType (Node) == END_INSTANCE_DEVICE_PATH_SUBTYPE);\r
}\r
\r
/**\r
//\r
// Compute the size and add back in the size of the end device path structure\r
//\r
- return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath);\r
+ return ((UINTN)DevicePath - (UINTN)Start) + DevicePathNodeLength (DevicePath);\r
}\r
\r
/**\r
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
)\r
{\r
- UINTN Size;\r
+ UINTN Size;\r
\r
//\r
// Compute the size\r
// Allocate space for the combined device path. It only has one end node of\r
// length EFI_DEVICE_PATH_PROTOCOL.\r
//\r
- Size1 = GetDevicePathSize (FirstDevicePath);\r
- Size2 = GetDevicePathSize (SecondDevicePath);\r
- Size = Size1 + Size2 - END_DEVICE_PATH_LENGTH;\r
+ Size1 = GetDevicePathSize (FirstDevicePath);\r
+ Size2 = GetDevicePathSize (SecondDevicePath);\r
+ Size = Size1 + Size2 - END_DEVICE_PATH_LENGTH;\r
\r
NewDevicePath = AllocatePool (Size);\r
\r
//\r
// Over write FirstDevicePath EndNode and do the copy\r
//\r
- DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath +\r
- (Size1 - END_DEVICE_PATH_LENGTH));\r
+ DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *)((CHAR8 *)NewDevicePath +\r
+ (Size1 - END_DEVICE_PATH_LENGTH));\r
CopyMem (DevicePath2, SecondDevicePath, Size2);\r
}\r
\r
if (DevicePathNode == NULL) {\r
return DuplicateDevicePath ((DevicePath != NULL) ? DevicePath : &mUefiDevicePathLibEndDevicePath);\r
}\r
+\r
//\r
// Build a Node that has a terminator on it\r
//\r
if (TempDevicePath == NULL) {\r
return NULL;\r
}\r
+\r
TempDevicePath = CopyMem (TempDevicePath, DevicePathNode, NodeLength);\r
//\r
// Add and end device path node to convert Node to device path\r
return NULL;\r
}\r
\r
- SrcSize = GetDevicePathSize (DevicePath);\r
- InstanceSize = GetDevicePathSize (DevicePathInstance);\r
+ SrcSize = GetDevicePathSize (DevicePath);\r
+ InstanceSize = GetDevicePathSize (DevicePathInstance);\r
\r
NewDevicePath = AllocatePool (SrcSize + InstanceSize);\r
if (NewDevicePath != NULL) {\r
-\r
- TempDevicePath = CopyMem (NewDevicePath, DevicePath, SrcSize);;\r
+ TempDevicePath = CopyMem (NewDevicePath, DevicePath, SrcSize);\r
\r
while (!IsDevicePathEnd (TempDevicePath)) {\r
TempDevicePath = NextDevicePathNode (TempDevicePath);\r
}\r
\r
- TempDevicePath->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;\r
- TempDevicePath = NextDevicePathNode (TempDevicePath);\r
+ TempDevicePath->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;\r
+ TempDevicePath = NextDevicePathNode (TempDevicePath);\r
CopyMem (TempDevicePath, DevicePathInstance, InstanceSize);\r
}\r
\r
EFI_DEVICE_PATH_PROTOCOL *\r
EFIAPI\r
UefiDevicePathLibGetNextDevicePathInstance (\r
- IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r
- OUT UINTN *Size\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,\r
+ OUT UINTN *Size\r
)\r
{\r
EFI_DEVICE_PATH_PROTOCOL *DevPath;\r
\r
ASSERT (Size != NULL);\r
\r
- if (DevicePath == NULL || *DevicePath == NULL) {\r
+ if ((DevicePath == NULL) || (*DevicePath == NULL)) {\r
*Size = 0;\r
return NULL;\r
}\r
//\r
// Compute the size of the device path instance\r
//\r
- *Size = ((UINTN) DevPath - (UINTN) (*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
+ *Size = ((UINTN)DevPath - (UINTN)(*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);\r
\r
//\r
// Make a copy and return the device path instance\r
//\r
- Temp = DevPath->SubType;\r
- DevPath->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;\r
- ReturnValue = DuplicateDevicePath (*DevicePath);\r
- DevPath->SubType = Temp;\r
+ Temp = DevPath->SubType;\r
+ DevPath->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;\r
+ ReturnValue = DuplicateDevicePath (*DevicePath);\r
+ DevPath->SubType = Temp;\r
\r
//\r
// If DevPath is the end of an entire device path, then another instance\r
EFI_DEVICE_PATH_PROTOCOL *\r
EFIAPI\r
UefiDevicePathLibCreateDeviceNode (\r
- IN UINT8 NodeType,\r
- IN UINT8 NodeSubType,\r
- IN UINT16 NodeLength\r
+ IN UINT8 NodeType,\r
+ IN UINT8 NodeSubType,\r
+ IN UINT16 NodeLength\r
)\r
{\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
\r
if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {\r
//\r
\r
DevicePath = AllocateZeroPool (NodeLength);\r
if (DevicePath != NULL) {\r
- DevicePath->Type = NodeType;\r
- DevicePath->SubType = NodeSubType;\r
- SetDevicePathNodeLength (DevicePath, NodeLength);\r
+ DevicePath->Type = NodeType;\r
+ DevicePath->SubType = NodeSubType;\r
+ SetDevicePathNodeLength (DevicePath, NodeLength);\r
}\r
\r
return DevicePath;\r
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
)\r
{\r
- CONST EFI_DEVICE_PATH_PROTOCOL *Node;\r
+ CONST EFI_DEVICE_PATH_PROTOCOL *Node;\r
\r
if (DevicePath == NULL) {\r
return FALSE;\r
return FALSE;\r
}\r
\r
-\r
/**\r
Allocates a device path for a file and appends it to an existing device path.\r
\r
EFI_DEVICE_PATH_PROTOCOL *\r
EFIAPI\r
FileDevicePath (\r
- IN EFI_HANDLE Device OPTIONAL,\r
- IN CONST CHAR16 *FileName\r
+ IN EFI_HANDLE Device OPTIONAL,\r
+ IN CONST CHAR16 *FileName\r
)\r
{\r
UINTN Size;\r
\r
DevicePath = NULL;\r
\r
- Size = StrSize (FileName);\r
+ Size = StrSize (FileName);\r
FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + END_DEVICE_PATH_LENGTH);\r
if (FileDevicePath != NULL) {\r
- FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath;\r
+ FilePath = (FILEPATH_DEVICE_PATH *)FileDevicePath;\r
FilePath->Header.Type = MEDIA_DEVICE_PATH;\r
FilePath->Header.SubType = MEDIA_FILEPATH_DP;\r
CopyMem (&FilePath->PathName, FileName, Size);\r