git: d5024179b8dd - stable/15 - sound: Simplify sndbuf_clear() loop

From: Christos Margiolis <christos_at_FreeBSD.org>
Date: Tue, 18 Nov 2025 00:51:54 UTC
The branch stable/15 has been updated by christos:

URL: https://cgit.FreeBSD.org/src/commit/?id=d5024179b8dd1c1779adff1c762f6f6c0abae557

commit d5024179b8dd1c1779adff1c762f6f6c0abae557
Author:     Christos Margiolis <christos@FreeBSD.org>
AuthorDate: 2025-11-11 12:05:24 +0000
Commit:     Christos Margiolis <christos@FreeBSD.org>
CommitDate: 2025-11-18 00:51:22 +0000

    sound: Simplify sndbuf_clear() loop
    
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Reviewed by:    markj
    Differential Revision:  https://reviews.freebsd.org/D53526
    
    (cherry picked from commit c0e96595a4da90d890be88881a5dc3381da59dd7)
---
 sys/dev/sound/pcm/buffer.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/sys/dev/sound/pcm/buffer.c b/sys/dev/sound/pcm/buffer.c
index e3d2f27f9f81..0cfa04fc3167 100644
--- a/sys/dev/sound/pcm/buffer.c
+++ b/sys/dev/sound/pcm/buffer.c
@@ -276,16 +276,10 @@ sndbuf_clear(struct snd_dbuf *b, unsigned int length)
 		length = b->bufsize;
 
 	data = sndbuf_zerodata(b->fmt);
-
 	i = sndbuf_getfreeptr(b);
 	p = sndbuf_getbuf(b);
-	while (length > 0) {
-		p[i] = data;
-		length--;
-		i++;
-		if (i >= b->bufsize)
-			i = 0;
-	}
+	for  (; length > 0; length--, i++)
+		p[i % b->bufsize] = data;
 }
 
 /**