Skip to content

Commit 3b92889

Browse files
committed
[FREELDR] Simplify some control branches in loops (reactos#7417)
Collapse some tests; remove redundant `continue;` Pointed out by Serge Gautherie.
1 parent 5ed33de commit 3b92889

File tree

3 files changed

+20
-47
lines changed

3 files changed

+20
-47
lines changed

boot/freeldr/freeldr/arch/i386/pc/pcdisk.c

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -605,22 +605,13 @@ PcDiskReadLogicalSectorsLBA(
605605

606606
Int386(0x13, &RegsIn, &RegsOut);
607607

608-
/* If it worked return TRUE */
609-
if (INT386_SUCCESS(RegsOut))
610-
{
611-
return TRUE;
612-
}
613-
/* If it was a corrected ECC error then the data is still good */
614-
else if (RegsOut.b.ah == 0x11)
615-
{
608+
/* If it worked, or if it was a corrected ECC error
609+
* and the data is still good, return success */
610+
if (INT386_SUCCESS(RegsOut) || (RegsOut.b.ah == 0x11))
616611
return TRUE;
617-
}
618-
/* If it failed then do the next retry */
619-
else
620-
{
621-
DiskResetController(DriveNumber);
622-
continue;
623-
}
612+
613+
/* It failed, do the next retry */
614+
DiskResetController(DriveNumber);
624615
}
625616

626617
/* If we get here then the read failed */
@@ -715,22 +706,13 @@ PcDiskReadLogicalSectorsCHS(
715706
{
716707
Int386(0x13, &RegsIn, &RegsOut);
717708

718-
/* If it worked break out */
719-
if (INT386_SUCCESS(RegsOut))
720-
{
709+
/* If it worked, or if it was a corrected ECC error
710+
* and the data is still good, break out */
711+
if (INT386_SUCCESS(RegsOut) || (RegsOut.b.ah == 0x11))
721712
break;
722-
}
723-
/* If it was a corrected ECC error then the data is still good */
724-
else if (RegsOut.b.ah == 0x11)
725-
{
726-
break;
727-
}
728-
/* If it failed then do the next retry */
729-
else
730-
{
731-
DiskResetController(DriveNumber);
732-
continue;
733-
}
713+
714+
/* It failed, do the next retry */
715+
DiskResetController(DriveNumber);
734716
}
735717

736718
/* If we retried 3 times then fail */

boot/freeldr/freeldr/arch/i386/pc98/pc98disk.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,22 +219,13 @@ Pc98DiskReadLogicalSectorsLBA(
219219
{
220220
Int386(0x1B, &RegsIn, &RegsOut);
221221

222-
/* If it worked return TRUE */
223-
if (INT386_SUCCESS(RegsOut))
224-
{
225-
return TRUE;
226-
}
227-
/* If it was a corrected ECC error then the data is still good */
228-
else if (RegsOut.b.ah == 0x08)
229-
{
222+
/* If it worked, or if it was a corrected ECC error
223+
* and the data is still good, return success */
224+
if (INT386_SUCCESS(RegsOut) || (RegsOut.b.ah == 0x08))
230225
return TRUE;
231-
}
232-
/* If it failed the do the next retry */
233-
else
234-
{
235-
DiskResetController(DiskDrive);
236-
continue;
237-
}
226+
227+
/* It failed, do the next retry */
228+
DiskResetController(DiskDrive);
238229
}
239230
}
240231

boot/freeldr/freeldr/lib/fs/fat.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,8 @@ BOOLEAN FatSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID Directory
668668
// See if the file name matches either the short or long name
669669
//
670670
if (((strlen(FileName) == strlen(LfnNameBuffer)) && (_stricmp(FileName, LfnNameBuffer) == 0)) ||
671-
((strlen(FileName) == strlen(ShortNameBuffer)) && (_stricmp(FileName, ShortNameBuffer) == 0))) {
671+
((strlen(FileName) == strlen(ShortNameBuffer)) && (_stricmp(FileName, ShortNameBuffer) == 0)))
672+
{
672673
//
673674
// We found the entry, now fill in the FAT_FILE_INFO struct
674675
//
@@ -702,7 +703,6 @@ BOOLEAN FatSearchDirectoryBufferForFile(PFAT_VOLUME_INFO Volume, PVOID Directory
702703
//
703704
RtlZeroMemory(ShortNameBuffer, 13 * sizeof(UCHAR));
704705
RtlZeroMemory(LfnNameBuffer, 261 * sizeof(UCHAR));
705-
continue;
706706
}
707707

708708
return FALSE;

0 commit comments

Comments
 (0)