diff options
author | RALOVICH, Kristof <tade60@freemail.hu> | 2013-10-11 23:43:44 +0200 |
---|---|---|
committer | RALOVICH, Kristof <tade60@freemail.hu> | 2013-10-11 23:43:44 +0200 |
commit | 55ab727057ba65b8272dc3ca60f96ff68d0da62b (patch) | |
tree | d6f645d27e611c05d7b1eb96039b78328f16fcd3 | |
parent | e305f0b6f5c61df356c77c984b1ad0b0233d8255 (diff) |
gant: fix a bunch of build warnings
antpm/src/gant/antlib.cpp:233:24: error: assigning to 'unsigned char *' from incompatible type 'void *'
burstbuf[chan] = malloc(BSIZE);
^ ~~~~~~~~~~~~~
antpm/src/gant/antlib.cpp:247:25: error: assigning to 'unsigned char *' from incompatible type 'void *'
burstbuf[chan] = malloc(BSIZE);
^ ~~~~~~~~~~~~~
antpm/src/gant/antlib.cpp:256:25: error: assigning to 'unsigned char *' from incompatible type 'void *'
burstbuf[chan] = realloc(burstbuf[chan], bused[chan]+BSIZE);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
antpm/src/gant/antlib.c: In function ‘commfn’:
antpm/src/gant/antlib.c:366:20: warning: unused parameter ‘arg’ [-Wunused-parameter]
antpm/src/gant/antlib.c: In function ‘ANT_Initf’:
antpm/src/gant/antlib.c:406:33: warning: unused parameter ‘baud’ [-Wunused-parameter]
antpm/src/gant/antlib.c: In function ‘ANT_Init’:
antpm/src/gant/antlib.c:435:30: warning: unused parameter ‘baud’ [-Wunused-parameter]
antpm/src/gant/antlib.c: In function ‘ANT_AssignChannelEventFunction’:
antpm/src/gant/antlib.c:618:38: warning: unused parameter ‘chan’ [-Wunused-parameter]
antpm/src/gant/gant.c: In function ‘chevent’:
antpm/src/gant/gant.c:821:9: warning: variable ‘newdata’ set but not used [-Wunused-but-set-variable]
antpm/src/gant/antlib.c: In function ‘ANT_AssignChannelEventFunction’:
antpm/src/gant/antlib.c:619:38: warning: unused parameter ‘chan’ [-Wunused-parameter]
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/gant/antlib.c | 18 | ||||
-rw-r--r-- | src/gant/antlib.h | 4 | ||||
-rw-r--r-- | src/gant/gant.c | 12 |
4 files changed, 19 insertions, 16 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 08449a7..348eeda 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,6 +33,7 @@ ENDIF() IF(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -fms-extensions -std=c++0x -Wall")
set(CMAKE_CXX_FLAGS_DEBUG "-g3 -ggdb3")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wextra -Wall")
set(CMAKE_C_FLAGS_DEBUG "-g3 -ggdb3")
IF(USE_COVERAGE)
diff --git a/src/gant/antlib.c b/src/gant/antlib.c index de20f66..c0a04f1 100644 --- a/src/gant/antlib.c +++ b/src/gant/antlib.c @@ -18,7 +18,7 @@ //#include "antmessage.h" //#include "anttypes.h" -#define S(e) if (-1 == (e)) {perror(#e);exit(1);} else +#define S(e) do { if (-1 == (e)) {perror(#e); return 0;} } while(0) #define MAXMSG 30 // SYNC,LEN,MSG,data[9+],CHKSUM #define MAXCHAN 32 @@ -230,7 +230,7 @@ void get_data(int fd) if (seq != 0) fprintf(stderr, "out of sequence ch# %d %d\n", chan, seq); else { - burstbuf[chan] = malloc(BSIZE); + burstbuf[chan] = (unsigned char*)malloc(BSIZE); bzero(burstbuf[chan], BSIZE); memcpy(burstbuf[chan], buf+i+4, 8); bused[chan] = 8; @@ -244,7 +244,7 @@ void get_data(int fd) free(burstbuf[chan]); burstbuf[chan] = 0; if (seq == 0) { - burstbuf[chan] = malloc(BSIZE); + burstbuf[chan] = (unsigned char*)malloc(BSIZE); bzero(burstbuf[chan], BSIZE); memcpy(burstbuf[chan], buf+i+4, 8); bused[chan] = 8; @@ -253,7 +253,7 @@ void get_data(int fd) } } else { if ((bused[chan] % BSIZE) == 0) { - burstbuf[chan] = realloc(burstbuf[chan], bused[chan]+BSIZE); + burstbuf[chan] = (unsigned char*)realloc(burstbuf[chan], bused[chan]+BSIZE); bzero(burstbuf[chan]+bused[chan], BSIZE); } memcpy(burstbuf[chan]+bused[chan], buf+i+4, 8); @@ -368,6 +368,7 @@ void *commfn(void* arg) fd_set readfds, writefds, exceptfds; int ready; struct timeval to; + (void)arg; for(;;) { FD_ZERO(&readfds); @@ -403,7 +404,7 @@ ANT_OpenRxScanMode(uchar chan) } uchar -ANT_Initf(char *devname, ushort baud) +ANT_Initf(char *devname) { struct termios tp; @@ -427,17 +428,17 @@ ANT_Initf(char *devname, ushort baud) tp.c_cc[VTIME] = 0; S(tcsetattr(fd, TCSANOW, &tp)); - if (pthread_create(&commthread, 0, commfn, 0)); + S(pthread_create(&commthread, 0, commfn, 0)); return 1; } uchar -ANT_Init(uchar devno, ushort baud) +ANT_Init(uchar devno) { char dev[40]; sprintf(dev, "/dev/ttyUSB%d", devno); - return ANT_Initf(dev, devno); + return ANT_Initf(dev); } uchar @@ -617,6 +618,7 @@ ANT_AssignResponseFunction(RESPONSE_FUNC rf, uchar* rbuf) void ANT_AssignChannelEventFunction(uchar chan, CHANNEL_EVENT_FUNC rf, uchar* rbuf) { + (void)chan; cfn = rf; cbufp = rbuf; } diff --git a/src/gant/antlib.h b/src/gant/antlib.h index a8c95d3..fe22e59 100644 --- a/src/gant/antlib.h +++ b/src/gant/antlib.h @@ -5,8 +5,8 @@ uchar ANT_ResetSystem(void); uchar ANT_Cmd55(uchar chan); uchar ANT_OpenRxScanMode(uchar chan); -uchar ANT_Initf(char *devname, ushort baud); -uchar ANT_Init(uchar devno, ushort baud); +uchar ANT_Initf(char *devname); +uchar ANT_Init(uchar devno); uchar ANT_RequestMessage(uchar chan, uchar mesg); uchar ANT_SetNetworkKeya(uchar net, uchar *key); uchar ANT_SetNetworkKey(uchar net, uchar *key); diff --git a/src/gant/gant.c b/src/gant/gant.c index 88b83dd..4e5afb3 100644 --- a/src/gant/gant.c +++ b/src/gant/gant.c @@ -818,7 +818,7 @@ uchar chevent(uchar chan, uchar event) { uchar status; uchar phase; - uint newdata; + /*uint newdata;*/ struct ack_msg ack; struct auth_msg auth; struct pair_msg pair; @@ -830,7 +830,7 @@ uchar chevent(uchar chan, uchar event) if (event == EVENT_RX_BROADCAST) { status = cbuf[1] & 0xd7; - newdata = cbuf[1] & 0x20; + /*newdata = cbuf[1] & 0x20;*/ phase = cbuf[2]; } cid = cbuf[4] + cbuf[5] * 256 + cbuf[6] * 256 * 256 + cbuf[7] * 256 * 256 * 256; @@ -894,7 +894,7 @@ uchar chevent(uchar chan, uchar event) ack.c1 = 0x00; ack.c2 = 0x00; ack.id = 0; - ANT_SendAcknowledgedData(chan, (void *)&ack); // tell garmin we're finished + ANT_SendAcknowledgedData(chan, (uchar *)&ack); // tell garmin we're finished sleep(1); exit(1); } @@ -1318,7 +1318,7 @@ int main(int ac, char *av[]) int waveform = 0x0053; // aids search somehow int c; extern char *optarg; - extern int optind, opterr, optopt; + extern int optind; // default auth file // if (getenv("HOME")) @@ -1379,9 +1379,9 @@ int main(int ac, char *av[]) if ((!passive && !authfile) || ac) usage(); - if (!ANT_Init(devnum, 0)) // should be 115200 but doesn't fit into a short + if (!ANT_Init(devnum)) // should be 115200 but doesn't fit into a short { - ERROR_OUT("Open dev %d failed", devnum); + ERROR_OUT("Open /dev/ttyUSB%d failed", devnum); exit(1); } ANT_ResetSystem(); |