From d511783a3c48d1a18d2c913e5d0a486b25eef175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Thu, 5 Feb 2015 21:24:26 +0000 Subject: [PATCH] [FREELDR]: Remove some extra newlines at the end of error messages that are displayed via message boxes, and also for few of them, use the fact that our message boxes implement printf-like features. svn path=/trunk/; revision=66174 --- .../boot/freeldr/freeldr/arch/amd64/winldr.c | 4 +-- .../boot/freeldr/freeldr/arch/i386/drivemap.c | 25 ++++++++----------- .../boot/freeldr/freeldr/arch/i386/winldr.c | 4 +-- reactos/boot/freeldr/freeldr/disk/ramdisk.c | 6 ++--- reactos/boot/freeldr/freeldr/freeldr.c | 4 +-- reactos/boot/freeldr/freeldr/linuxboot.c | 11 +++----- reactos/boot/freeldr/freeldr/miscboot.c | 15 +++-------- .../boot/freeldr/freeldr/windows/peloader.c | 22 ++++++++-------- reactos/boot/freeldr/freeldr/windows/winldr.c | 2 +- .../boot/freeldr/freeldr/windows/wlmemory.c | 4 +-- .../boot/freeldr/freeldr/windows/wlregistry.c | 3 +-- 11 files changed, 42 insertions(+), 58 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c b/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c index 710bb475efb..5091c8047da 100644 --- a/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c +++ b/reactos/boot/freeldr/freeldr/arch/amd64/winldr.c @@ -384,7 +384,7 @@ void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock) PcrBasePage = Pcr >> MM_PAGE_SHIFT; if (Pcr == 0) { - UiMessageBox("Can't allocate PCR\n"); + UiMessageBox("Can't allocate PCR."); return; } RtlZeroMemory((PVOID)Pcr, 2 * MM_PAGE_SIZE); @@ -400,7 +400,7 @@ void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock) GdtIdt = (PKGDTENTRY)MmAllocateMemoryWithType(NumPages * MM_PAGE_SIZE, LoaderMemoryData); if (GdtIdt == NULL) { - UiMessageBox("Can't allocate pages for GDT+IDT!\n"); + UiMessageBox("Can't allocate pages for GDT+IDT!"); return; } diff --git a/reactos/boot/freeldr/freeldr/arch/i386/drivemap.c b/reactos/boot/freeldr/freeldr/arch/i386/drivemap.c index 177e47042c4..416cc19abe9 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/drivemap.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/drivemap.c @@ -30,16 +30,15 @@ ULONG DriveMapHandlerSegOff = 0; // Segment:offset style address of ou #ifndef _MSC_VER VOID DriveMapMapDrivesInSection(PCSTR SectionName) { - CHAR SettingName[80]; - CHAR SettingValue[80]; - CHAR ErrorText[260]; - CHAR Drive1[80]; - CHAR Drive2[80]; - ULONG SectionId; - ULONG SectionItemCount; - ULONG Index; - ULONG Index2; - DRIVE_MAP_LIST DriveMapList; + CHAR SettingName[80]; + CHAR SettingValue[80]; + CHAR Drive1[80]; + CHAR Drive2[80]; + ULONG SectionId; + ULONG SectionItemCount; + ULONG Index; + ULONG Index2; + DRIVE_MAP_LIST DriveMapList; RtlZeroMemory(&DriveMapList, sizeof(DRIVE_MAP_LIST)); @@ -62,8 +61,7 @@ VOID DriveMapMapDrivesInSection(PCSTR SectionName) // Make sure we haven't exceeded the drive map max count if (DriveMapList.DriveMapCount >= 4) { - sprintf(ErrorText, "Max DriveMap count exceeded in section [%s]:\n\n%s=%s", SectionName, SettingName, SettingValue); - UiMessageBox(ErrorText); + UiMessageBox("Max DriveMap count exceeded in section [%s]:\n\n%s=%s", SectionName, SettingName, SettingValue); continue; } @@ -88,8 +86,7 @@ VOID DriveMapMapDrivesInSection(PCSTR SectionName) // Make sure we got good values before we add them to the map if (!DriveMapIsValidDriveString(Drive1) || !DriveMapIsValidDriveString(Drive2)) { - sprintf(ErrorText, "Error in DriveMap setting in section [%s]:\n\n%s=%s", SectionName, SettingName, SettingValue); - UiMessageBox(ErrorText); + UiMessageBox("Error in DriveMap setting in section [%s]:\n\n%s=%s", SectionName, SettingName, SettingValue); continue; } diff --git a/reactos/boot/freeldr/freeldr/arch/i386/winldr.c b/reactos/boot/freeldr/freeldr/arch/i386/winldr.c index 15c4f52907b..6cc099fd645 100644 --- a/reactos/boot/freeldr/freeldr/arch/i386/winldr.c +++ b/reactos/boot/freeldr/freeldr/arch/i386/winldr.c @@ -365,7 +365,7 @@ void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock) if (Pcr == 0) { - UiMessageBox("Can't allocate PCR\n"); + UiMessageBox("Can't allocate PCR."); return; } @@ -384,7 +384,7 @@ void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock) if (GdtIdt == NULL) { - UiMessageBox("Can't allocate pages for GDT+IDT!\n"); + UiMessageBox("Can't allocate pages for GDT+IDT!"); return; } diff --git a/reactos/boot/freeldr/freeldr/disk/ramdisk.c b/reactos/boot/freeldr/freeldr/disk/ramdisk.c index 6998f2828a7..0afc702aa1d 100644 --- a/reactos/boot/freeldr/freeldr/disk/ramdisk.c +++ b/reactos/boot/freeldr/freeldr/disk/ramdisk.c @@ -155,7 +155,7 @@ RamDiskLoadVirtualFile(IN PCHAR FileName) // if (Information.EndingAddress.HighPart != 0) { - UiMessageBox("RAM disk too big\n"); + UiMessageBox("RAM disk too big."); FsCloseFile(RamFile); return FALSE; } @@ -172,7 +172,7 @@ RamDiskLoadVirtualFile(IN PCHAR FileName) gRamDiskBase = MmAllocateMemoryWithType(gRamDiskSize, LoaderXIPRom); if (!gRamDiskBase) { - UiMessageBox("Failed to allocate memory for RAM disk\n"); + UiMessageBox("Failed to allocate memory for RAM disk."); FsCloseFile(RamFile); return FALSE; } @@ -222,7 +222,7 @@ RamDiskLoadVirtualFile(IN PCHAR FileName) gRamDiskBase = NULL; gRamDiskSize = 0; FsCloseFile(RamFile); - UiMessageBox("Failed to read RAM disk\n"); + UiMessageBox("Failed to read RAM disk."); return FALSE; } } diff --git a/reactos/boot/freeldr/freeldr/freeldr.c b/reactos/boot/freeldr/freeldr/freeldr.c index 43a020d592b..ea527e86ecd 100644 --- a/reactos/boot/freeldr/freeldr/freeldr.c +++ b/reactos/boot/freeldr/freeldr/freeldr.c @@ -41,13 +41,13 @@ VOID BootMain(LPSTR CmdLine) if (!UiInitialize(FALSE)) { - UiMessageBoxCritical("Unable to initialize UI.\n"); + UiMessageBoxCritical("Unable to initialize UI."); goto Quit; } if (!MmInitializeMemoryManager()) { - UiMessageBoxCritical("Unable to initialize memory manager"); + UiMessageBoxCritical("Unable to initialize memory manager."); goto Quit; } diff --git a/reactos/boot/freeldr/freeldr/linuxboot.c b/reactos/boot/freeldr/freeldr/linuxboot.c index ebc90733d00..c2c8f97e82c 100644 --- a/reactos/boot/freeldr/freeldr/linuxboot.c +++ b/reactos/boot/freeldr/freeldr/linuxboot.c @@ -82,7 +82,6 @@ LoadAndBootLinux(IN OperatingSystemItem* OperatingSystem, PCSTR Description = OperatingSystem->LoadIdentifier; PFILE LinuxKernel = 0; PFILE LinuxInitrdFile = 0; - CHAR TempString[260]; UiDrawBackdrop(); @@ -102,8 +101,7 @@ LoadAndBootLinux(IN OperatingSystemItem* OperatingSystem, LinuxKernel = FsOpenFile(LinuxKernelName); if (!LinuxKernel) { - sprintf(TempString, "Linux kernel \'%s\' not found.", LinuxKernelName); - UiMessageBox(TempString); + UiMessageBox("Linux kernel \'%s\' not found.", LinuxKernelName); goto LinuxBootFailed; } @@ -113,8 +111,7 @@ LoadAndBootLinux(IN OperatingSystemItem* OperatingSystem, LinuxInitrdFile = FsOpenFile(LinuxInitrdName); if (!LinuxInitrdFile) { - sprintf(TempString, "Linux initrd image \'%s\' not found.", LinuxInitrdName); - UiMessageBox(TempString); + UiMessageBox("Linux initrd image \'%s\' not found.", LinuxInitrdName); goto LinuxBootFailed; } } @@ -212,7 +209,6 @@ LinuxBootFailed: BOOLEAN LinuxParseIniSection(PCSTR SectionName) { ULONG_PTR SectionId; - CHAR SettingName[260]; /* Find all the message box settings and run them */ UiShowMessageBoxesInSection(SectionName); @@ -220,8 +216,7 @@ BOOLEAN LinuxParseIniSection(PCSTR SectionName) /* Try to open the operating system section in the .ini file */ if (!IniOpenSection(SectionName, &SectionId)) { - sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", SectionName); - UiMessageBox(SettingName); + UiMessageBox("Section [%s] not found in freeldr.ini.", SectionName); return FALSE; } diff --git a/reactos/boot/freeldr/freeldr/miscboot.c b/reactos/boot/freeldr/freeldr/miscboot.c index badf4aadb92..50f68e9afc5 100644 --- a/reactos/boot/freeldr/freeldr/miscboot.c +++ b/reactos/boot/freeldr/freeldr/miscboot.c @@ -34,7 +34,6 @@ LoadAndBootBootSector(IN OperatingSystemItem* OperatingSystem, CHAR FileName[260]; PFILE FilePointer; ULONG BytesRead; - CHAR SettingName[80]; /* Find all the message box settings and run them */ UiShowMessageBoxesInSection(SectionName); @@ -42,8 +41,7 @@ LoadAndBootBootSector(IN OperatingSystemItem* OperatingSystem, /* Try to open the operating system section in the .ini file */ if (!IniOpenSection(SectionName, &SectionId)) { - sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", SectionName); - UiMessageBox(SettingName); + UiMessageBox("Section [%s] not found in freeldr.ini.", SectionName); return; } @@ -56,8 +54,7 @@ LoadAndBootBootSector(IN OperatingSystemItem* OperatingSystem, FilePointer = FsOpenFile(FileName); if (!FilePointer) { - strcat(FileName, " not found."); - UiMessageBox(FileName); + UiMessageBox("%s not found.", FileName); return; } @@ -97,7 +94,6 @@ LoadAndBootPartition(IN OperatingSystemItem* OperatingSystem, { ULONG_PTR SectionId; PCSTR SectionName = OperatingSystem->SystemPartition; - CHAR SettingName[80]; CHAR SettingValue[80]; PARTITION_TABLE_ENTRY PartitionTableEntry; UCHAR DriveNumber; @@ -109,8 +105,7 @@ LoadAndBootPartition(IN OperatingSystemItem* OperatingSystem, /* Try to open the operating system section in the .ini file */ if (!IniOpenSection(SectionName, &SectionId)) { - sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", SectionName); - UiMessageBox(SettingName); + UiMessageBox("Section [%s] not found in freeldr.ini.", SectionName); return; } @@ -175,7 +170,6 @@ LoadAndBootDrive(IN OperatingSystemItem* OperatingSystem, { ULONG_PTR SectionId; PCSTR SectionName = OperatingSystem->SystemPartition; - CHAR SettingName[80]; CHAR SettingValue[80]; UCHAR DriveNumber; @@ -185,8 +179,7 @@ LoadAndBootDrive(IN OperatingSystemItem* OperatingSystem, /* Try to open the operating system section in the .ini file */ if (!IniOpenSection(SectionName, &SectionId)) { - sprintf(SettingName, "Section [%s] not found in freeldr.ini.\n", SectionName); - UiMessageBox(SettingName); + UiMessageBox("Section [%s] not found in freeldr.ini.", SectionName); return; } diff --git a/reactos/boot/freeldr/freeldr/windows/peloader.c b/reactos/boot/freeldr/freeldr/windows/peloader.c index f733a2fccdf..916a1ed8fcd 100644 --- a/reactos/boot/freeldr/freeldr/windows/peloader.c +++ b/reactos/boot/freeldr/freeldr/windows/peloader.c @@ -282,7 +282,7 @@ WinLdrLoadImage(IN PCHAR FileName, Status = ArcOpen(FileName, OpenReadOnly, &FileId); if (Status != ESUCCESS) { - //UiMessageBox("Can not open the file"); + // UiMessageBox("Can not open the file."); return FALSE; } @@ -290,7 +290,7 @@ WinLdrLoadImage(IN PCHAR FileName, Status = ArcRead(FileId, HeadersBuffer, SECTOR_SIZE * 2, &BytesRead); if (Status != ESUCCESS) { - UiMessageBox("Error reading from file"); + UiMessageBox("Error reading from file."); ArcClose(FileId); return FALSE; } @@ -299,8 +299,8 @@ WinLdrLoadImage(IN PCHAR FileName, NtHeaders = RtlImageNtHeader(HeadersBuffer); if (!NtHeaders) { - //Print(L"Error - no NT header found in %s\n", FileName); - UiMessageBox("Error - no NT header found"); + // Print(L"Error - no NT header found in %s\n", FileName); + UiMessageBox("Error - no NT header found."); ArcClose(FileId); return FALSE; } @@ -308,8 +308,8 @@ WinLdrLoadImage(IN PCHAR FileName, /* Ensure this is executable image */ if (((NtHeaders->FileHeader.Characteristics & IMAGE_FILE_EXECUTABLE_IMAGE) == 0)) { - //Print(L"Not an executable image %s\n", FileName); - UiMessageBox("Not an executable image"); + // Print(L"Not an executable image %s\n", FileName); + UiMessageBox("Not an executable image."); ArcClose(FileId); return FALSE; } @@ -330,8 +330,8 @@ WinLdrLoadImage(IN PCHAR FileName, if (PhysicalBase == NULL) { - //Print(L"Failed to alloc pages for image %s\n", FileName); - UiMessageBox("Failed to alloc pages for image"); + // Print(L"Failed to alloc pages for image %s\n", FileName); + UiMessageBox("Failed to alloc pages for image."); ArcClose(FileId); return FALSE; } @@ -347,7 +347,7 @@ WinLdrLoadImage(IN PCHAR FileName, Status = ArcSeek(FileId, &Position, SeekAbsolute); if (Status != ESUCCESS) { - UiMessageBox("Error seeking to start of file"); + UiMessageBox("Error seeking to start of file."); ArcClose(FileId); return FALSE; } @@ -355,8 +355,8 @@ WinLdrLoadImage(IN PCHAR FileName, Status = ArcRead(FileId, PhysicalBase, NtHeaders->OptionalHeader.SizeOfHeaders, &BytesRead); if (Status != ESUCCESS) { - //Print(L"Error reading headers %s\n", FileName); - UiMessageBox("Error reading headers"); + // Print(L"Error reading headers %s\n", FileName); + UiMessageBox("Error reading headers."); ArcClose(FileId); return FALSE; } diff --git a/reactos/boot/freeldr/freeldr/windows/winldr.c b/reactos/boot/freeldr/freeldr/windows/winldr.c index 2790cf52b07..1410f4fce46 100644 --- a/reactos/boot/freeldr/freeldr/windows/winldr.c +++ b/reactos/boot/freeldr/freeldr/windows/winldr.c @@ -682,7 +682,7 @@ LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem, /* Load the ramdisk */ if (!RamDiskLoadVirtualFile(FileName)) { - UiMessageBox("Failed to load RAM disk file %s\n", FileName); + UiMessageBox("Failed to load RAM disk file %s", FileName); return; } } diff --git a/reactos/boot/freeldr/freeldr/windows/wlmemory.c b/reactos/boot/freeldr/freeldr/windows/wlmemory.c index 6e45f45b510..ef89b4ca0a6 100644 --- a/reactos/boot/freeldr/freeldr/windows/wlmemory.c +++ b/reactos/boot/freeldr/freeldr/windows/wlmemory.c @@ -220,7 +220,7 @@ WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock) MemoryMap = MmGetMemoryMap(&NoEntries); if (MemoryMap == NULL) { - UiMessageBox("Can not retrieve the current memory map"); + UiMessageBox("Can not retrieve the current memory map."); return FALSE; } @@ -334,7 +334,7 @@ WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock) /*Status = MempSetupPaging(OsLoaderBase >> MM_PAGE_SHIFT, OsLoaderSize >> MM_PAGE_SHIFT); if (!Status) { - UiMessageBox("Error during MempSetupPaging"); + UiMessageBox("Error during MempSetupPaging."); return; }*/ diff --git a/reactos/boot/freeldr/freeldr/windows/wlregistry.c b/reactos/boot/freeldr/freeldr/windows/wlregistry.c index 49638139b33..bebf15c0350 100644 --- a/reactos/boot/freeldr/freeldr/windows/wlregistry.c +++ b/reactos/boot/freeldr/freeldr/windows/wlregistry.c @@ -437,8 +437,7 @@ WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, return TRUE; Failure: - //UiMessageBox("Error reading NLS file %s\n", Filename); - UiMessageBox("Error reading NLS file!"); + UiMessageBox("Error reading NLS file %s", FileName); return FALSE; }