Fix lint issue

This commit is contained in:
Nick Peng
2019-08-09 22:32:17 +08:00
parent 5082f1ae55
commit 273c2d5100
8 changed files with 32 additions and 48 deletions

View File

@@ -242,7 +242,7 @@ struct dns_query_struct {
static struct dns_client client;
static atomic_t dns_client_sid = ATOMIC_INIT(0);
static LIST_HEAD(pending_servers);
pthread_mutex_t pending_server_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t pending_server_mutex = PTHREAD_MUTEX_INITIALIZER;
static int dns_client_has_bootstrap_dns = 0;
/* get addr info */
@@ -452,7 +452,7 @@ errout:
}
/* add server to group */
int _dns_client_add_to_group_pending(char *group_name, char *server_ip, int port, dns_server_type_t server_type, int ispending)
static int _dns_client_add_to_group_pending(char *group_name, char *server_ip, int port, dns_server_type_t server_type, int ispending)
{
struct dns_server_info *server_info = NULL;

View File

@@ -2032,7 +2032,6 @@ static int _dns_server_recv(struct dns_server_conn_head *conn, unsigned char *in
int qclass;
int qtype = DNS_T_ALL;
_dns_server_conn_get(conn);
/* decode packet */
tlog(TLOG_DEBUG, "recv query packet from %s, len = %d", gethost_by_addr(name, sizeof(name), (struct sockaddr *)from), inpacket_len);
decode_len = dns_decode(packet, DNS_PACKSIZE, inpacket, inpacket_len);
@@ -2083,7 +2082,6 @@ static int _dns_server_recv(struct dns_server_conn_head *conn, unsigned char *in
goto errout;
}
_dns_server_conn_release(conn);
return ret;
errout:
if (request) {
@@ -2091,7 +2089,6 @@ errout:
_dns_server_delete_request(request);
}
_dns_server_conn_release(conn);
return ret;
}
@@ -2441,23 +2438,28 @@ static int _dns_server_process_tcp(struct dns_server_conn_tcp_client *dnsserver,
static int _dns_server_process(struct dns_server_conn_head *conn, struct epoll_event *event, unsigned long now)
{
int ret;
_dns_server_client_touch(conn);
_dns_server_conn_get(conn);
if (conn->type == DNS_CONN_TYPE_UDP_SERVER) {
struct dns_server_conn_udp *udpconn = (struct dns_server_conn_udp *)conn;
return _dns_server_process_udp(udpconn, event, now);
ret = _dns_server_process_udp(udpconn, event, now);
} else if (conn->type == DNS_CONN_TYPE_TCP_SERVER) {
struct dns_server_conn_tcp_server *tcpserver = (struct dns_server_conn_tcp_server *)conn;
return _dns_server_tcp_accept(tcpserver, event, now);
ret = _dns_server_tcp_accept(tcpserver, event, now);
} else if (conn->type == DNS_CONN_TYPE_TCP_CLIENT) {
struct dns_server_conn_tcp_client *tcpclient = (struct dns_server_conn_tcp_client *)conn;
return _dns_server_process_tcp(tcpclient, event, now);
ret = _dns_server_process_tcp(tcpclient, event, now);
} else if (conn->type == DNS_CONN_TYPE_TLS_SERVER) {
tlog(TLOG_ERROR, "unsupport dns server type %d", conn->type);
return -1;
ret = -1;
} else {
tlog(TLOG_ERROR, "unsupport dns server type %d", conn->type);
return -1;
ret = -1;
}
_dns_server_conn_release(conn);
return ret;
}
static void _dns_server_second_ping_check(struct dns_request *request)

View File

@@ -984,14 +984,10 @@ static int _fast_ping_get_addr_by_type(PING_TYPE type, const char *ip_str, int p
return _fast_ping_get_addr_by_dns(ip_str, port, out_gai, out_ping_type);
break;
default:
goto errout;
break;
}
return -1;
errout:
return -1;
}
struct ping_host_struct *fast_ping_start(PING_TYPE type, const char *host, int count, int interval, int timeout, fast_ping_result ping_callback, void *userptr)
@@ -1055,7 +1051,6 @@ struct ping_host_struct *fast_ping_start(PING_TYPE type, const char *host, int c
hash_add(ping.addrmap, &ping_host->addr_node, addrkey);
pthread_mutex_unlock(&ping.map_lock);
_fast_ping_host_get(ping_host);
_fast_ping_host_get(ping_host);
if (_fast_ping_sendping(ping_host) != 0) {
goto errout_remove;
@@ -1063,8 +1058,10 @@ struct ping_host_struct *fast_ping_start(PING_TYPE type, const char *host, int c
ping_host->run = 1;
freeaddrinfo(gai);
_fast_ping_host_put(ping_host);
return ping_host;
errout_remove:
fast_ping_stop(ping_host);
ping_host = NULL;
errout:
if (gai) {
freeaddrinfo(gai);
@@ -1074,10 +1071,6 @@ errout:
free(ping_host);
}
return NULL;
errout_remove:
fast_ping_stop(ping_host);
_fast_ping_host_put(ping_host);
return NULL;
}
@@ -1270,8 +1263,8 @@ static int _fast_ping_process_icmp(struct ping_host_struct *ping_host, struct ti
}
if (recv_ping_host->seq != seq) {
_fast_ping_host_put(recv_ping_host);
tlog(TLOG_ERROR, "seq num mismatch, expect %u, real %u", recv_ping_host->seq, seq);
_fast_ping_host_put(recv_ping_host);
return -1;
}
@@ -1640,7 +1633,7 @@ errout:
return -1;
}
void _fast_ping_close_fds(void)
static void _fast_ping_close_fds(void)
{
if (ping.fd_icmp > 0) {
close(ping.fd_icmp);

View File

@@ -20,4 +20,4 @@ static inline char *safe_strncpy(char *dest, const char *src, size_t n)
return ret;
}
#endif
#endif

View File

@@ -52,23 +52,28 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
static art_node* alloc_node(uint8_t type) {
art_node* n;
switch (type) {
void *mem = NULL;
switch (type) {
case NODE4:
n = (art_node*)calloc(1, sizeof(art_node4));
mem = (art_node*)calloc(1, sizeof(art_node4));
break;
case NODE16:
n = (art_node*)calloc(1, sizeof(art_node16));
mem = (art_node*)calloc(1, sizeof(art_node16));
break;
case NODE48:
n = (art_node*)calloc(1, sizeof(art_node48));
mem = (art_node*)calloc(1, sizeof(art_node48));
break;
case NODE256:
n = (art_node*)calloc(1, sizeof(art_node256));
mem = (art_node*)calloc(1, sizeof(art_node256));
break;
default:
abort();
}
n->type = type;
if (mem == NULL) {
abort();
}
n = mem;
n->type = type;
return n;
}

View File

@@ -167,7 +167,6 @@ int conf_parse_args(char *key, char *value, int *argc, char **argv)
argv[count] = start;
*ptr = '\0';
ptr++;
start = ptr;
count++;
sep_flag = ' ';
start = NULL;

View File

@@ -71,7 +71,7 @@ format: Log formats
#ifndef BASE_FILE_NAME
#define BASE_FILE_NAME __FILE__
#endif
#define tlog(level, format, ...) tlog_ext(level, BASE_FILE_NAME, __LINE__, __func__, 0, format, ##__VA_ARGS__)
#define tlog(level, format, ...) tlog_ext(level, BASE_FILE_NAME, __LINE__, __func__, NULL, format, ##__VA_ARGS__)
extern int tlog_ext(tlog_level level, const char *file, int line, const char *func, void *userptr, const char *format, ...)
__attribute__((format(printf, 6, 7))) __attribute__((nonnull (6)));

View File

@@ -506,7 +506,7 @@ static int _ipset_operate(const char *ipsetname, const unsigned char addr[], int
nested[0]->len = (void *)buffer + NETLINK_ALIGN(netlink_head->nlmsg_len) - (void *)nested[0];
for (;;) {
rc = sendto(ipset_fd, buffer, netlink_head->nlmsg_len, 0, (struct sockaddr *)&snl, sizeof(snl));
rc = sendto(ipset_fd, buffer, netlink_head->nlmsg_len, 0, (const struct sockaddr *)&snl, sizeof(snl));
if (rc >= 0) {
break;
}
@@ -680,25 +680,10 @@ void SSL_CRYPTO_thread_cleanup(void)
#ifndef MIN
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
#endif
typedef struct Protocol {
const char *const name;
const uint16_t default_port;
int (*const parse_packet)(const char*, size_t, char *, const char **);
const char *const abort_message;
const size_t abort_message_len;
} protocol_t;
static int parse_extensions(const char *, size_t, char *, const char **);
static int parse_server_name_extension(const char *, size_t, char *, const char **);
const struct Protocol *const tls_protocol;
static const protocol_t tls_protocol_st = {
.default_port = 443,
.parse_packet = &parse_tls_header,
};
const protocol_t *const tls_protocol = &tls_protocol_st;
/* Parse a TLS packet for the Server Name Indication extension in the client
* hello handshake, returning the first servername found (pointer to static
* array)
@@ -884,4 +869,4 @@ void get_compiled_time(struct tm *tm)
tm->tm_hour = hour;
tm->tm_min = min;
tm->tm_sec = sec;
}
}