diff options
| author | Tero Kontkanen <tero.kontkanen@granitedevices.fi> | 2017-05-30 15:22:44 +0300 |
|---|---|---|
| committer | Tero Kontkanen <tero.kontkanen@granitedevices.fi> | 2017-05-30 15:22:44 +0300 |
| commit | 7765b619bb3406cc8960f66d5f86fb23e1df87d0 (patch) | |
| tree | 6ce5cf04f743106f949d1401b3772bb9e6385666 | |
| parent | a60052b1d6a620e64d300f07e9edd26a963cd889 (diff) | |
| download | SimpleMotionV2-7765b619bb3406cc8960f66d5f86fb23e1df87d0.tar.gz SimpleMotionV2-7765b619bb3406cc8960f66d5f86fb23e1df87d0.zip | |
Eliminate compiler warnings on TCP support
| -rw-r--r-- | busdevice.c | 3 | ||||
| -rw-r--r-- | tcpclient.c | 12 |
2 files changed, 8 insertions, 7 deletions
diff --git a/busdevice.c b/busdevice.c index b73da3f..3e0dc12 100644 --- a/busdevice.c +++ b/busdevice.c @@ -137,6 +137,7 @@ static int parseIpAddress(const char *s, char *ip, size_t ipsize, short *port) { const char *ip_end, *port_start; + //ip_end and port_start are pointers to memory area of s, not offsets or indexes to s if (validateIpAddress(s, &ip_end, &port_start) == -1) return -1; @@ -144,7 +145,7 @@ static int parseIpAddress(const char *s, char *ip, size_t ipsize, short *port) if (!ip) return 0; - if (ipsize < ip_end - s + 1) + if (ipsize < (size_t)(ip_end - s + 1)) return -1; memcpy(ip, s, ip_end - s); diff --git a/tcpclient.c b/tcpclient.c index 31fb2f2..09d2426 100644 --- a/tcpclient.c +++ b/tcpclient.c @@ -56,7 +56,7 @@ int OpenTCPPort(const char * ip_addr, int port) fd_set myset; int res, valopt; socklen_t lon; - long arg; + unsigned long arg; #if defined(_WIN32) initwsa(); @@ -98,7 +98,7 @@ int OpenTCPPort(const char * ip_addr, int port) tv.tv_sec = 5; tv.tv_usec = 0; FD_ZERO(&myset); - FD_SET(sockfd, &myset); + FD_SET((unsigned int)sockfd, &myset); if (select(sockfd+1, NULL, &myset, NULL, &tv) > 0) { lon = sizeof(int); @@ -138,7 +138,7 @@ int PollTCPPort(int sockfd, unsigned char *buf, int size) int n; fd_set input; FD_ZERO(&input); - FD_SET(sockfd, &input); + FD_SET((unsigned int)sockfd, &input); struct timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = readTimeoutMs * 1000; @@ -155,14 +155,14 @@ int PollTCPPort(int sockfd, unsigned char *buf, int size) return(-1); } - n = read(sockfd, buf, size); + n = read(sockfd, (char*)buf, size); return(n); } int SendTCPByte(int sockfd, unsigned char byte) { int n; - n = write(sockfd, &byte, 1); + n = write(sockfd, (char*)&byte, 1); if(n<0) return(1); return(0); @@ -171,7 +171,7 @@ int SendTCPByte(int sockfd, unsigned char byte) int SendTCPBuf(int sockfd, unsigned char *buf, int size) { - int sent = write(sockfd, buf, size); + int sent = write(sockfd, (char*)buf, size); if (sent != size) { return sent; |
