From 20c2d9624d4a299b21a0bd84434ec7d4efe28c4c Mon Sep 17 00:00:00 2001 From: Tsarevich Dmitry Date: Sun, 23 Feb 2020 20:26:32 +0300 Subject: [PATCH] [types] Do not mix BOOL and BOOLEAN BOOL is typedef for int, BOOLEAN is for BYTE. Mixing them is not good idea, since converting BOOL => BOOLEAN can lead to data lost. Use BOOLEAN type when simple true/false (TRUE/FALSE) set of values required. --- src/drive.c | 2 +- src/drive.h | 2 +- src/iso.c | 2 +- src/process.c | 2 +- src/rufus.c | 4 ++-- src/rufus.h | 4 ++-- src/vhd.c | 12 ++++++------ 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/drive.c b/src/drive.c index 15190527..baf42749 100644 --- a/src/drive.c +++ b/src/drive.c @@ -1046,7 +1046,7 @@ const struct {int (*fn)(FILE *fp); char* str;} known_mbr[] = { }; // Returns TRUE if the drive seems bootable, FALSE otherwise -BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName, BOOL bSilent) +BOOLEAN AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName, BOOL bSilent) { const char* mbr_name = "Master Boot Record"; FAKE_FD fake_fd = { 0 }; diff --git a/src/drive.h b/src/drive.h index e14a0d85..2d4db42e 100644 --- a/src/drive.h +++ b/src/drive.h @@ -380,7 +380,7 @@ char GetUnusedDriveLetter(void); BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label); uint64_t GetDriveSize(DWORD DriveIndex); BOOL IsMediaPresent(DWORD DriveIndex); -BOOL AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName, BOOL bSilent); +BOOLEAN AnalyzeMBR(HANDLE hPhysicalDrive, const char* TargetName, BOOL bSilent); BOOL AnalyzePBR(HANDLE hLogicalVolume); BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSystemNameSize, BOOL bSilent); BOOL UnmountVolume(HANDLE hDrive); diff --git a/src/iso.c b/src/iso.c index 09eabc29..42324c9d 100644 --- a/src/iso.c +++ b/src/iso.c @@ -725,7 +725,7 @@ void GetGrubVersion(char* buf, size_t buf_size) img_report.grub2_version[0] = 0; } -BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan) +BOOLEAN ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan) { size_t i, j, size, sl_index = 0; uint16_t sl_version; diff --git a/src/process.c b/src/process.c index 00b43565..b3edfdbb 100644 --- a/src/process.c +++ b/src/process.c @@ -609,7 +609,7 @@ static DWORD WINAPI SearchProcessThread(LPVOID param) // The above may not work on Windows 7, so try QueryFullProcessImageName (Vista or later) if (!bGotCmdLine) { - bGotCmdLine = QueryFullProcessImageNameW(processHandle, 0, wexe_path, &size); + bGotCmdLine = QueryFullProcessImageNameW(processHandle, 0, wexe_path, &size) ? TRUE : FALSE; if (bGotCmdLine) wchar_to_utf8_no_alloc(wexe_path, cmdline, sizeof(cmdline)); } diff --git a/src/rufus.c b/src/rufus.c index 08bda425..88bf875e 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -1109,8 +1109,8 @@ DWORD WINAPI ISOScanThread(LPVOID param) user_notified = FALSE; EnableControls(FALSE, FALSE); memset(&img_report, 0, sizeof(img_report)); - img_report.is_iso = (BOOLEAN)ExtractISO(image_path, "", TRUE); - img_report.is_bootable_img = (BOOLEAN)IsBootableImage(image_path); + img_report.is_iso = ExtractISO(image_path, "", TRUE); + img_report.is_bootable_img = IsBootableImage(image_path); if ((FormatStatus == (ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_CANCELLED)) || (img_report.image_size == 0) || (!img_report.is_iso && !img_report.is_bootable_img)) { diff --git a/src/rufus.h b/src/rufus.h index 359baa1d..c2609c3f 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -506,7 +506,7 @@ extern void ListDialog(char* title, char* message, char** items, int size); extern SIZE GetTextSize(HWND hCtrl, char* txt); extern BOOL ExtractAppIcon(const char* filename, BOOL bSilent); extern BOOL ExtractDOS(const char* path); -extern BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan); +extern BOOLEAN ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan); extern int64_t ExtractISOFile(const char* iso, const char* iso_file, const char* dest_file, DWORD attributes); extern BOOL HasEfiImgBootLoaders(void); extern BOOL DumpFatDir(const char* path, int32_t cluster); @@ -547,7 +547,7 @@ extern BOOL WimExtractFile(const char* wim_image, int index, const char* src, co extern BOOL WimExtractFile_API(const char* image, int index, const char* src, const char* dst); extern BOOL WimExtractFile_7z(const char* image, int index, const char* src, const char* dst); extern BOOL WimApplyImage(const char* image, int index, const char* dst); -extern BOOL IsBootableImage(const char* path); +extern BOOLEAN IsBootableImage(const char* path); extern BOOL AppendVHDFooter(const char* vhd_path); extern int SetWinToGoIndex(void); extern int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid); diff --git a/src/vhd.c b/src/vhd.c index 482d832b..2ad8e622 100644 --- a/src/vhd.c +++ b/src/vhd.c @@ -229,12 +229,12 @@ static comp_assoc file_assoc[] = { // For now we consider that an image that matches a known extension is bootable #define MBR_SIZE 512 // Might need to review this once we see bootable 4k systems -BOOL IsCompressedBootableImage(const char* path) +BOOLEAN IsCompressedBootableImage(const char* path) { char *p; unsigned char *buf = NULL; int i; - BOOL r = FALSE; + BOOLEAN r = FALSE; int64_t dc; img_report.compression_type = BLED_COMPRESSION_NONE; @@ -267,7 +267,7 @@ BOOL IsCompressedBootableImage(const char* path) } -BOOL IsBootableImage(const char* path) +BOOLEAN IsBootableImage(const char* path) { HANDLE handle = INVALID_HANDLE_VALUE; LARGE_INTEGER liImageSize; @@ -276,7 +276,7 @@ BOOL IsBootableImage(const char* path) size_t i; uint32_t checksum, old_checksum; LARGE_INTEGER ptr; - BOOL is_bootable_img = FALSE; + BOOLEAN is_bootable_img = FALSE; uprintf("Disk image analysis:"); handle = CreateFileU(path, GENERIC_READ, FILE_SHARE_READ, NULL, @@ -286,9 +286,9 @@ BOOL IsBootableImage(const char* path) goto out; } - is_bootable_img = (BOOLEAN)IsCompressedBootableImage(path); + is_bootable_img = IsCompressedBootableImage(path); if (img_report.compression_type == BLED_COMPRESSION_NONE) - is_bootable_img = (BOOLEAN)AnalyzeMBR(handle, " Image", FALSE); + is_bootable_img = AnalyzeMBR(handle, " Image", FALSE); if (!GetFileSizeEx(handle, &liImageSize)) { uprintf(" Could not get image size: %s", WindowsErrorString());