diff --git a/src/format.c b/src/format.c index 84562f49..44de3c79 100644 --- a/src/format.c +++ b/src/format.c @@ -1553,7 +1553,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage) int64_t bled_ret; uint8_t *buffer = NULL; uint8_t *cmp_buffer = NULL; - int i, throttle_fast_zeroing = 0; + int i, *ptr, zero_data, throttle_fast_zeroing = 0; // We poked the MBR and other stuff, so we need to rewind li.QuadPart = 0; @@ -1630,11 +1630,10 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage) // we might speed things up by skipping empty blocks, or skipping the write if the data is the same. // Notes: A block is declared empty when all bits are either 0 (zeros) or 1 (flash block erased). // Also, a back-off strategy is used to limit reading. - if (throttle_fast_zeroing) { throttle_fast_zeroing--; - } else if ((fast_zeroing) && (hSourceImage == NULL)) { // currently only enabled for erase - + } else if (fast_zeroing) { + assert(hSourceImage == NULL); // Only enabled for zeroing CHECK_FOR_USER_CANCEL; // Read block and compare against the block that needs to be written @@ -1644,30 +1643,22 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage) goto out; } - // erase or write - if (hSourceImage == NULL) { - // Erase, check for an empty block - int *ptr = (int*)(cmp_buffer); - // Get first element - int value = ptr[0]; - // Check all bits are the same - if ((value != 0) && (value != -1)) { - goto blocknotempty; - } + // Check for an empty block + ptr = (int*)(cmp_buffer); + // Get first element + zero_data = ptr[0]; + // Check all bits are the same + if ((zero_data == 0) || (zero_data == -1)) { // Compare the rest of the block against the first element - for (i = 1; i < (int)(rSize/sizeof(int)); i++) { - if (ptr[i] != value) - goto blocknotempty; + for (i = 1; i < (int)(rSize / sizeof(int)); i++) { + if (ptr[i] != zero_data) + break; + } + if (i >= (int)(rSize / sizeof(int))) { + // Block is empty, skip write + wSize = rSize; + continue; } - // Block is empty, skip write - wSize = rSize; - continue; - blocknotempty: - ; - } else if (memcmp(cmp_buffer, buffer, rSize) == 0) { - // Write, block is unchanged, skip write - wSize = rSize; - continue; } // Move the file pointer position back for writing @@ -1676,7 +1667,7 @@ static BOOL WriteDrive(HANDLE hPhysicalDrive, HANDLE hSourceImage) uprintf("Error: Could not reset position - %s", WindowsErrorString()); goto out; } - // throttle read operations + // Throttle read operations throttle_fast_zeroing = 15; } diff --git a/src/rufus.rc b/src/rufus.rc index d9e10f7a..51deefcc 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 232, 326 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 3.2.1338" +CAPTION "Rufus 3.2.1339" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -392,8 +392,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,2,1338,0 - PRODUCTVERSION 3,2,1338,0 + FILEVERSION 3,2,1339,0 + PRODUCTVERSION 3,2,1339,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -411,13 +411,13 @@ BEGIN VALUE "Comments", "https://akeo.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "3.2.1338" + VALUE "FileVersion", "3.2.1339" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2018 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus-3.2.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "3.2.1338" + VALUE "ProductVersion", "3.2.1339" END END BLOCK "VarFileInfo" diff --git a/src/ui.c b/src/ui.c index 51cbeb53..66a5828f 100644 --- a/src/ui.c +++ b/src/ui.c @@ -638,7 +638,7 @@ void ToggleAdvancedFormatOptions(BOOL enable) void SetPersistenceSize(uint64_t pos, uint64_t max) { char tmp[12]; - int i, proposed_unit_selection; + int i, proposed_unit_selection = 0; LONGLONG base_unit = MB; HWND hCtrl;