[NTOSKRNL]
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 2 Dec 2012 15:30:59 +0000 (15:30 +0000)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sun, 2 Dec 2012 15:30:59 +0000 (15:30 +0000)
- Skip other spaces preceding a command option instead of increasing the reading pointer of a constant (should fix KDSERIAL).
- Use a macro for representing length in chars of constant strings instead of putting magic values.

svn path=/trunk/; revision=57787

reactos/ntoskrnl/kdbg/kdb.c

index b13384c..75fd5a5 100644 (file)
@@ -1705,30 +1705,29 @@ INIT_FUNCTION
 KdbpGetCommandLineSettings(
     PCHAR p1)
 {
-    PCHAR p2;
+#define CONST_STR_LEN(x) (sizeof(x)/sizeof(x[0]))
 
-    while (p1 && (p2 = strchr(p1, ' ')))
+    while (p1 && (p1 = strchr(p1, ' ')))
     {
-        p2 += 2;
+        /* Skip other spaces */
+        while (*p1 == ' ') ++p1;
 
-        if (!_strnicmp(p2, "KDSERIAL", 8))
+        if (!_strnicmp(p1, "KDSERIAL", CONST_STR_LEN("KDSERIAL")))
         {
-            p2 += 8;
+            p1 += CONST_STR_LEN("KDSERIAL");
             KdbDebugState |= KD_DEBUG_KDSERIAL;
             KdpDebugMode.Serial = TRUE;
         }
-        else if (!_strnicmp(p2, "KDNOECHO", 8))
+        else if (!_strnicmp(p1, "KDNOECHO", CONST_STR_LEN("KDNOECHO")))
         {
-            p2 += 8;
+            p1 += CONST_STR_LEN("KDNOECHO");
             KdbDebugState |= KD_DEBUG_KDNOECHO;
         }
-        else if (!_strnicmp(p2, "FIRSTCHANCE", 11))
+        else if (!_strnicmp(p1, "FIRSTCHANCE", CONST_STR_LEN("FIRSTCHANCE")))
         {
-            p2 += 11;
+            p1 += CONST_STR_LEN("FIRSTCHANCE");
             KdbpSetEnterCondition(-1, TRUE, KdbEnterAlways);
         }
-
-        p1 = p2;
     }
 }