缩小变量作用域:消除18处variableScope,声明移入实际使用块

This commit is contained in:
2026-09-01 13:59:44 +08:00
parent f1d5483a49
commit 6307c3f635
9 changed files with 17 additions and 25 deletions
+1 -2
View File
@@ -91,13 +91,12 @@ size_t ringbuf_peek(const ringbuf_t *rb, uint8_t *data, size_t len)
{
size_t n = 0;
size_t i = 0;
size_t idx;
n = ringbuf_avail(rb);
n = (n < len) ? n : len;
for (i = 0; i < n; i++) {
idx = (rb->tail + i) % rb->size;
size_t idx = (rb->tail + i) % rb->size;
data[i] = rb->buf[idx];
}