Fixed clang warnings + debug build

This commit is contained in:
frekky 2015-11-21 19:27:28 +08:00
parent e3531378b5
commit 68a53c4565
5 changed files with 24 additions and 20 deletions

View File

@ -1,5 +1,5 @@
COMMONOBJS = tun.o dns.o read.o encoding.o login.o base32.o base64.o base64u.o base128.o md5.o window.o common.o COMMONOBJS = tun.o dns.o read.o encoding.o login.o base32.o base64.o base64u.o base128.o md5.o window.o common.o util.o
CLIENTOBJS = iodine.o client.o util.o CLIENTOBJS = iodine.o client.o
CLIENT = ../bin/iodine CLIENT = ../bin/iodine
SERVEROBJS = iodined.o user.o fw_query.o server.o SERVEROBJS = iodined.o user.o fw_query.o server.o
SERVER = ../bin/iodined SERVER = ../bin/iodined
@ -13,7 +13,7 @@ LDFLAGS += -lz `sh osflags $(TARGETOS) link` $(LIBPATH)
CFLAGS += -std=c99 -c -Wall -D$(OS) -pedantic `sh osflags $(TARGETOS) cflags` -DGITREVISION=\"$(HEAD_COMMIT)\" CFLAGS += -std=c99 -c -Wall -D$(OS) -pedantic `sh osflags $(TARGETOS) cflags` -DGITREVISION=\"$(HEAD_COMMIT)\"
CFLAGS_RELEASE = -O3 -fno-strict-aliasing CFLAGS_RELEASE = -O3 -fno-strict-aliasing
CFLAGS_DEBUG = -g -Og -DDEBUG_BUILD CFLAGS_DEBUG = -g -O0 -DDEBUG_BUILD
all: CFLAGS += $(CFLAGS_RELEASE) all: CFLAGS += $(CFLAGS_RELEASE)
all: executables all: executables

View File

@ -571,7 +571,7 @@ send_query(int fd, uint8_t *hostname)
and if user hasn't specified server timeout/window timeout etc. */ and if user hasn't specified server timeout/window timeout etc. */
num_sent++; num_sent++;
if (send_query_sendcnt >= 0 && send_query_sendcnt < 100 && if (send_query_sendcnt > 0 && send_query_sendcnt < 100 &&
lazymode && connected && autodetect_server_timeout) { lazymode && connected && autodetect_server_timeout) {
send_query_sendcnt++; send_query_sendcnt++;

View File

@ -87,7 +87,7 @@ extern const unsigned char raw_header[RAW_HDR_LEN];
#define TIMEPRINT(...) \ #define TIMEPRINT(...) \
struct timeval currenttime;\ struct timeval currenttime;\
gettimeofday(&currenttime, NULL);\ gettimeofday(&currenttime, NULL);\
fprintf(stderr, "%03ld.%03ld ", currenttime.tv_sec, currenttime.tv_usec / 1000);\ fprintf(stderr, "%03ld.%03ld ", (long) currenttime.tv_sec, (long) currenttime.tv_usec / 1000);\
fprintf(stderr, __VA_ARGS__); fprintf(stderr, __VA_ARGS__);
#define DEBUG(level, ...) \ #define DEBUG(level, ...) \

View File

@ -18,6 +18,23 @@
#include <stdio.h> #include <stdio.h>
#include "common.h" #include "common.h"
time_t
timeval_to_ms(struct timeval *tv)
{
time_t ms = tv->tv_sec * 1000;
ms += (tv->tv_usec + 500) / 1000;
return ms;
}
struct timeval
ms_to_timeval(time_t ms)
{
struct timeval tv;
tv.tv_sec = ms / 1000;
tv.tv_usec = (ms - tv.tv_sec * 1000) * 1000;
return tv;
}
char * char *
get_resolvconf_addr() get_resolvconf_addr()
{ {

View File

@ -24,21 +24,8 @@
char *get_resolvconf_addr(); char *get_resolvconf_addr();
void socket_setrtable(int fd, int rtable); void socket_setrtable(int fd, int rtable);
inline time_t time_t timeval_to_ms(struct timeval *tv);
timeval_to_ms(struct timeval *tv)
{
time_t ms = tv->tv_sec * 1000;
ms += (tv->tv_usec + 500) / 1000;
return ms;
}
inline struct timeval struct timeval ms_to_timeval(time_t ms);
ms_to_timeval(time_t ms)
{
struct timeval tv;
tv.tv_sec = ms / 1000;
tv.tv_usec = (ms - tv.tv_sec * 1000) * 1000;
return tv;
}
#endif #endif