https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3b928898ef09ece59ba63ece3efdd4467195d74a

commit 3b928898ef09ece59ba63ece3efdd4467195d74a
Author:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
AuthorDate: Wed Oct 2 19:24:42 2024 +0200
Commit:     Hermès Bélusca-Maïto <hermes.belusca-ma...@reactos.org>
CommitDate: Thu Oct 3 11:47:31 2024 +0200

    [FREELDR] Simplify some control branches in loops (#7417)
    
    Collapse some tests; remove redundant `continue;`
    
    Pointed out by Serge Gautherie.
---
 boot/freeldr/freeldr/arch/i386/pc/pcdisk.c     | 42 ++++++++------------------
 boot/freeldr/freeldr/arch/i386/pc98/pc98disk.c | 21 ++++---------
 boot/freeldr/freeldr/lib/fs/fat.c              |  4 +--
 3 files changed, 20 insertions(+), 47 deletions(-)

diff --git a/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c 
b/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c
index 1bd498e6730..cf13ed663dc 100644
--- a/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c
+++ b/boot/freeldr/freeldr/arch/i386/pc/pcdisk.c
@@ -605,22 +605,13 @@ PcDiskReadLogicalSectorsLBA(
 
         Int386(0x13, &RegsIn, &RegsOut);
 
-        /* If it worked return TRUE */
-        if (INT386_SUCCESS(RegsOut))
-        {
-            return TRUE;
-        }
-        /* If it was a corrected ECC error then the data is still good */
-        else if (RegsOut.b.ah == 0x11)
-        {
+        /* If it worked, or if it was a corrected ECC error
+         * and the data is still good, return success */
+        if (INT386_SUCCESS(RegsOut) || (RegsOut.b.ah == 0x11))
             return TRUE;
-        }
-        /* If it failed then do the next retry */
-        else
-        {
-            DiskResetController(DriveNumber);
-            continue;
-        }
+
+        /* It failed, do the next retry */
+        DiskResetController(DriveNumber);
     }
 
     /* If we get here then the read failed */
@@ -715,22 +706,13 @@ PcDiskReadLogicalSectorsCHS(
         {
             Int386(0x13, &RegsIn, &RegsOut);
 
-            /* If it worked break out */
-            if (INT386_SUCCESS(RegsOut))
-            {
+            /* If it worked, or if it was a corrected ECC error
+             * and the data is still good, break out */
+            if (INT386_SUCCESS(RegsOut) || (RegsOut.b.ah == 0x11))
                 break;
-            }
-            /* If it was a corrected ECC error then the data is still good */
-            else if (RegsOut.b.ah == 0x11)
-            {
-                break;
-            }
-            /* If it failed then do the next retry */
-            else
-            {
-                DiskResetController(DriveNumber);
-                continue;
-            }
+
+            /* It failed, do the next retry */
+            DiskResetController(DriveNumber);
         }
 
         /* If we retried 3 times then fail */
diff --git a/boot/freeldr/freeldr/arch/i386/pc98/pc98disk.c 
b/boot/freeldr/freeldr/arch/i386/pc98/pc98disk.c
index 9eef9d45f71..e6f98d136f7 100644
--- a/boot/freeldr/freeldr/arch/i386/pc98/pc98disk.c
+++ b/boot/freeldr/freeldr/arch/i386/pc98/pc98disk.c
@@ -219,22 +219,13 @@ Pc98DiskReadLogicalSectorsLBA(
         {
             Int386(0x1B, &RegsIn, &RegsOut);
 
-            /* If it worked return TRUE */
-            if (INT386_SUCCESS(RegsOut))
-            {
-                return TRUE;
-            }
-            /* If it was a corrected ECC error then the data is still good */
-            else if (RegsOut.b.ah == 0x08)
-            {
+            /* If it worked, or if it was a corrected ECC error
+             * and the data is still good, return success */
+            if (INT386_SUCCESS(RegsOut) || (RegsOut.b.ah == 0x08))
                 return TRUE;
-            }
-            /* If it failed the do the next retry */
-            else
-            {
-                DiskResetController(DiskDrive);
-                continue;
-            }
+
+            /* It failed, do the next retry */
+            DiskResetController(DiskDrive);
         }
     }
 
diff --git a/boot/freeldr/freeldr/lib/fs/fat.c 
b/boot/freeldr/freeldr/lib/fs/fat.c
index 556f8086430..257f1e43c63 100644
--- a/boot/freeldr/freeldr/lib/fs/fat.c
+++ b/boot/freeldr/freeldr/lib/fs/fat.c
@@ -668,7 +668,8 @@ BOOLEAN FatSearchDirectoryBufferForFile(PFAT_VOLUME_INFO 
Volume, PVOID Directory
         // See if the file name matches either the short or long name
         //
         if (((strlen(FileName) == strlen(LfnNameBuffer)) && 
(_stricmp(FileName, LfnNameBuffer) == 0)) ||
-            ((strlen(FileName) == strlen(ShortNameBuffer)) && 
(_stricmp(FileName, ShortNameBuffer) == 0)))        {
+            ((strlen(FileName) == strlen(ShortNameBuffer)) && 
(_stricmp(FileName, ShortNameBuffer) == 0)))
+        {
             //
             // We found the entry, now fill in the FAT_FILE_INFO struct
             //
@@ -702,7 +703,6 @@ BOOLEAN FatSearchDirectoryBufferForFile(PFAT_VOLUME_INFO 
Volume, PVOID Directory
         //
         RtlZeroMemory(ShortNameBuffer, 13 * sizeof(UCHAR));
         RtlZeroMemory(LfnNameBuffer, 261 * sizeof(UCHAR));
-        continue;
     }
 
     return FALSE;

Reply via email to