https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a972948051c9667caab49…
commit a972948051c9667caab490d406f28271edeb759f
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Jan 28 23:14:16 2018 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Oct 28 15:04:33 2018 +0100
[SETUPLIB][USETUP] Remove the deprecated GenericListHasSingleEntry() function and use instead GetNumberOfListEntries().
- Few FIXMEs get fixed in the process.
- Add some diagnostic ASSERTs.
---
base/setup/lib/settings.c | 6 ------
base/setup/lib/utils/genlist.c | 14 +-------------
base/setup/lib/utils/genlist.h | 4 ----
base/setup/usetup/genlist.c | 11 +++++++----
base/setup/usetup/usetup.c | 28 ++++++++++++++++------------
5 files changed, 24 insertions(+), 39 deletions(-)
diff --git a/base/setup/lib/settings.c b/base/setup/lib/settings.c
index f0a5200fe9..93de42a31d 100644
--- a/base/setup/lib/settings.c
+++ b/base/setup/lib/settings.c
@@ -761,10 +761,7 @@ ProcessComputerFiles(
Entry = GetCurrentListEntry(List);
if (Entry == NULL)
- {
- DPRINT("GetCurrentListEntry() failed\n");
return FALSE;
- }
RtlStringCchPrintfW(SectionName, ARRAYSIZE(SectionName),
L"Files.%s", ((PGENENTRY)GetListEntryData(Entry))->Id);
@@ -794,10 +791,7 @@ ProcessDisplayRegistry(
Entry = GetCurrentListEntry(List);
if (Entry == NULL)
- {
- DPRINT1("GetCurrentListEntry() failed\n");
return FALSE;
- }
if (!SetupFindFirstLineW(InfFile, L"Display",
((PGENENTRY)GetListEntryData(Entry))->Id,
diff --git a/base/setup/lib/utils/genlist.c b/base/setup/lib/utils/genlist.c
index a322914cd8..79a4895075 100644
--- a/base/setup/lib/utils/genlist.c
+++ b/base/setup/lib/utils/genlist.c
@@ -88,7 +88,7 @@ SetCurrentListEntry(
IN PGENERIC_LIST List,
IN PGENERIC_LIST_ENTRY Entry)
{
- if (Entry->List != List)
+ if (!Entry || (Entry->List != List))
return;
List->CurrentEntry = Entry;
}
@@ -143,16 +143,4 @@ GetNumberOfListEntries(
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 */
diff --git a/base/setup/lib/utils/genlist.h b/base/setup/lib/utils/genlist.h
index 5d145a4c46..ea3c7473bf 100644
--- a/base/setup/lib/utils/genlist.h
+++ b/base/setup/lib/utils/genlist.h
@@ -66,8 +66,4 @@ ULONG
GetNumberOfListEntries(
IN PGENERIC_LIST List);
-BOOLEAN
-GenericListHasSingleEntry(
- IN PGENERIC_LIST List);
-
/* EOF */
diff --git a/base/setup/usetup/genlist.c b/base/setup/usetup/genlist.c
index 8e8baffacd..c43f89ccd9 100644
--- a/base/setup/usetup/genlist.c
+++ b/base/setup/usetup/genlist.c
@@ -356,17 +356,20 @@ DrawGenericListCurrentItem(
IN SHORT Left,
IN SHORT Top)
{
- //
- // FIXME: That stuff crashes when the list is empty!!
- //
CHAR CurrentItemText[256];
- if (GetEntryDescriptionProc)
+
+ if (GetEntryDescriptionProc &&
+ GetNumberOfListEntries(List) > 0)
{
GetEntryDescriptionProc(GetCurrentListEntry(List),
CurrentItemText,
ARRAYSIZE(CurrentItemText));
CONSOLE_SetTextXY(Left, Top, CurrentItemText);
}
+ else
+ {
+ CONSOLE_SetTextXY(Left, Top, "");
+ }
}
VOID
diff --git a/base/setup/usetup/usetup.c b/base/setup/usetup/usetup.c
index f78f6525aa..46cb244565 100644
--- a/base/setup/usetup/usetup.c
+++ b/base/setup/usetup/usetup.c
@@ -508,9 +508,11 @@ LanguagePage(PINPUT_RECORD Ir)
SetConsoleCodePage();
UpdateKBLayout();
- /* If there's just a single language in the list skip
- * the language selection process altogether! */
- if (GenericListHasSingleEntry(LanguageList))
+ /*
+ * If there is no language or just a single one in the list,
+ * skip the language selection process altogether.
+ */
+ if (GetNumberOfListEntries(LanguageList) <= 1)
{
USetupData.LanguageId = (LANGID)(wcstol(SelectedLanguageId, NULL, 16) & 0xFFFF);
return WELCOME_PAGE;
@@ -564,9 +566,8 @@ LanguagePage(PINPUT_RECORD Ir)
}
else if (Ir->Event.KeyEvent.uChar.AsciiChar == 0x0D) /* ENTER */
{
- //
- // FIXME: That stuff crashes when the list is empty!!
- //
+ ASSERT(GetNumberOfListEntries(LanguageList) >= 1);
+
SelectedLanguageId =
((PGENENTRY)GetListEntryData(GetCurrentListEntry(LanguageList)))->Id;
@@ -591,9 +592,8 @@ LanguagePage(PINPUT_RECORD Ir)
if (RefreshPage)
{
- //
- // FIXME: That stuff crashes when the list is empty!!
- //
+ ASSERT(GetNumberOfListEntries(LanguageList) >= 1);
+
NewLanguageId =
((PGENENTRY)GetListEntryData(GetCurrentListEntry(LanguageList)))->Id;
@@ -897,6 +897,11 @@ UpgradeRepairPage(PINPUT_RECORD Ir)
NtOsInstallsList = CreateNTOSInstallationsList(PartitionList);
if (!NtOsInstallsList)
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)
{
RepairUpdateFlag = FALSE;
@@ -961,9 +966,8 @@ UpgradeRepairPage(PINPUT_RECORD Ir)
if (toupper(Ir->Event.KeyEvent.uChar.AsciiChar) == 'U') /* U */
{
/* Retrieve the current installation */
- //
- // FIXME: That stuff crashes when the list is empty!!
- //
+ ASSERT(GetNumberOfListEntries(NtOsInstallsList) >= 1);
+
CurrentInstallation =
(PNTOS_INSTALLATION)GetListEntryData(GetCurrentListEntry(NtOsInstallsList));
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=dae658088a6ca49571468…
commit dae658088a6ca4957146890f614d2fb202b8fd25
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sun Sep 3 16:03:21 2017 +0000
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Oct 28 14:41:57 2018 +0100
[USETUP] Introduce some -V functions for CONSOLE_ConOutPrintf, CONSOLE_SetStatusText and CONSOLE_SetStatusTextX.
Additions:
- Use explicit __cdecl calling convention for variadic functions.
- Fix also the whitespace in consup.h.
svn path=/branches/setup_improvements/; revision=75749
---
base/setup/usetup/consup.c | 91 ++++++++++++++++++---------------
base/setup/usetup/consup.h | 123 +++++++++++++++++++++++++++------------------
2 files changed, 124 insertions(+), 90 deletions(-)
diff --git a/base/setup/usetup/consup.c b/base/setup/usetup/consup.c
index 3c4bf3d011..a919e07624 100644
--- a/base/setup/usetup/consup.c
+++ b/base/setup/usetup/consup.c
@@ -137,16 +137,14 @@ CONSOLE_ConOutPuts(
}
VOID
-CONSOLE_ConOutPrintf(
- IN LPCSTR szFormat, ...)
+CONSOLE_ConOutPrintfV(
+ IN LPCSTR szFormat,
+ IN va_list args)
{
CHAR szOut[256];
DWORD dwWritten;
- va_list arg_ptr;
- va_start(arg_ptr, szFormat);
- vsprintf(szOut, szFormat, arg_ptr);
- va_end(arg_ptr);
+ vsprintf(szOut, szFormat, args);
WriteConsole(
StdOutput,
@@ -156,6 +154,19 @@ CONSOLE_ConOutPrintf(
NULL);
}
+VOID
+__cdecl
+CONSOLE_ConOutPrintf(
+ IN LPCSTR szFormat,
+ ...)
+{
+ va_list arg_ptr;
+
+ va_start(arg_ptr, szFormat);
+ CONSOLE_ConOutPrintfV(szFormat, arg_ptr);
+ va_end(arg_ptr);
+}
+
BOOL
CONSOLE_Flush(VOID)
{
@@ -405,17 +416,16 @@ CONSOLE_SetUnderlinedTextXY(
}
VOID
-CONSOLE_SetStatusText(
- IN LPCSTR fmt, ...)
+CONSOLE_SetStatusTextXV(
+ IN SHORT x,
+ IN LPCSTR fmt,
+ IN va_list args)
{
- CHAR Buffer[128];
- va_list ap;
COORD coPos;
DWORD Written;
+ CHAR Buffer[128];
- va_start(ap, fmt);
- vsprintf(Buffer, fmt, ap);
- va_end(ap);
+ vsprintf(Buffer, fmt, args);
coPos.X = 0;
coPos.Y = yScreen - 1;
@@ -434,6 +444,8 @@ CONSOLE_SetStatusText(
coPos,
&Written);
+ coPos.X = x;
+
WriteConsoleOutputCharacterA(
StdOutput,
Buffer,
@@ -443,44 +455,38 @@ CONSOLE_SetStatusText(
}
VOID
+__cdecl
CONSOLE_SetStatusTextX(
IN SHORT x,
- IN LPCSTR fmt, ...)
+ IN LPCSTR fmt,
+ ...)
{
- CHAR Buffer[128];
va_list ap;
- COORD coPos;
- DWORD Written;
va_start(ap, fmt);
- vsprintf(Buffer, fmt, ap);
+ CONSOLE_SetStatusTextXV(x, fmt, ap);
va_end(ap);
+}
- coPos.X = 0;
- coPos.Y = yScreen - 1;
-
- FillConsoleOutputAttribute(
- StdOutput,
- BACKGROUND_WHITE,
- xScreen,
- coPos,
- &Written);
-
- FillConsoleOutputCharacterA(
- StdOutput,
- ' ',
- xScreen,
- coPos,
- &Written);
+VOID
+CONSOLE_SetStatusTextV(
+ IN LPCSTR fmt,
+ IN va_list args)
+{
+ CONSOLE_SetStatusTextXV(0, fmt, args);
+}
- coPos.X = x;
+VOID
+__cdecl
+CONSOLE_SetStatusText(
+ IN LPCSTR fmt,
+ ...)
+{
+ va_list ap;
- WriteConsoleOutputCharacterA(
- StdOutput,
- Buffer,
- (ULONG)strlen(Buffer),
- coPos,
- &Written);
+ va_start(ap, fmt);
+ CONSOLE_SetStatusTextV(fmt, ap);
+ va_end(ap);
}
static
@@ -503,6 +509,7 @@ CONSOLE_ClearStatusTextX(IN SHORT x,
VOID
+__cdecl
CONSOLE_SetStatusTextAutoFitX(
IN SHORT x,
IN LPCSTR fmt, ...)
@@ -588,6 +595,7 @@ CONSOLE_SetHighlightedTextXY(
}
VOID
+__cdecl
CONSOLE_PrintTextXY(
IN SHORT x,
IN SHORT y,
@@ -614,6 +622,7 @@ CONSOLE_PrintTextXY(
}
VOID
+__cdecl
CONSOLE_PrintTextXYN(
IN SHORT x,
IN SHORT y,
diff --git a/base/setup/usetup/consup.h b/base/setup/usetup/consup.h
index dce5fa86aa..c107785cb3 100644
--- a/base/setup/usetup/consup.h
+++ b/base/setup/usetup/consup.h
@@ -55,14 +55,14 @@ extern SHORT xScreen, yScreen;
BOOLEAN
CONSOLE_Init(
- VOID);
+ VOID);
VOID
CONSOLE_ClearScreen(VOID);
VOID
CONSOLE_ConInKey(
- OUT PINPUT_RECORD Buffer);
+ OUT PINPUT_RECORD Buffer);
BOOLEAN
CONSOLE_ConInKeyPeek(
@@ -70,15 +70,22 @@ CONSOLE_ConInKeyPeek(
VOID
CONSOLE_ConOutChar(
- IN CHAR c);
+ IN CHAR c);
+
+VOID
+CONSOLE_ConOutPrintfV(
+ IN LPCSTR szFormat,
+ IN va_list args);
VOID
+__cdecl
CONSOLE_ConOutPrintf(
- IN LPCSTR szFormat, ...);
+ IN LPCSTR szFormat,
+ ...);
VOID
CONSOLE_ConOutPuts(
- IN LPCSTR szText);
+ IN LPCSTR szText);
BOOL
CONSOLE_Flush(VOID);
@@ -96,97 +103,115 @@ CONSOLE_GetCursorY(VOID);
VOID
CONSOLE_InvertTextXY(
- IN SHORT x,
- IN SHORT y,
- IN SHORT col,
- IN SHORT row);
+ IN SHORT x,
+ IN SHORT y,
+ IN SHORT col,
+ IN SHORT row);
VOID
CONSOLE_NormalTextXY(
- IN SHORT x,
- IN SHORT y,
- IN SHORT col,
- IN SHORT row);
+ IN SHORT x,
+ IN SHORT y,
+ IN SHORT col,
+ IN SHORT row);
VOID
+__cdecl
CONSOLE_PrintTextXY(
- IN SHORT x,
- IN SHORT y,
- IN LPCSTR fmt, ...);
+ IN SHORT x,
+ IN SHORT y,
+ IN LPCSTR fmt, ...);
VOID
+__cdecl
CONSOLE_PrintTextXYN(
- IN SHORT x,
- IN SHORT y,
- IN SHORT len,
- IN LPCSTR fmt, ...);
+ IN SHORT x,
+ IN SHORT y,
+ IN SHORT len,
+ IN LPCSTR fmt, ...);
VOID
CONSOLE_SetCursorType(
- IN BOOL bInsert,
- IN BOOL bVisible);
+ IN BOOL bInsert,
+ IN BOOL bVisible);
VOID
CONSOLE_SetCursorXY(
- IN SHORT x,
- IN SHORT y);
+ IN SHORT x,
+ IN SHORT y);
VOID
CONSOLE_SetCursorXY(
- IN SHORT x,
- IN SHORT y);
+ IN SHORT x,
+ IN SHORT y);
VOID
CONSOLE_SetHighlightedTextXY(
- IN SHORT x,
- IN SHORT y,
- IN LPCSTR Text);
+ IN SHORT x,
+ IN SHORT y,
+ IN LPCSTR Text);
VOID
CONSOLE_SetInputTextXY(
- IN SHORT x,
- IN SHORT y,
- IN SHORT len,
- IN LPCWSTR Text);
+ IN SHORT x,
+ IN SHORT y,
+ IN SHORT len,
+ IN LPCWSTR Text);
VOID
CONSOLE_SetInvertedTextXY(
- IN SHORT x,
- IN SHORT y,
- IN LPCSTR Text);
+ IN SHORT x,
+ IN SHORT y,
+ IN LPCSTR Text);
VOID
+CONSOLE_SetStatusTextV(
+ IN LPCSTR fmt,
+ IN va_list args);
+
+VOID
+__cdecl
CONSOLE_SetStatusText(
- IN LPCSTR fmt, ...);
+ IN LPCSTR fmt,
+ ...);
+
+VOID
+CONSOLE_SetStatusTextXV(
+ IN SHORT x,
+ IN LPCSTR fmt,
+ IN va_list args);
VOID
+__cdecl
CONSOLE_SetStatusTextX(
IN SHORT x,
- IN LPCSTR fmt, ...);
+ IN LPCSTR fmt,
+ ...);
VOID
+__cdecl
CONSOLE_SetStatusTextAutoFitX(
IN SHORT x,
- IN LPCSTR fmt, ...);
+ IN LPCSTR fmt, ...);
VOID
CONSOLE_SetTextXY(
- IN SHORT x,
- IN SHORT y,
- IN LPCSTR Text);
+ IN SHORT x,
+ IN SHORT y,
+ IN LPCSTR Text);
VOID
CONSOLE_SetUnderlinedTextXY(
- IN SHORT x,
- IN SHORT y,
- IN LPCSTR Text);
+ IN SHORT x,
+ IN SHORT y,
+ IN LPCSTR Text);
VOID
CONSOLE_SetStyledText(
- IN SHORT x,
- IN SHORT y,
- IN INT Flags,
- IN LPCSTR Text);
+ IN SHORT x,
+ IN SHORT y,
+ IN INT Flags,
+ IN LPCSTR Text);
VOID
CONSOLE_ClearStyledText(IN SHORT x,