https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cee893be99b5cd159a580…
commit cee893be99b5cd159a580a5dec9eef1ccef93dc5
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Mon Jan 9 16:08:07 2023 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Mar 9 18:26:53 2023 +0100
[NTOS:KD] Simplify min-values calculations in KdpPrintToLogFile and KdpScreenPrint.
---
ntoskrnl/kd/kdio.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/ntoskrnl/kd/kdio.c b/ntoskrnl/kd/kdio.c
index 45733e0b3ca..5f2c7f966c7 100644
--- a/ntoskrnl/kd/kdio.c
+++ b/ntoskrnl/kd/kdio.c
@@ -174,10 +174,7 @@ KdpPrintToLogFile(PCHAR String,
OldIrql = KdbpAcquireLock(&KdpDebugLogSpinLock);
beg = KdpCurrentPosition;
- num = KdpFreeBytes;
- if (Length < num)
- num = Length;
-
+ num = min(Length, KdpFreeBytes);
if (num != 0)
{
end = (beg + num) % KdpBufferSize;
@@ -470,16 +467,14 @@ KdpScreenPrint(PCHAR String,
return;
if (KdpDmesgBuffer == NULL)
- return;
+ return;
/* Acquire the printing spinlock without waiting at raised IRQL */
OldIrql = KdbpAcquireLock(&KdpDmesgLogSpinLock);
- /* Invariant: always_true(KdpDmesgFreeBytes == KdpDmesgBufferSize);
- * set num to min(KdpDmesgFreeBytes, Length).
- */
- num = (Length < KdpDmesgFreeBytes) ? Length : KdpDmesgFreeBytes;
beg = KdpDmesgCurrentPosition;
+ /* Invariant: always_true(KdpDmesgFreeBytes == KdpDmesgBufferSize); */
+ num = min(Length, KdpDmesgFreeBytes);
if (num != 0)
{
end = (beg + num) % KdpDmesgBufferSize;