/* If FirstEntry is NULL, then ASSERT(). If FirstEntry->ForwardLink is NULL, then ASSERT(). If FirstEntry->BackLink is NULL, then ASSERT(). If SecondEntry is NULL, then ASSERT(); If PcdMaximumLinkedListLength is not zero, and List contains more than PcdMaximumLinkedListLength nodes, then ASSERT(). */
BOOLEAN EFIAPI IsNodeInList(IN CONST LIST_ENTRY *FirstEntry, IN CONST LIST_ENTRY *SecondEntry)
/* If FirstEntry is NULL, then ASSERT(). If FirstEntry->ForwardLink is NULL, then ASSERT(). If FirstEntry->BackLink is NULL, then ASSERT(). If SecondEntry is NULL, then ASSERT(); If PcdMaximumLinkedListLength is not zero, and List contains more than PcdMaximumLinkedListLength nodes, then ASSERT(). */
BOOLEAN EFIAPI IsNodeInList(IN CONST LIST_ENTRY *FirstEntry, IN CONST LIST_ENTRY *SecondEntry)
{
  UINTN             Count;
  CONST LIST_ENTRY  *Ptr;
  ASSERT (InternalBaseLibIsListValid (FirstEntry));
  ASSERT (SecondEntry != NULL);
  Count = 0;
  Ptr   = FirstEntry;
  do {
    Ptr = Ptr->ForwardLink;
    if (PcdGet32 (PcdMaximumLinkedListLength) > 0) {
      Count++;
      if (Count == PcdGet32 (PcdMaximumLinkedListLength)) {
        return (BOOLEAN)(Ptr == SecondEntry);
      }
    }
    if (Ptr == SecondEntry) {
      return TRUE;
    }
  } while (Ptr != FirstEntry);
  return FALSE;
}