/* If found the device path is not a valid device path, remove the variable. */
VOID BdsFormalizeConsoleVariable(IN CHAR16 *VariableName)
/* If found the device path is not a valid device path, remove the variable. */
VOID BdsFormalizeConsoleVariable(IN CHAR16 *VariableName)
{
  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
  UINTN                     VariableSize;
  EFI_STATUS                Status;
  GetEfiGlobalVariable2 (VariableName, (VOID **)&DevicePath, &VariableSize);
  if ((DevicePath != NULL) && !IsDevicePathValid (DevicePath, VariableSize)) {
    Status = gRT->SetVariable (
                    VariableName,
                    &gEfiGlobalVariableGuid,
                    EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
                    0,
                    NULL
                    );
    ASSERT_EFI_ERROR (Status);
  }
  if (DevicePath != NULL) {
    FreePool (DevicePath);
  }
}