From 74488ba47f203ada63c34808ff761d907f16cd68 Mon Sep 17 00:00:00 2001 From: wangyu- Date: Mon, 4 Jun 2018 03:56:44 -0500 Subject: [PATCH] fix warnings --- common.cpp | 5 ++++- makefile | 4 ++-- my_ev.cpp | 10 ++++++++++ my_ev.h | 3 +-- my_ev_common.h | 11 ----------- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/common.cpp b/common.cpp index 72373a8..a5709c7 100644 --- a/common.cpp +++ b/common.cpp @@ -82,7 +82,10 @@ void get_fake_random_chars(char * s,int len) while(left>=(int)sizeof(u64_t)) { - *((u64_t*)p)=my_random.gen64(); //no endianess problem here , but may break strict-alias? + //*((u64_t*)p)=my_random.gen64(); //this may break strict-alias , also p may not point to a multiple of sizeof(u64_t) + + u64_t tmp=my_random.gen64(); + memcpy(p,&tmp,sizeof(u64_t)); // so,use memcpy instead. p+=sizeof(u64_t); left-=sizeof(u64_t); diff --git a/makefile b/makefile index 5b2674e..b1522be 100755 --- a/makefile +++ b/makefile @@ -6,9 +6,9 @@ cc_mips24kc_le=/toolchains/lede-sdk-17.01.2-ramips-mt7621_gcc-5.4.0_musl-1.1.16. #cc_arm= /toolchains/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabi/bin/arm-linux-gnueabi-g++ -march=armv6 -marm cc_arm= /toolchains/arm-2014.05/bin/arm-none-linux-gnueabi-g++ #cc_bcm2708=/home/wangyu/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ -FLAGS= -std=c++11 -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers -Wno-strict-aliasing -Wno-comment +FLAGS= -std=c++11 -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers -SOURCES=main.cpp log.cpp common.cpp lib/fec.c lib/rs.c packet.cpp delay_manager.cpp fd_manager.cpp connection.cpp fec_manager.cpp misc.cpp tunnel_client.cpp tunnel_server.cpp my_ev.cpp -Ilibev +SOURCES=main.cpp log.cpp common.cpp lib/fec.c lib/rs.c packet.cpp delay_manager.cpp fd_manager.cpp connection.cpp fec_manager.cpp misc.cpp tunnel_client.cpp tunnel_server.cpp my_ev.cpp -isystem libev NAME=speederv2 TARGETS=amd64 arm mips24kc_be x86 mips24kc_le diff --git a/my_ev.cpp b/my_ev.cpp index 832c1d9..5880a4c 100644 --- a/my_ev.cpp +++ b/my_ev.cpp @@ -1,5 +1,15 @@ #pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wextra" +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wcomment" +#pragma GCC diagnostic ignored "-Wparentheses" +#pragma GCC diagnostic ignored "-Wstrict-aliasing" +#pragma GCC diagnostic ignored "-Wunused-value" + +#pragma GCC diagnostic ignored "-Wall" +#pragma GCC diagnostic ignored "-W" + #include "my_ev_common.h" #include "ev.c" diff --git a/my_ev.h b/my_ev.h index f3630ee..c0c0e24 100644 --- a/my_ev.h +++ b/my_ev.h @@ -1,6 +1,5 @@ -#pragma GCC diagnostic push +#pragma once #include "my_ev_common.h" #include "ev.h" -#pragma GCC diagnostic pop diff --git a/my_ev_common.h b/my_ev_common.h index 9c10e29..0755f45 100644 --- a/my_ev_common.h +++ b/my_ev_common.h @@ -1,15 +1,4 @@ -#pragma GCC diagnostic ignored "-Wextra" -#pragma GCC diagnostic ignored "-Wsign-compare" -#pragma GCC diagnostic ignored "-Wcomment" -#pragma GCC diagnostic ignored "-Wparentheses" -#pragma GCC diagnostic ignored "-Wstrict-aliasing" -#pragma GCC diagnostic ignored "-Wunused-value" - -#pragma GCC diagnostic ignored "-Wall" -#pragma GCC diagnostic ignored "-W" - - #define EV_STANDALONE 1 #define EV_COMMON void *data; unsigned long long u64; #define EV_COMPAT3 0