From 4d0642b67fe43e0f64a24c2c8a8a55e8805fa6c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Wed, 18 Mar 2026 22:33:36 +0100 Subject: [PATCH] [FREELDR][KDCOM][KDGDB][NTOS:KD] Minor code comments enhancements --- boot/freeldr/freeldr/lib/comm/rs232.c | 7 +++---- boot/freeldr/freeldr/lib/debug.c | 10 ++++------ drivers/base/kdcom/kdcom.c | 21 +++++++++------------ drivers/base/kdgdb/kdcom.c | 19 ++++++++----------- ntoskrnl/kd/i386/kdserial.c | 7 +++---- ntoskrnl/kd/kdmain.c | 8 ++++---- 6 files changed, 31 insertions(+), 41 deletions(-) diff --git a/boot/freeldr/freeldr/lib/comm/rs232.c b/boot/freeldr/freeldr/lib/comm/rs232.c index 0d2bc404a8e..5aa56a2a09f 100644 --- a/boot/freeldr/freeldr/lib/comm/rs232.c +++ b/boot/freeldr/freeldr/lib/comm/rs232.c @@ -57,10 +57,9 @@ BOOLEAN Rs232PortInitialize(IN ULONG ComPort, if (ComPort == 0) { /* - * Start enumerating COM ports from the last one to the first one, - * and break when we find a valid port. - * If we reach the first element of the list, the invalid COM port, - * then it means that no valid port was found. + * Enumerate COM ports from the last to the first one, and stop + * when we find a valid port. If we reach the first list element + * (the undefined COM port), no valid port was found. */ for (ComPort = MAX_COM_PORTS; ComPort > 0; ComPort--) { diff --git a/boot/freeldr/freeldr/lib/debug.c b/boot/freeldr/freeldr/lib/debug.c index f7170ccd21f..e6d2cf6538b 100644 --- a/boot/freeldr/freeldr/lib/debug.c +++ b/boot/freeldr/freeldr/lib/debug.c @@ -109,11 +109,11 @@ DebugInit( /* * Check if we got /DEBUGPORT parameters. - * NOTE: Inspired by reactos/ntoskrnl/kd/kdinit.c, KdInitSystem(...) + * NOTE: Inspired by ntoskrnl/kd/kdinit.c, KdInitSystem(...) */ while (PortString) { - /* Move past the actual string, to reach the port*/ + /* Move past the actual string */ PortString += strlen("DEBUGPORT"); /* Now get past any spaces and skip the equal sign */ @@ -147,13 +147,11 @@ DebugInit( /* Check if we got a baud rate */ if (BaudString) { - /* Move past the actual string, to reach the rate */ + /* Move past the actual string and any spaces */ BaudString += strlen("BAUDRATE"); - - /* Now get past any spaces */ while (*BaudString == ' ') BaudString++; - /* And make sure we have a rate */ + /* Make sure we have a rate */ if (*BaudString) { /* Read and set it */ diff --git a/drivers/base/kdcom/kdcom.c b/drivers/base/kdcom/kdcom.c index d83ec56ad75..bc8c07bde2d 100644 --- a/drivers/base/kdcom/kdcom.c +++ b/drivers/base/kdcom/kdcom.c @@ -1,7 +1,7 @@ /* * COPYRIGHT: GPL, see COPYING in the top level directory * PROJECT: ReactOS kernel - * FILE: drivers/base/kddll/kdcom.c + * FILE: drivers/base/kdcom/kdcom.c * PURPOSE: COM port functions for the kernel debugger. * PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org) */ @@ -147,7 +147,7 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) /* Check if we got the /DEBUGPORT parameter */ if (PortString) { - /* Move past the actual string, to reach the port*/ + /* Move past the actual string */ PortString += strlen("DEBUGPORT"); /* Now get past any spaces and skip the equal sign */ @@ -160,7 +160,7 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) return STATUS_INVALID_PARAMETER; } - /* Check for a valid Serial Port */ + /* Check for a valid serial port */ PortString += 3; Value = atol(PortString); if (Value >= sizeof(BaseArray) / sizeof(BaseArray[0])) @@ -175,13 +175,11 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) /* Check if we got a baud rate */ if (BaudString) { - /* Move past the actual string, to reach the rate */ + /* Move past the actual string and any spaces */ BaudString += strlen("BAUDRATE"); - - /* Now get past any spaces */ while (*BaudString == ' ') BaudString++; - /* And make sure we have a rate */ + /* Make sure we have a rate */ if (*BaudString) { /* Read and set it */ @@ -194,14 +192,13 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) #ifdef KDDEBUG /* * Try to find a free COM port and use it as the KD debugging port. - * NOTE: Inspired by reactos/boot/freeldr/freeldr/comm/rs232.c, Rs232PortInitialize(...) + * NOTE: Inspired by freeldr/comm/rs232.c, Rs232PortInitialize(...) */ { /* - * Start enumerating COM ports from the last one to the first one, - * and break when we find a valid port. - * If we reach the first element of the list, the invalid COM port, - * then it means that no valid port was found. + * Enumerate COM ports from the last to the first one, and stop + * when we find a valid port. If we reach the first list element + * (the undefined COM port), no valid port was found. */ ULONG ComPort; for (ComPort = MAX_COM_PORTS; ComPort > 0; ComPort--) diff --git a/drivers/base/kdgdb/kdcom.c b/drivers/base/kdgdb/kdcom.c index df96d177179..683eb379684 100644 --- a/drivers/base/kdgdb/kdcom.c +++ b/drivers/base/kdgdb/kdcom.c @@ -141,7 +141,7 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) /* Check if we got the /DEBUGPORT parameter */ if (PortString) { - /* Move past the actual string, to reach the port*/ + /* Move past the actual string */ PortString += strlen("DEBUGPORT"); /* Now get past any spaces and skip the equal sign */ @@ -154,7 +154,7 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) return STATUS_INVALID_PARAMETER; } - /* Check for a valid Serial Port */ + /* Check for a valid serial port */ PortString += 3; Value = atol(PortString); if (Value >= sizeof(BaseArray) / sizeof(BaseArray[0])) @@ -169,13 +169,11 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) /* Check if we got a baud rate */ if (BaudString) { - /* Move past the actual string, to reach the rate */ + /* Move past the actual string and any spaces */ BaudString += strlen("BAUDRATE"); - - /* Now get past any spaces */ while (*BaudString == ' ') BaudString++; - /* And make sure we have a rate */ + /* Make sure we have a rate */ if (*BaudString) { /* Read and set it */ @@ -188,14 +186,13 @@ KdDebuggerInitialize0(IN PLOADER_PARAMETER_BLOCK LoaderBlock OPTIONAL) #ifdef KDDEBUG /* * Try to find a free COM port and use it as the KD debugging port. - * NOTE: Inspired by reactos/boot/freeldr/freeldr/comm/rs232.c, Rs232PortInitialize(...) + * NOTE: Inspired by freeldr/comm/rs232.c, Rs232PortInitialize(...) */ { /* - * Start enumerating COM ports from the last one to the first one, - * and break when we find a valid port. - * If we reach the first element of the list, the invalid COM port, - * then it means that no valid port was found. + * Enumerate COM ports from the last to the first one, and stop + * when we find a valid port. If we reach the first list element + * (the undefined COM port), no valid port was found. */ ULONG ComPort; for (ComPort = MAX_COM_PORTS; ComPort > 0; ComPort--) diff --git a/ntoskrnl/kd/i386/kdserial.c b/ntoskrnl/kd/i386/kdserial.c index 1b24b56f991..867f7ba3703 100644 --- a/ntoskrnl/kd/i386/kdserial.c +++ b/ntoskrnl/kd/i386/kdserial.c @@ -45,10 +45,9 @@ KdPortInitializeEx( if (ComPortNumber == 0) { /* - * Start enumerating COM ports from the last one to the first one, - * and break when we find a valid port. - * If we reach the first element of the list, the invalid COM port, - * then it means that no valid port was found. + * Enumerate COM ports from the last to the first one, and stop + * when we find a valid port. If we reach the first list element + * (the undefined COM port), no valid port was found. */ for (ComPortNumber = MAX_COM_PORTS; ComPortNumber > 0; ComPortNumber--) { diff --git a/ntoskrnl/kd/kdmain.c b/ntoskrnl/kd/kdmain.c index c5b3e828e2e..9e9c71b091c 100644 --- a/ntoskrnl/kd/kdmain.c +++ b/ntoskrnl/kd/kdmain.c @@ -59,14 +59,14 @@ KdpGetDebugMode( /* Check for Screen Debugging */ if (!_strnicmp(p2, "SCREEN", 6)) { - /* Enable It */ + /* Enable it */ p2 += 6; KdpDebugMode.Screen = TRUE; } /* Check for Serial Debugging */ else if (!_strnicmp(p2, "COM", 3)) { - /* Check for a valid Serial Port */ + /* Check for a valid serial port */ p2 += 3; if (*p2 != ':') { @@ -94,7 +94,7 @@ KdpGetDebugMode( /* Check for Debug Log Debugging */ else if (!_strnicmp(p2, "FILE", 4)) { - /* Enable It */ + /* Enable it */ p2 += 4; KdpDebugMode.File = TRUE; if (*p2 == ':') @@ -139,7 +139,7 @@ KdDebuggerInitialize0( /* Check if we got the /DEBUGPORT parameter(s) */ while (Port) { - /* Move past the actual string, to reach the port*/ + /* Move past the actual string */ Port += sizeof("DEBUGPORT") - 1; /* Now get past any spaces and skip the equal sign */