缩小变量作用域:消除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
+2 -2
View File
@@ -81,9 +81,7 @@ static uint8_t rtc_calc_week(uint16_t y, uint8_t m, uint8_t d)
*/
static void unix_to_sd2506(uint32_t unix_secs, sd2506_time_t *p_sd_time)
{
uint32_t y, m, d;
uint8_t h, mi, s;
int is_leap;
/* 时分秒 */
{
@@ -97,6 +95,8 @@ static void unix_to_sd2506(uint32_t unix_secs, sd2506_time_t *p_sd_time)
/* 年月日 */
{
uint32_t y, m, d;
int is_leap;
uint64_t day_count = ((uint64_t)unix_secs / 86400uL);
y = 1970u;
+1 -2
View File
@@ -36,10 +36,9 @@
static int time_sync_open_listener(void)
{
int retry;
int s;
for (retry = 0; retry < 5; retry++) {
s = net_socket(NET_AF_INET, NET_SOCK_STREAM);
int s = net_socket(NET_AF_INET, NET_SOCK_STREAM);
if (s < 0) {
DBG_ERROR("time_sync: net_socket FAIL");
vTaskDelay(pdMS_TO_TICKS(500));
+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];
}