From 56362bd942605e51bb1dbce1111c38d38b26616b Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 11 Jan 2022 18:46:29 -0500 Subject: [PATCH 1/2] format codes --- ntp/ntp.c | 2 +- ping/ping.c | 2 +- tcpdump/tcpdump.c | 2 +- telnet/telnet.c | 6 +++--- tftp/tftp.h | 2 +- tftp/tftp_client.c | 2 +- tftp/tftp_port.c | 2 +- tftp/tftp_server.c | 2 +- tftp/tftp_xfer.c | 2 +- tftp/tftp_xfer.h | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ntp/ntp.c b/ntp/ntp.c index 2f5e7a6..9279bb2 100644 --- a/ntp/ntp.c +++ b/ntp/ntp.c @@ -410,7 +410,7 @@ static rt_bool_t ntp_check_network(void) { #ifdef RT_USING_NETDEV struct netdev * netdev = netdev_get_by_family(AF_INET); - return (netdev && netdev_is_link_up(netdev)); + return (netdev && netdev_is_link_up(netdev)); #else return RT_TRUE; #endif diff --git a/ping/ping.c b/ping/ping.c index b830809..a0f58df 100644 --- a/ping/ping.c +++ b/ping/ping.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2021, RT-Thread Development Team + * Copyright (c) 2006-2022, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/tcpdump/tcpdump.c b/tcpdump/tcpdump.c index 372a973..cfbe2c3 100644 --- a/tcpdump/tcpdump.c +++ b/tcpdump/tcpdump.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2021, RT-Thread Development Team + * Copyright (c) 2006-2022, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/telnet/telnet.c b/telnet/telnet.c index 9fdfcde..8f7fe0e 100644 --- a/telnet/telnet.c +++ b/telnet/telnet.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2021, RT-Thread Development Team + * Copyright (c) 2006-2022, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * @@ -325,10 +325,10 @@ static void telnet_thread(void* parameter) } if(setsockopt(telnet->server_fd, SOL_SOCKET, SO_KEEPALIVE, (void *)&keepalive, sizeof(keepalive)) < 0) - { + { rt_kprintf("telnet:set socket keepalive failed\n"); return; - } + } addr.sin_family = AF_INET; addr.sin_port = htons(TELNET_PORT); diff --git a/tftp/tftp.h b/tftp/tftp.h index 7a10515..88e1dab 100644 --- a/tftp/tftp.h +++ b/tftp/tftp.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2021, RT-Thread Development Team + * Copyright (c) 2006-2022, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/tftp/tftp_client.c b/tftp/tftp_client.c index 7abe65d..f78b79c 100644 --- a/tftp/tftp_client.c +++ b/tftp/tftp_client.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2021, RT-Thread Development Team + * Copyright (c) 2006-2022, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/tftp/tftp_port.c b/tftp/tftp_port.c index c541444..13d2f24 100644 --- a/tftp/tftp_port.c +++ b/tftp/tftp_port.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2021, RT-Thread Development Team + * Copyright (c) 2006-2022, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/tftp/tftp_server.c b/tftp/tftp_server.c index f358fce..cced845 100644 --- a/tftp/tftp_server.c +++ b/tftp/tftp_server.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2021, RT-Thread Development Team + * Copyright (c) 2006-2022, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/tftp/tftp_xfer.c b/tftp/tftp_xfer.c index 7d54eb2..66ca783 100644 --- a/tftp/tftp_xfer.c +++ b/tftp/tftp_xfer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2021, RT-Thread Development Team + * Copyright (c) 2006-2022, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/tftp/tftp_xfer.h b/tftp/tftp_xfer.h index 7ab16dd..c410aff 100644 --- a/tftp/tftp_xfer.h +++ b/tftp/tftp_xfer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2021, RT-Thread Development Team + * Copyright (c) 2006-2022, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * From 0e58af0b32bfe53f5318f34909f4f2502f28674e Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 11 Jan 2022 18:47:47 -0500 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BD=BF=E7=94=A8rt=5Fxxx=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iperf/iperf.c | 4 ++-- ping/ping.c | 6 +++--- tftp/tftp_server.c | 8 ++++---- tftp/tftp_xfer.c | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/iperf/iperf.c b/iperf/iperf.c index e19c81e..ed5add7 100644 --- a/iperf/iperf.c +++ b/iperf/iperf.c @@ -51,7 +51,7 @@ static void iperf_udp_client(void *thread_param) { return; } - memset(buffer, 0x00, IPERF_BUFSZ); + rt_memset(buffer, 0x00, IPERF_BUFSZ); sock = socket(PF_INET, SOCK_DGRAM, 0); if(sock < 0) { @@ -286,7 +286,7 @@ void iperf_server(void *thread_param) server_addr.sin_family = AF_INET; server_addr.sin_port = htons(param.port); server_addr.sin_addr.s_addr = INADDR_ANY; - memset(&(server_addr.sin_zero), 0x0, sizeof(server_addr.sin_zero)); + rt_memset(&(server_addr.sin_zero), 0x0, sizeof(server_addr.sin_zero)); if (bind(sock, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) == -1) { diff --git a/ping/ping.c b/ping/ping.c index a0f58df..a8b3e3f 100644 --- a/ping/ping.c +++ b/ping/ping.c @@ -161,15 +161,15 @@ rt_err_t ping(char* target_name, rt_uint32_t times, rt_size_t size) size = PING_DATA_SIZE; } - memset(&hint, 0, sizeof(hint)); + rt_memset(&hint, 0, sizeof(hint)); /* convert URL to IP */ if (lwip_getaddrinfo(target_name, NULL, &hint, &res) != 0) { rt_kprintf("ping: unknown host %s\n", target_name); return -RT_ERROR; } - memcpy(&h, &res->ai_addr, sizeof(struct sockaddr_in *)); - memcpy(&ina, &h->sin_addr, sizeof(ina)); + rt_memcpy(&h, &res->ai_addr, sizeof(struct sockaddr_in *)); + rt_memcpy(&ina, &h->sin_addr, sizeof(ina)); lwip_freeaddrinfo(res); if (inet_aton(inet_ntoa(ina), &target_addr) == 0) { diff --git a/tftp/tftp_server.c b/tftp/tftp_server.c index cced845..a38404d 100644 --- a/tftp/tftp_server.c +++ b/tftp/tftp_server.c @@ -114,7 +114,7 @@ static struct tftp_client_xfer *tftp_client_xfer_add(struct tftp_server *server, { if (_private->client_table[i].xfer == NULL) { - memset(&_private->client_table[i], 0, sizeof(struct tftp_client_xfer)); + rt_memset(&_private->client_table[i], 0, sizeof(struct tftp_client_xfer)); _private->client_table[i].xfer = xfer; return &_private->client_table[i]; } @@ -342,7 +342,7 @@ static struct tftp_client_xfer *tftp_server_request_handle(struct tftp_server *s _private = server->_private; /* Receiving client requests */ - memset(packet, 0, sizeof(struct tftp_packet)); + rt_memset(packet, 0, sizeof(struct tftp_packet)); xfer = tftp_recv_request(_private->server_xfer, packet); if (xfer == NULL) { @@ -550,7 +550,7 @@ struct tftp_server *tftp_server_create(const char *root_name, int port) return NULL; } /* init server object */ - memset(server, 0, mem_len); + rt_memset(server, 0, mem_len); server->root_name = strdup(root_name); if (server->root_name == NULL) { @@ -567,7 +567,7 @@ struct tftp_server *tftp_server_create(const char *root_name, int port) free(server); return NULL; } - memset(_private->client_table, 0, mem_len); + rt_memset(_private->client_table, 0, mem_len); _private->table_num = TFTP_SERVER_CONNECT_MAX; return server; } diff --git a/tftp/tftp_xfer.c b/tftp/tftp_xfer.c index 66ca783..88f8fb7 100644 --- a/tftp/tftp_xfer.c +++ b/tftp/tftp_xfer.c @@ -202,7 +202,7 @@ int tftp_send_request(struct tftp_xfer *xfer, uint16_t cmd, const char *remote_f } /* Packing request packet header */ send_packet->cmd = htons(cmd); - size = sprintf(send_packet->info.filename, "%s%c%s%c%s%c%d%c%s%c%d%c", + size = rt_sprintf(send_packet->info.filename, "%s%c%s%c%s%c%d%c%s%c%d%c", remote_file, 0, xfer->mode, 0, "blksize", 0, xfer->blksize, 0,"tsize", 0, 0, 0) + 2; /* send data */ r_size = sendto(xfer->sock, send_packet, size, 0, @@ -233,7 +233,7 @@ struct tftp_xfer *tftp_recv_request(struct tftp_xfer *xfer, struct tftp_packet * /* get packet size */ mem_size = sizeof(struct tftp_packet); - memset(packet, 0, mem_size); + rt_memset(packet, 0, mem_size); /* Receiving raw data */ size = tftp_recv_raw_data(xfer, packet, mem_size); if (size > 0) @@ -248,7 +248,7 @@ struct tftp_xfer *tftp_recv_request(struct tftp_xfer *xfer, struct tftp_packet * if (client_xfer != NULL) { struct tftp_xfer_private *_client_private = client_xfer->_private; - memcpy(&_client_private->sender, &_private->sender, sizeof(struct sockaddr_in)); + rt_memcpy(&_client_private->sender, &_private->sender, sizeof(struct sockaddr_in)); } if (ntohs(packet->cmd) == TFTP_CMD_RRQ) { @@ -343,7 +343,7 @@ struct tftp_xfer *tftp_xfer_create(const char *ip_addr, int port) tftp_printf("can't create tftp transfer!! exit\n"); return NULL; } - memset(xfer, 0, mem_len); + rt_memset(xfer, 0, mem_len); _private = (struct tftp_xfer_private *)&xfer[1]; /* create socket */