-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[misc] improve readability of error code handling
* Also don't pass a read size value in WriteFileWithRetry() if we don't use it.
- Loading branch information
Showing
25 changed files
with
257 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* Copyright 1992-1994 Remy Card <[email protected]> | ||
* Copyright 1995-1999 Theodore Ts'o | ||
* Copyright 1999 David Beattie | ||
* Copyright 2011-2023 Pete Batard <[email protected]> | ||
* Copyright 2011-2024 Pete Batard <[email protected]> | ||
* | ||
* This file is based on the minix file system programs fsck and mkfs | ||
* written and copyrighted by Linus Torvalds <[email protected]> | ||
|
@@ -318,7 +318,7 @@ static void CALLBACK alarm_intr(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dw | |
{ | ||
if (!num_blocks) | ||
return; | ||
if (FormatStatus) { | ||
if (ErrorStatus) { | ||
uprintf("%sInterrupting at block %" PRIu64 "\n", bb_prefix, | ||
(unsigned long long) currently_testing); | ||
cancel_ops = -1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* | ||
* Copyright 1995, 1996, 1997, 1998, 1999 by Theodore Ts'o | ||
* Copyright 1999 by David Beattie | ||
* Copyright 2011-2018 by Pete Batard | ||
* Copyright 2011-2024 by Pete Batard | ||
* | ||
* This file is based on the minix file system programs fsck and mkfs | ||
* written and copyrighted by Linus Torvalds <[email protected]> | ||
|
@@ -28,12 +28,11 @@ typedef struct bb_struct_u64_iterate *bb_badblocks_iterate; | |
typedef struct bb_struct_u64_list *bb_u64_list; | ||
typedef struct bb_struct_u64_iterate *bb_u64_iterate; | ||
|
||
#define BB_ET_NO_MEMORY (ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NOT_ENOUGH_MEMORY) | ||
#define BB_ET_MAGIC_BADBLOCKS_LIST (ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_OBJECT_IN_LIST) | ||
#define BB_ET_MAGIC_BADBLOCKS_ITERATE (ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INVALID_BLOCK) | ||
#define BB_ET_NO_MEMORY RUFUS_ERROR(ERROR_NOT_ENOUGH_MEMORY) | ||
#define BB_ET_MAGIC_BADBLOCKS_LIST RUFUS_ERROR(ERROR_OBJECT_IN_LIST) | ||
#define BB_ET_MAGIC_BADBLOCKS_ITERATE RUFUS_ERROR(ERROR_INVALID_BLOCK) | ||
|
||
#define BB_CHECK_MAGIC(struct, code) \ | ||
if ((struct)->magic != (code)) return (code) | ||
#define BB_CHECK_MAGIC(struct, code) if ((struct)->magic != (code)) return (code) | ||
#define BB_BAD_BLOCKS_THRESHOLD 256 | ||
#define BB_BLOCKS_AT_ONCE 64 | ||
#define BB_SYS_PAGE_SIZE 4096 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* Rufus: The Reliable USB Formatting Utility | ||
* DOS boot file extraction, from the FAT12 floppy image in diskcopy.dll | ||
* (MS WinME DOS) or from the embedded FreeDOS resource files | ||
* Copyright © 2011-2023 Pete Batard <[email protected]> | ||
* Copyright © 2011-2024 Pete Batard <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -352,7 +352,7 @@ BOOL ExtractFreeDOS(const char* path) | |
IDR_FD_EGA17_CPX, IDR_FD_EGA18_CPX }; | ||
char filename[MAX_PATH], locale_path[MAX_PATH]; | ||
BYTE* res_data; | ||
DWORD res_size, Size; | ||
DWORD res_size; | ||
HANDLE hFile; | ||
int i; | ||
|
||
|
@@ -366,10 +366,10 @@ BOOL ExtractFreeDOS(const char* path) | |
static_strcat(locale_path, "LOCALE\\"); | ||
CreateDirectoryA(locale_path, NULL); | ||
|
||
for (i=0; i<ARRAYSIZE(res_name); i++) { | ||
for (i = 0; i < ARRAYSIZE(res_name); i++) { | ||
res_data = (BYTE*)GetResource(hMainInstance, MAKEINTRESOURCEA(res_id[i]), _RT_RCDATA, res_name[i], &res_size, FALSE); | ||
|
||
static_strcpy(filename, ((i<2)?path:locale_path)); | ||
static_strcpy(filename, ((i<2) ? path : locale_path)); | ||
static_strcat(filename, res_name[i]); | ||
|
||
hFile = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, | ||
|
@@ -379,7 +379,7 @@ BOOL ExtractFreeDOS(const char* path) | |
return FALSE; | ||
} | ||
|
||
if (!WriteFileWithRetry(hFile, res_data, res_size, &Size, WRITE_RETRIES)) { | ||
if (!WriteFileWithRetry(hFile, res_data, res_size, NULL, WRITE_RETRIES)) { | ||
uprintf("Could not write file '%s': %s.", filename, WindowsErrorString()); | ||
safe_closehandle(hFile); | ||
return FALSE; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* | ||
* Copyright (C) 1993, 1994, 1995 Theodore Ts'o. | ||
* Copyright (C) 1998 Andrey Shedel <[email protected]> | ||
* Copyright (C) 2018-2019 Pete Batard <[email protected]> | ||
* Copyright (C) 2018-2024 Pete Batard <[email protected]> | ||
* | ||
* %Begin-Header% | ||
* This file may be redistributed under the terms of the GNU Library | ||
|
@@ -180,7 +180,7 @@ static __inline unsigned _MapNtStatus(IN NTSTATUS Status) | |
// Return the last Windows Error | ||
DWORD ext2_last_winerror(DWORD default_error) | ||
{ | ||
return ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | (LastWinError ? LastWinError : default_error); | ||
return RUFUS_ERROR(LastWinError ? LastWinError : default_error); | ||
} | ||
|
||
// | ||
|
Oops, something went wrong.