1
0
Fork 0
mirror of https://github.com/reactos/reactos.git synced 2025-05-14 23:03:53 +00:00

[SETUPLIB][USETUP] Remove the deprecated GenericListHasSingleEntry() function and use instead GetNumberOfListEntries().

- Few FIXMEs get fixed in the process.
- Add some diagnostic ASSERTs.
This commit is contained in:
Hermès Bélusca-Maïto 2018-01-28 23:14:16 +01:00
parent a635aa8475
commit a972948051
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
5 changed files with 24 additions and 39 deletions

View file

@ -761,10 +761,7 @@ ProcessComputerFiles(
Entry = GetCurrentListEntry(List); Entry = GetCurrentListEntry(List);
if (Entry == NULL) if (Entry == NULL)
{
DPRINT("GetCurrentListEntry() failed\n");
return FALSE; return FALSE;
}
RtlStringCchPrintfW(SectionName, ARRAYSIZE(SectionName), RtlStringCchPrintfW(SectionName, ARRAYSIZE(SectionName),
L"Files.%s", ((PGENENTRY)GetListEntryData(Entry))->Id); L"Files.%s", ((PGENENTRY)GetListEntryData(Entry))->Id);
@ -794,10 +791,7 @@ ProcessDisplayRegistry(
Entry = GetCurrentListEntry(List); Entry = GetCurrentListEntry(List);
if (Entry == NULL) if (Entry == NULL)
{
DPRINT1("GetCurrentListEntry() failed\n");
return FALSE; return FALSE;
}
if (!SetupFindFirstLineW(InfFile, L"Display", if (!SetupFindFirstLineW(InfFile, L"Display",
((PGENENTRY)GetListEntryData(Entry))->Id, ((PGENENTRY)GetListEntryData(Entry))->Id,

View file

@ -88,7 +88,7 @@ SetCurrentListEntry(
IN PGENERIC_LIST List, IN PGENERIC_LIST List,
IN PGENERIC_LIST_ENTRY Entry) IN PGENERIC_LIST_ENTRY Entry)
{ {
if (Entry->List != List) if (!Entry || (Entry->List != List))
return; return;
List->CurrentEntry = Entry; List->CurrentEntry = Entry;
} }
@ -143,16 +143,4 @@ GetNumberOfListEntries(
return List->NumOfEntries; return List->NumOfEntries;
} }
BOOLEAN
GenericListHasSingleEntry(
IN PGENERIC_LIST List)
{
/*
* If both list head pointers (which normally point to the first and last
* list member, respectively) point to the same entry then it means that
* there is just a single thing in there, otherwise... false!
*/
return (!IsListEmpty(&List->ListHead) && (List->ListHead.Flink == List->ListHead.Blink));
}
/* EOF */ /* EOF */

View file

@ -66,8 +66,4 @@ ULONG
GetNumberOfListEntries( GetNumberOfListEntries(
IN PGENERIC_LIST List); IN PGENERIC_LIST List);
BOOLEAN
GenericListHasSingleEntry(
IN PGENERIC_LIST List);
/* EOF */ /* EOF */

View file

@ -356,17 +356,20 @@ DrawGenericListCurrentItem(
IN SHORT Left, IN SHORT Left,
IN SHORT Top) IN SHORT Top)
{ {
//
// FIXME: That stuff crashes when the list is empty!!
//
CHAR CurrentItemText[256]; CHAR CurrentItemText[256];
if (GetEntryDescriptionProc)
if (GetEntryDescriptionProc &&
GetNumberOfListEntries(List) > 0)
{ {
GetEntryDescriptionProc(GetCurrentListEntry(List), GetEntryDescriptionProc(GetCurrentListEntry(List),
CurrentItemText, CurrentItemText,
ARRAYSIZE(CurrentItemText)); ARRAYSIZE(CurrentItemText));
CONSOLE_SetTextXY(Left, Top, CurrentItemText); CONSOLE_SetTextXY(Left, Top, CurrentItemText);
} }
else
{
CONSOLE_SetTextXY(Left, Top, "");
}
} }
VOID VOID

View file

@ -508,9 +508,11 @@ LanguagePage(PINPUT_RECORD Ir)
SetConsoleCodePage(); SetConsoleCodePage();
UpdateKBLayout(); UpdateKBLayout();
/* If there's just a single language in the list skip /*
* the language selection process altogether! */ * If there is no language or just a single one in the list,
if (GenericListHasSingleEntry(LanguageList)) * skip the language selection process altogether.
*/
if (GetNumberOfListEntries(LanguageList) <= 1)
{ {
USetupData.LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF); USetupData.LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF);
return WELCOME_PAGE; return WELCOME_PAGE;
@ -564,9 +566,8 @@ LanguagePage(PINPUT_RECORD Ir)
} }
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */ else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{ {
// ASSERT(GetNumberOfListEntries(LanguageList) >= 1);
// FIXME: That stuff crashes when the list is empty!!
//
SelectedLanguageId = SelectedLanguageId =
((PGENENTRY)GetListEntryData(GetCurrentListEntry(LanguageList)))->Id; ((PGENENTRY)GetListEntryData(GetCurrentListEntry(LanguageList)))->Id;
@ -591,9 +592,8 @@ LanguagePage(PINPUT_RECORD Ir)
if (RefreshPage) if (RefreshPage)
{ {
// ASSERT(GetNumberOfListEntries(LanguageList) >= 1);
// FIXME: That stuff crashes when the list is empty!!
//
NewLanguageId = NewLanguageId =
((PGENENTRY)GetListEntryData(GetCurrentListEntry(LanguageList)))->Id; ((PGENENTRY)GetListEntryData(GetCurrentListEntry(LanguageList)))->Id;
@ -897,6 +897,11 @@ UpgradeRepairPage(PINPUT_RECORD Ir)
NtOsInstallsList = CreateNTOSInstallationsList(PartitionList); NtOsInstallsList = CreateNTOSInstallationsList(PartitionList);
if (!NtOsInstallsList) if (!NtOsInstallsList)
DPRINT1("Failed to get a list of NTOS installations; continue installation...\n"); DPRINT1("Failed to get a list of NTOS installations; continue installation...\n");
/*
* If there is no available installation (or just a single one??) that can
* be updated in the list, just continue with the regular installation.
*/
if (!NtOsInstallsList || GetNumberOfListEntries(NtOsInstallsList) == 0) if (!NtOsInstallsList || GetNumberOfListEntries(NtOsInstallsList) == 0)
{ {
RepairUpdateFlag = FALSE; RepairUpdateFlag = FALSE;
@ -961,9 +966,8 @@ UpgradeRepairPage(PINPUT_RECORD Ir)
if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'U') /* U */ if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'U') /* U */
{ {
/* Retrieve the current installation */ /* Retrieve the current installation */
// ASSERT(GetNumberOfListEntries(NtOsInstallsList) >= 1);
// FIXME: That stuff crashes when the list is empty!!
//
CurrentInstallation = CurrentInstallation =
(PNTOS_INSTALLATION)GetListEntryData(GetCurrentListEntry(NtOsInstallsList)); (PNTOS_INSTALLATION)GetListEntryData(GetCurrentListEntry(NtOsInstallsList));