[NTOS:KD] Simplify min-values calculations in KdpPrintToLogFile and KdpScreenPrint.

This commit is contained in:
Hermès Bélusca-Maïto 2023-01-09 16:08:07 +01:00
parent 4585372c6d
commit cee893be99
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -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;