/* Delete Load Option that represent a Deleted state in DriverOptionMenu. */
EFI_STATUS Var_DelDriverOption(VOID)
/* Delete Load Option that represent a Deleted state in DriverOptionMenu. */
EFI_STATUS Var_DelDriverOption(VOID)
{
  BM_MENU_ENTRY    *NewMenuEntry;
  BM_LOAD_CONTEXT  *NewLoadContext;
  EFI_STATUS       Status;
  UINTN            Index;
  UINTN            Index2;
  Index2 = 0;
  for (Index = 0; Index < DriverOptionMenu.MenuNumber; Index++) {
    NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, (Index - Index2));
    if (NULL == NewMenuEntry) {
      return EFI_NOT_FOUND;
    }
    NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
    if (!NewLoadContext->Deleted) {
      continue;
    }
    Status = EfiBootManagerDeleteLoadOptionVariable (NewMenuEntry->OptionNumber, LoadOptionTypeDriver);
    if (EFI_ERROR (Status)) {
      return Status;
    }
    Index2++;
    RemoveEntryList (&NewMenuEntry->Link);
    BOpt_DestroyMenuEntry (NewMenuEntry);
    NewMenuEntry = NULL;
  }
  DriverOptionMenu.MenuNumber -= Index2;
  return EFI_SUCCESS;
}