浏览代码

lint: fix lint warnings

Nick Peng 3 月之前
父节点
当前提交
4f768845bc

+ 1 - 1
src/dns_client/client_mdns.c

@@ -33,7 +33,7 @@
 
 int _dns_client_create_socket_udp_mdns(struct dns_server_info *server_info)
 {
-	int fd = 0;
+	int fd = -1;
 	struct epoll_event event;
 	const int on = 1;
 	const int val = 1;

+ 1 - 1
src/dns_client/client_quic.c

@@ -203,7 +203,7 @@ errout:
 int _dns_client_create_socket_quic(struct dns_server_info *server_info, const char *hostname, const char *alpn)
 {
 #if defined(OSSL_QUIC1_VERSION) && !defined (OPENSSL_NO_QUIC)
-	int fd = 0;
+	int fd = -1;
 	unsigned char alpn_data[DNS_MAX_ALPN_LEN];
 	int32_t alpn_len = 0;
 	struct epoll_event event;

+ 4 - 1
src/dns_client/client_socket.c

@@ -139,6 +139,10 @@ void _dns_client_close_socket_ext(struct dns_server_info *server_info, int no_de
 	} else if (server_info->fd > 0) {
 		close(server_info->fd);
 	}
+
+	if (server_info->fd > 0) {
+		tlog(TLOG_DEBUG, "server %s:%d closed.", server_info->ip, server_info->port);
+	}
 	
 	server_info->fd = -1;
 	/* update send recv time */
@@ -146,7 +150,6 @@ void _dns_client_close_socket_ext(struct dns_server_info *server_info, int no_de
 	time(&server_info->last_recv);
 
 	pthread_mutex_unlock(&server_info->lock);
-	tlog(TLOG_DEBUG, "server %s:%d closed.", server_info->ip, server_info->port);
 }
 
 void _dns_client_close_socket(struct dns_server_info *server_info)

+ 1 - 1
src/dns_client/client_tcp.c

@@ -35,7 +35,7 @@
 
 int _dns_client_create_socket_tcp(struct dns_server_info *server_info)
 {
-	int fd = 0;
+	int fd = -1;
 	struct epoll_event event;
 	int yes = 1;
 	const int priority = SOCKET_PRIORITY;

+ 1 - 1
src/dns_client/client_tls.c

@@ -350,7 +350,7 @@ errout:
 
 int _dns_client_create_socket_tls(struct dns_server_info *server_info, const char *hostname, const char *alpn)
 {
-	int fd = 0;
+	int fd = -1;
 	struct epoll_event event;
 	SSL *ssl = NULL;
 	struct proxy_conn *proxy = NULL;

+ 1 - 1
src/dns_client/client_udp.c

@@ -104,7 +104,7 @@ errout:
 
 int _dns_client_create_socket_udp(struct dns_server_info *server_info)
 {
-	int fd = 0;
+	int fd = -1;
 	struct epoll_event event;
 	const int on = 1;
 	const int val = 255;

+ 1 - 1
src/dns_client/server_info.c

@@ -405,7 +405,7 @@ int _dns_client_server_add(const char *server_ip, const char *server_host, int p
 	server_info->ai_family = gai->ai_family;
 	server_info->ai_addrlen = gai->ai_addrlen;
 	server_info->type = server_type;
-	server_info->fd = 0;
+	server_info->fd = -1;
 	server_info->status = DNS_SERVER_STATUS_INIT;
 	server_info->ttl = ttl;
 	server_info->ttl_range = 0;

+ 1 - 1
src/dns_server/local_addr.c

@@ -184,7 +184,7 @@ int _dns_server_local_addr_cache_destroy(void)
 
 int _dns_server_local_addr_cache_init(void)
 {
-	int fd = 0;
+	int fd = -1;
 	struct sockaddr_nl sa;
 
 	server.local_addr_cache.fd_netlink = -1;

+ 1 - 1
src/fast_ping/ping_icmp.c

@@ -201,7 +201,7 @@ errout:
 
 static int _fast_ping_create_icmp(FAST_PING_TYPE type)
 {
-	int fd = 0;
+	int fd = -1;
 	int *set_fd = NULL;
 
 	pthread_mutex_lock(&ping.lock);

+ 2 - 2
src/fast_ping/ping_udp.c

@@ -35,7 +35,7 @@ int _fast_ping_sendping_udp(struct ping_host_struct *ping_host)
 	struct ping_dns_head dns_head;
 	int len = 0;
 	int flag = 0;
-	int fd = 0;
+	int fd = -1;
 
 	flag |= (0 << 15) & 0x8000;
 	flag |= (2 << 11) & 0x7800;
@@ -140,7 +140,7 @@ errout:
 
 static int _fast_ping_create_udp(FAST_PING_TYPE type)
 {
-	int fd = 0;
+	int fd = -1;
 	int *set_fd = NULL;
 
 	pthread_mutex_lock(&ping.lock);

+ 1 - 1
src/lib/nftset.c

@@ -178,7 +178,7 @@ static int _nftset_socket_init(void)
 	struct sockaddr_nl addr = {0};
 	addr.nl_family = AF_NETLINK;
 	addr.nl_pid = 0;
-	int fd = 0;
+	int fd = -1;
 
 	if (nftset_fd > 0) {
 		return 0;

+ 1 - 1
src/utils/dns_debug.c

@@ -141,7 +141,7 @@ struct _dns_read_packet_info {
 static struct _dns_read_packet_info *_dns_read_packet_file(const char *packet_file)
 {
 	struct _dns_read_packet_info *info = NULL;
-	int fd = 0;
+	int fd = -1;
 	int len = 0;
 	int message_len = 0;
 	uint8_t *ptr = NULL;

+ 1 - 1
src/utils/nftset.c

@@ -179,7 +179,7 @@ static int _nftset_socket_init(void)
 	struct sockaddr_nl addr = {0};
 	addr.nl_family = AF_NETLINK;
 	addr.nl_pid = 0;
-	int fd = 0;
+	int fd = -1;
 
 	if (nftset_fd > 0) {
 		return 0;