新增代码规范检查钩子(规范V1.0 可机械校验项)并修复存量违规
新增 scripts/check_coding_standard.py + coding-standard 钩子(S1~S9: 头文件保护宏、文件头注释、宏大写、_t 后缀、switch default、 禁 strcpy/sprintf/goto/Tab、函数注释) 修复存量违规:NET_* 字节序宏大写化、net_fd_set 等类型加 _t 后缀、 net_inet_ntoa 的 sprintf 改 snprintf、补 4 处函数注释与 ui_task.c 文件头 docs/代码规范/pre-commit使用说明.md:新增 2.8 节,修正失效文档路径
This commit is contained in:
@@ -35,11 +35,11 @@ static int check_socket_error(int sockfd);
|
||||
/*
|
||||
* 函数功能:I/O 多路复用(select 模式),等待多个 Socket 的读写事件就绪
|
||||
* 入口参数:nfds - 最大文件描述符数 +1 int > 0
|
||||
* readfds - 读事件集合指针 net_fd_set *(可为 NULL)
|
||||
* writefds - 写事件集合指针 net_fd_set *(可为 NULL)
|
||||
* exceptfds- 异常事件集合指针 net_fd_set *(可为 NULL)
|
||||
* timeout - 超时时间结构体指针 net_timeval *(NULL=无限等待)
|
||||
* 出口参数:readfds/writefds/exceptfds - 仅保留就绪的 Socket 位 net_fd_set *
|
||||
* readfds - 读事件集合指针 net_fd_set_t *(可为 NULL)
|
||||
* writefds - 写事件集合指针 net_fd_set_t *(可为 NULL)
|
||||
* exceptfds- 异常事件集合指针 net_fd_set_t *(可为 NULL)
|
||||
* timeout - 超时时间结构体指针 net_timeval_t *(NULL=无限等待)
|
||||
* 出口参数:readfds/writefds/exceptfds - 仅保留就绪的 Socket 位 net_fd_set_t *
|
||||
* 返回值:就绪的 Socket 数量(>= 0);-1 表示参数无效 int
|
||||
* 限定条件:net_init() + MX_FREERTOS_Init() 已执行;可在任意任务上下文调用
|
||||
* 函数说明:1. 轮询 Socket 控制块(RAM)中的读/写/异常状态,判断事件是否就绪
|
||||
@@ -49,13 +49,13 @@ static int check_socket_error(int sockfd);
|
||||
* 3. 阻塞等待直到有事件就绪或超时
|
||||
* 4. 通过 osDelay(1) 让出 CPU,平衡实时性与 CPU 利用率(状态刷新延迟 <=10ms)
|
||||
*/
|
||||
int net_select(int nfds, net_fd_set *readfds, net_fd_set *writefds,
|
||||
net_fd_set *exceptfds, net_timeval *timeout) {
|
||||
int net_select(int nfds, net_fd_set_t *readfds, net_fd_set_t *writefds,
|
||||
net_fd_set_t *exceptfds, net_timeval_t *timeout) {
|
||||
uint32_t start_tick;
|
||||
uint32_t timeout_ms = 0;
|
||||
net_fd_set result_read = {0};
|
||||
net_fd_set result_write = {0};
|
||||
net_fd_set result_except = {0};
|
||||
net_fd_set_t result_read = {0};
|
||||
net_fd_set_t result_write = {0};
|
||||
net_fd_set_t result_except = {0};
|
||||
int ready_count = 0;
|
||||
int i;
|
||||
|
||||
@@ -142,7 +142,7 @@ int net_select(int nfds, net_fd_set *readfds, net_fd_set *writefds,
|
||||
|
||||
/*
|
||||
* 函数功能:I/O 多路复用(poll 模式),等待多个 Socket 的读写事件就绪
|
||||
* 入口参数:fds - pollfd 数组指针 net_pollfd *
|
||||
* 入口参数:fds - pollfd 数组指针 net_pollfd_t *
|
||||
* nfds - 数组元素数量 int > 0
|
||||
* timeout - 超时时间(毫秒) int >= 0(-1=无限等待,但本实现按 >=0 处理)
|
||||
* 出口参数:fds[i].revents - 填充实际发生的事件掩码 short
|
||||
@@ -153,7 +153,7 @@ int net_select(int nfds, net_fd_set *readfds, net_fd_set *writefds,
|
||||
* 3. 阻塞等待直到有事件就绪或超时
|
||||
* 4. 通过 osDelay(1) 让出 CPU,平衡实时性与 CPU 利用率(状态刷新延迟 <=10ms)
|
||||
*/
|
||||
int net_poll_events(net_pollfd *fds, int nfds, int timeout) {
|
||||
int net_poll_events(net_pollfd_t *fds, int nfds, int timeout) {
|
||||
uint32_t start_tick;
|
||||
int ready = 0;
|
||||
int i;
|
||||
|
||||
Reference in New Issue
Block a user