From 0efcacfdf4f8182629688ce7dd9a9f22dd4c5dbd Mon Sep 17 00:00:00 2001 From: wangyu Date: Sat, 29 Jul 2017 20:58:38 +0800 Subject: [PATCH] fixed warnings --- common.cpp | 2 +- common.h | 22 +++++++++++----------- encrypt.cpp | 2 +- main.cpp | 25 +++++++++++++++---------- makefile | 2 +- network.cpp | 14 +++++++------- 6 files changed, 36 insertions(+), 31 deletions(-) diff --git a/common.cpp b/common.cpp index d7607d5..f0d8181 100644 --- a/common.cpp +++ b/common.cpp @@ -189,7 +189,7 @@ int numbers_to_char(id_t id1,id_t id2,id_t id3,char * &data,int &len) int char_to_numbers(const char * data,int len,id_t &id1,id_t &id2,id_t &id3) { - if(len mp; - int ready_num; + uint32_t ready_num; unordered_map udp_fd_mp; //a bit dirty to used pointer,but can void unordered_map search unordered_map timer_fd_mp;//we can use pointer here since unordered_map.rehash() uses shallow copy @@ -1285,7 +1285,7 @@ int client_on_raw_recv(conn_info_t &conn_info) conn_info.last_hb_recv_time=current_time_rough; return 0; } - else if(data_len>=sizeof(uint32_t)+1&&data[0]=='d') + else if(data_len>= int( sizeof(uint32_t)+1 )&&data[0]=='d') { mylog(log_trace,"received a data from fake tcp,len:%d\n",data_len); @@ -1351,7 +1351,7 @@ int server_on_raw_ready(conn_info_t &conn_info) mylog(log_debug, "received hb <%x,%x>\n", conn_info.oppsite_id, tmp); conn_info.last_hb_recv_time = current_time_rough; return 0; - } else if (data[0] == 'd' && data_len >= sizeof(uint32_t) + 1) { + } else if (data[0] == 'd' && data_len >=int( sizeof(uint32_t) + 1)) { uint32_t tmp_conv_id = ntohl(*((uint32_t *) &data[1])); conn_info.last_hb_recv_time = current_time_rough; @@ -2109,21 +2109,21 @@ int client_event_loop() } int n; for (n = 0; n < nfds; ++n) { - if (events[n].data.u64 == raw_recv_fd) + if (events[n].data.u64 == (uint64_t)raw_recv_fd) { iphdr *iph;tcphdr *tcph; client_on_raw_recv(conn_info); } - if(events[n].data.u64 ==timer_fd) + if(events[n].data.u64 ==(uint64_t)timer_fd) { uint64_t value; read(timer_fd, &value, 8); keep_connection_client(conn_info); } - if (events[n].data.u64 == udp_fd) + if (events[n].data.u64 == (uint64_t)udp_fd) { - socklen_t recv_len; + int recv_len; struct sockaddr_in udp_new_addr_in; if ((recv_len = recvfrom(udp_fd, buf, buf_len, 0, (struct sockaddr *) &udp_new_addr_in, &slen)) == -1) { @@ -2265,7 +2265,7 @@ int server_event_loop() for (n = 0; n < nfds; ++n) { //printf("%d %d %d %d\n",timer_fd,raw_recv_fd,raw_send_fd,n); - if ((events[n].data.u64 ) == timer_fd) + if ((events[n].data.u64 ) == (uint64_t)timer_fd) { uint64_t dummy; read(timer_fd, &dummy, 8); @@ -2293,7 +2293,7 @@ int server_event_loop() //conn_info_t &conn_info=conn_manager.find(ip,port); keep_connection_server_multi(*p_conn_info); } - else if (events[n].data.u64 == raw_recv_fd) + else if (events[n].data.u64 == (uint64_t)raw_recv_fd) { iphdr *iph;tcphdr *tcph; server_on_raw_recv_multi(); @@ -2707,6 +2707,11 @@ void iptables_warn() } int main(int argc, char *argv[]) { + + uint32_t b=0xffff; + int32_t a=b; + printf("<%d>",a); + dup2(1, 2);//redirect stderr to stdout signal(SIGINT, INThandler); process_arg(argc,argv); diff --git a/makefile b/makefile index f95677b..1e2b4c3 100755 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ ccmips=mips-openwrt-linux-g++ -FLAGS=-Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-sign-compare +FLAGS=-Wall -Wextra -Wno-unused-variable -Wno-unused-parameter all: sudo killall udp2raw||true sleep 0.2 diff --git a/network.cpp b/network.cpp index a775b96..f0ff3c1 100644 --- a/network.cpp +++ b/network.cpp @@ -285,7 +285,7 @@ int peek_raw(uint32_t &ip,uint16_t &port) int recv_len = recvfrom(raw_recv_fd, peek_raw_buf,buf_len, MSG_PEEK ,&saddr , &saddr_size);//change buf_len to something smaller,we only need header here iphdr * iph = (struct iphdr *) (ip_begin); //mylog(log_info,"recv_len %d\n",recv_len); - if(recv_lenprotocol!=IPPROTO_TCP) return -1; struct tcphdr *tcph=(tcphdr *)payload; - if(recv_lensource); break; @@ -309,7 +309,7 @@ int peek_raw(uint32_t &ip,uint16_t &port) { if(iph->protocol!=IPPROTO_UDP) return -1; struct udphdr *udph=(udphdr *)payload; - if(recv_lensource); break; @@ -318,7 +318,7 @@ int peek_raw(uint32_t &ip,uint16_t &port) { if(iph->protocol!=IPPROTO_ICMP) return -1; struct icmphdr *icmph=(icmphdr *)payload; - if(recv_lenid); break; @@ -347,7 +347,7 @@ int recv_raw_ip(raw_info_t &raw_info,char * &payload,int &payloadlen) mylog(log_trace,"recv_len %d\n",recv_len); return -1; } - if(recv_lentot_len); - if(recv_len-link_level_header_len