From 443ade4c29be1cba32a8e76b6f7e84660912e831 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Mon, 25 Nov 2024 22:51:55 -0500 Subject: [PATCH] [sscanf] use rt_sscanf to replace sscanf --- bsp/nuvoton/libraries/m460/rtt_port/drv_common.c | 8 ++++---- bsp/nuvoton/libraries/ma35/rtt_port/drv_disp.c | 4 ++-- bsp/nuvoton/libraries/ma35/rtt_port/drv_sys.c | 8 ++++---- bsp/nuvoton/libraries/n9h30/rtt_port/drv_common.c | 4 ++-- bsp/nuvoton/libraries/nu_packages/Demo/wormhole_demo.c | 4 ++-- components/drivers/phy/ofw.c | 2 +- components/net/at/at_socket/at_socket.c | 4 ++-- examples/test/avl.c | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/bsp/nuvoton/libraries/m460/rtt_port/drv_common.c b/bsp/nuvoton/libraries/m460/rtt_port/drv_common.c index cb12e1fcb5..adbe38618e 100644 --- a/bsp/nuvoton/libraries/m460/rtt_port/drv_common.c +++ b/bsp/nuvoton/libraries/m460/rtt_port/drv_common.c @@ -167,12 +167,12 @@ void devmem(int argc, char *argv[]) if (argc == 3) { - if (sscanf(argv[2], "0x%x", &value) != 1) + if (rt_sscanf(argv[2], "0x%x", &value) != 1) goto exit_devmem; mode = 1; /*Write*/ } - if (sscanf(argv[1], "0x%x", &u32Addr) != 1) + if (rt_sscanf(argv[1], "0x%x", &u32Addr) != 1) goto exit_devmem; else if (!u32Addr || u32Addr & (4 - 1)) goto exit_devmem; @@ -203,12 +203,12 @@ void devmem2(int argc, char *argv[]) if (argc == 3) { - if (sscanf(argv[2], "%u", &value) != 1) + if (rt_sscanf(argv[2], "%u", &value) != 1) goto exit_devmem; word_count = value; } - if (sscanf(argv[1], "0x%x", &u32Addr) != 1) + if (rt_sscanf(argv[1], "0x%x", &u32Addr) != 1) goto exit_devmem; else if (!u32Addr || u32Addr & (4 - 1)) goto exit_devmem; diff --git a/bsp/nuvoton/libraries/ma35/rtt_port/drv_disp.c b/bsp/nuvoton/libraries/ma35/rtt_port/drv_disp.c index 842c567882..ddb3cb1d6d 100644 --- a/bsp/nuvoton/libraries/ma35/rtt_port/drv_disp.c +++ b/bsp/nuvoton/libraries/ma35/rtt_port/drv_disp.c @@ -399,7 +399,7 @@ static rt_err_t lcd_set_overlay_colkey(int argc, char **argv) for (index = 0; index < (len - 1); index ++) { - if (sscanf(argv[index + 1], "%x", &arg[index]) != 1) + if (rt_sscanf(argv[index + 1], "%x", &arg[index]) != 1) return -1; } rt_kprintf("colkeylow:0x%08x colkeyhigh:0x%08x\n", arg[0], arg[1]); @@ -459,7 +459,7 @@ static rt_err_t lcd_set_alphablend_opmode(int argc, char **argv) for (index = 0; index < (len - 1); index ++) { - if (sscanf(argv[index + 1], "%x", &arg[index]) != 1) + if (rt_sscanf(argv[index + 1], "%x", &arg[index]) != 1) return -1; } diff --git a/bsp/nuvoton/libraries/ma35/rtt_port/drv_sys.c b/bsp/nuvoton/libraries/ma35/rtt_port/drv_sys.c index d88df6677e..302730c81f 100644 --- a/bsp/nuvoton/libraries/ma35/rtt_port/drv_sys.c +++ b/bsp/nuvoton/libraries/ma35/rtt_port/drv_sys.c @@ -307,12 +307,12 @@ void devmem(int argc, char *argv[]) if (argc == 3) { - if (sscanf(argv[2], "0x%x", &value) != 1) + if (rt_sscanf(argv[2], "0x%x", &value) != 1) goto exit_devmem; mode = 1; //Write } - if (sscanf(argv[1], "0x%x", &u32Addr) != 1) + if (rt_sscanf(argv[1], "0x%x", &u32Addr) != 1) goto exit_devmem; else if (u32Addr & (4 - 1)) goto exit_devmem; @@ -343,12 +343,12 @@ void devmem2(int argc, char *argv[]) if (argc == 3) { - if (sscanf(argv[2], "%d", &value) != 1) + if (rt_sscanf(argv[2], "%d", &value) != 1) goto exit_devmem; word_count = value; } - if (sscanf(argv[1], "0x%x", &u32Addr) != 1) + if (rt_sscanf(argv[1], "0x%x", &u32Addr) != 1) goto exit_devmem; else if (u32Addr & (4 - 1)) goto exit_devmem; diff --git a/bsp/nuvoton/libraries/n9h30/rtt_port/drv_common.c b/bsp/nuvoton/libraries/n9h30/rtt_port/drv_common.c index 620e439dda..402c05a5dd 100644 --- a/bsp/nuvoton/libraries/n9h30/rtt_port/drv_common.c +++ b/bsp/nuvoton/libraries/n9h30/rtt_port/drv_common.c @@ -90,12 +90,12 @@ void devmem(int argc, char *argv[]) if (argc == 3) { - if (sscanf(argv[2], "0x%x", &value) != 1) + if (rt_sscanf(argv[2], "0x%x", &value) != 1) goto exit_devmem; mode = 1; //Write } - if (sscanf(argv[1], "0x%x", &u32Addr) != 1) + if (rt_sscanf(argv[1], "0x%x", &u32Addr) != 1) goto exit_devmem; else if (!u32Addr || u32Addr & (4 - 1)) goto exit_devmem; diff --git a/bsp/nuvoton/libraries/nu_packages/Demo/wormhole_demo.c b/bsp/nuvoton/libraries/nu_packages/Demo/wormhole_demo.c index bf2b8d7ad7..f079de13e4 100644 --- a/bsp/nuvoton/libraries/nu_packages/Demo/wormhole_demo.c +++ b/bsp/nuvoton/libraries/nu_packages/Demo/wormhole_demo.c @@ -298,12 +298,12 @@ void whc_devmem(int argc, char *argv[]) if (argc == 3) { - if (sscanf(argv[2], "0x%x", &value) != 1) + if (rt_sscanf(argv[2], "0x%x", &value) != 1) goto exit_devmem; mode = 1; //Write } - if (sscanf(argv[1], "0x%x", &u32Addr) != 1) + if (rt_sscanf(argv[1], "0x%x", &u32Addr) != 1) goto exit_devmem; else if (u32Addr & (4 - 1)) goto exit_devmem; diff --git a/components/drivers/phy/ofw.c b/components/drivers/phy/ofw.c index 77429ec4c4..316bbc2fde 100644 --- a/components/drivers/phy/ofw.c +++ b/components/drivers/phy/ofw.c @@ -116,7 +116,7 @@ rt_err_t rt_ofw_get_phyid(struct rt_ofw_node *np,rt_uint32_t *id) if (ret) return ret; - ret = sscanf(phy_id,"ethernet-phy-id%4x.%4x",&upper, &lower); + ret = rt_sscanf(phy_id,"ethernet-phy-id%4x.%4x",&upper, &lower); if(ret != 2) return -RT_ERROR; diff --git a/components/net/at/at_socket/at_socket.c b/components/net/at/at_socket/at_socket.c index 4c5dee2b62..4695d3c102 100644 --- a/components/net/at/at_socket/at_socket.c +++ b/components/net/at/at_socket/at_socket.c @@ -759,7 +759,7 @@ static void at_connect_notice_cb(struct at_socket *sock, at_socket_evt_t event, } new_sock = at_get_socket(new_socket); new_sock->state = AT_SOCKET_CONNECT; - sscanf(buff, "SOCKET:%d", &base_socket); + rt_sscanf(buff, "SOCKET:%d", &base_socket); LOG_D("ACCEPT BASE SOCKET: %d", base_socket); new_sock->user_data = (void *)base_socket; @@ -985,7 +985,7 @@ int at_accept(int socket, struct sockaddr *name, socklen_t *namelen) at_do_event_changes(sock, AT_EVENT_RECV, RT_FALSE); } - sscanf(&receive_buff[0], "SOCKET:%d", &new_socket); + rt_sscanf(&receive_buff[0], "SOCKET:%d", &new_socket); new_sock = at_get_socket(new_socket); ip4_addr_set_any(&remote_addr); ipaddr_port_to_socketaddr(name, &remote_addr, &remote_port); diff --git a/examples/test/avl.c b/examples/test/avl.c index 961b46cc3c..b5141c5d9d 100644 --- a/examples/test/avl.c +++ b/examples/test/avl.c @@ -556,7 +556,7 @@ int main(int argc, char *argv[]) { if (argc == 2) { - sscanf(argv[1], "%d", &loop_count); + rt_sscanf(argv[1], "%d", &loop_count); } else {