1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[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.
This commit is contained in:
Tsarevich Dmitry 2020-02-23 20:26:32 +03:00
parent f4b006bc0c
commit 20c2d9624d
No known key found for this signature in database
GPG key ID: E3C61298FF5B1274
7 changed files with 14 additions and 14 deletions

View file

@ -1046,7 +1046,7 @@ const struct {int (*fn)(FILE *fp); char* str;} known_mbr[] = {
}; };
// Returns TRUE if the drive seems bootable, FALSE otherwise // 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"; const char* mbr_name = "Master Boot Record";
FAKE_FD fake_fd = { 0 }; FAKE_FD fake_fd = { 0 };

View file

@ -380,7 +380,7 @@ char GetUnusedDriveLetter(void);
BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label); BOOL GetDriveLabel(DWORD DriveIndex, char* letter, char** label);
uint64_t GetDriveSize(DWORD DriveIndex); uint64_t GetDriveSize(DWORD DriveIndex);
BOOL IsMediaPresent(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 AnalyzePBR(HANDLE hLogicalVolume);
BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSystemNameSize, BOOL bSilent); BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSystemNameSize, BOOL bSilent);
BOOL UnmountVolume(HANDLE hDrive); BOOL UnmountVolume(HANDLE hDrive);

View file

@ -725,7 +725,7 @@ void GetGrubVersion(char* buf, size_t buf_size)
img_report.grub2_version[0] = 0; 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; size_t i, j, size, sl_index = 0;
uint16_t sl_version; uint16_t sl_version;

View file

@ -609,7 +609,7 @@ static DWORD WINAPI SearchProcessThread(LPVOID param)
// The above may not work on Windows 7, so try QueryFullProcessImageName (Vista or later) // The above may not work on Windows 7, so try QueryFullProcessImageName (Vista or later)
if (!bGotCmdLine) { if (!bGotCmdLine) {
bGotCmdLine = QueryFullProcessImageNameW(processHandle, 0, wexe_path, &size); bGotCmdLine = QueryFullProcessImageNameW(processHandle, 0, wexe_path, &size) ? TRUE : FALSE;
if (bGotCmdLine) if (bGotCmdLine)
wchar_to_utf8_no_alloc(wexe_path, cmdline, sizeof(cmdline)); wchar_to_utf8_no_alloc(wexe_path, cmdline, sizeof(cmdline));
} }

View file

@ -1109,8 +1109,8 @@ DWORD WINAPI ISOScanThread(LPVOID param)
user_notified = FALSE; user_notified = FALSE;
EnableControls(FALSE, FALSE); EnableControls(FALSE, FALSE);
memset(&img_report, 0, sizeof(img_report)); memset(&img_report, 0, sizeof(img_report));
img_report.is_iso = (BOOLEAN)ExtractISO(image_path, "", TRUE); img_report.is_iso = ExtractISO(image_path, "", TRUE);
img_report.is_bootable_img = (BOOLEAN)IsBootableImage(image_path); img_report.is_bootable_img = IsBootableImage(image_path);
if ((FormatStatus == (ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_CANCELLED)) || if ((FormatStatus == (ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_CANCELLED)) ||
(img_report.image_size == 0) || (!img_report.is_iso && !img_report.is_bootable_img)) { (img_report.image_size == 0) || (!img_report.is_iso && !img_report.is_bootable_img)) {

View file

@ -506,7 +506,7 @@ extern void ListDialog(char* title, char* message, char** items, int size);
extern SIZE GetTextSize(HWND hCtrl, char* txt); extern SIZE GetTextSize(HWND hCtrl, char* txt);
extern BOOL ExtractAppIcon(const char* filename, BOOL bSilent); extern BOOL ExtractAppIcon(const char* filename, BOOL bSilent);
extern BOOL ExtractDOS(const char* path); 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 int64_t ExtractISOFile(const char* iso, const char* iso_file, const char* dest_file, DWORD attributes);
extern BOOL HasEfiImgBootLoaders(void); extern BOOL HasEfiImgBootLoaders(void);
extern BOOL DumpFatDir(const char* path, int32_t cluster); 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_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 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 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 BOOL AppendVHDFooter(const char* vhd_path);
extern int SetWinToGoIndex(void); extern int SetWinToGoIndex(void);
extern int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid); extern int IsHDD(DWORD DriveIndex, uint16_t vid, uint16_t pid, const char* strid);

View file

@ -229,12 +229,12 @@ static comp_assoc file_assoc[] = {
// For now we consider that an image that matches a known extension is bootable // 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 #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; char *p;
unsigned char *buf = NULL; unsigned char *buf = NULL;
int i; int i;
BOOL r = FALSE; BOOLEAN r = FALSE;
int64_t dc; int64_t dc;
img_report.compression_type = BLED_COMPRESSION_NONE; 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; HANDLE handle = INVALID_HANDLE_VALUE;
LARGE_INTEGER liImageSize; LARGE_INTEGER liImageSize;
@ -276,7 +276,7 @@ BOOL IsBootableImage(const char* path)
size_t i; size_t i;
uint32_t checksum, old_checksum; uint32_t checksum, old_checksum;
LARGE_INTEGER ptr; LARGE_INTEGER ptr;
BOOL is_bootable_img = FALSE; BOOLEAN is_bootable_img = FALSE;
uprintf("Disk image analysis:"); uprintf("Disk image analysis:");
handle = CreateFileU(path, GENERIC_READ, FILE_SHARE_READ, NULL, handle = CreateFileU(path, GENERIC_READ, FILE_SHARE_READ, NULL,
@ -286,9 +286,9 @@ BOOL IsBootableImage(const char* path)
goto out; goto out;
} }
is_bootable_img = (BOOLEAN)IsCompressedBootableImage(path); is_bootable_img = IsCompressedBootableImage(path);
if (img_report.compression_type == BLED_COMPRESSION_NONE) 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)) { if (!GetFileSizeEx(handle, &liImageSize)) {
uprintf(" Could not get image size: %s", WindowsErrorString()); uprintf(" Could not get image size: %s", WindowsErrorString());