Fix code warning.
Change-Id: Ib11fb49f528d3688351ae349d5b4e307c28b3967
diff --git a/mbtk/libmbtk_lib/net/mbtk_ifc.c b/mbtk/libmbtk_lib/net/mbtk_ifc.c
index 51267f5..3a7b24b 100755
--- a/mbtk/libmbtk_lib/net/mbtk_ifc.c
+++ b/mbtk/libmbtk_lib/net/mbtk_ifc.c
@@ -152,6 +152,7 @@
return ret;
}
+#if 0
/* deprecated - v4 only */
static int ifc_create_default_route2(const char *name, const char *gw)
{
@@ -175,6 +176,7 @@
LOGD("ifc_create_default_route(%s) = %d", name, ret);
return ret;
}
+#endif
int mbtk_ifc_open(void)
{
@@ -572,6 +574,6 @@
LOGD("Set IPv6 : %s success.", ipv6);
exit:
- close(socket);
+ mbtk_close(sockfd);
return err;
}
diff --git a/mbtk/libmbtk_lib/net/mbtk_net_control.c b/mbtk/libmbtk_lib/net/mbtk_net_control.c
index 722efda..458f940 100755
--- a/mbtk/libmbtk_lib/net/mbtk_net_control.c
+++ b/mbtk/libmbtk_lib/net/mbtk_net_control.c
@@ -298,7 +298,7 @@
struct timeval timeout;
int select_r;
int read_r;
- struct sockaddr_nl sa;
+// struct sockaddr_nl sa;
struct nlmsghdr *nh;
char buff[NET_CONTROL_BUF_SIZE];
diff --git a/mbtk/libmbtk_lib/net/mbtk_sock.c b/mbtk/libmbtk_lib/net/mbtk_sock.c
index d52abdb..ccd872f 100755
--- a/mbtk/libmbtk_lib/net/mbtk_sock.c
+++ b/mbtk/libmbtk_lib/net/mbtk_sock.c
@@ -33,13 +33,13 @@
if(sock_info->addr_family == MBTK_ADDR_IPV6) { // Only IPv6
family = AF_INET6;
}
- if(sock_info->sock_type == MBTK_SOCK_UDP) { // UDP
+ if(sock_info->sock_type == MBTK_SOCK_UDP_COM) { // UDP
// socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if((sock_info->fd = socket(family, SOCK_DGRAM, IPPROTO_UDP)) < 0){
LOGE("socket() fail.[%d]",errno);
goto result_fail;
}
- } else if(sock_info->sock_type == MBTK_SOCK_TCP){ // TCP
+ } else if(sock_info->sock_type == MBTK_SOCK_TCP_COM){ // TCP
if((sock_info->fd = socket(family, SOCK_STREAM, IPPROTO_TCP)) < 0){
LOGE("socket() fail.[%d]",errno);
goto result_fail;
diff --git a/mbtk/libmbtk_lib/net/mbtk_sock2.c b/mbtk/libmbtk_lib/net/mbtk_sock2.c
index ae5329e..45ae0b6 100755
--- a/mbtk/libmbtk_lib/net/mbtk_sock2.c
+++ b/mbtk/libmbtk_lib/net/mbtk_sock2.c
@@ -44,6 +44,7 @@
#include "mbtk_sock2.h"
#include "mbtk_sock_internal.h"
+#include "mbtk_str.h"
//#include "mbtk_openssl.h"
#define SA struct sockaddr
@@ -97,6 +98,7 @@
return FALSE;
}
+#if 0
static bool sock_is_close(int sockfd)
{
char buff[32];
@@ -113,6 +115,7 @@
return TRUE;
}
+#endif
static int sock_info_find_by_fd(int handle,int fd)
{
@@ -181,7 +184,7 @@
&& (epoll_events[i].events & EPOLLOUT)) {
LOGD("%d can read and write.",epoll_events[i].data.fd);
int error = -1;
- int len = sizeof(int);
+ socklen_t len = sizeof(int);
if(getsockopt(epoll_events[i].data.fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0){
LOGE("getsockopt fail.[%d]",errno);
}else{
@@ -627,9 +630,9 @@
}
}
- inter_info->ctx = &ctx;
+ inter_info->ctx = ctx;
- inter_info->ssl = &ssl;
+ inter_info->ssl = ssl;
return 0;
}
@@ -772,7 +775,7 @@
if (FD_ISSET(mbtk_sock[handle]->inter_infos[index_free].fd, &rset)
&& FD_ISSET(mbtk_sock[handle]->inter_infos[index_free].fd, &wset)) {
int error = -1;
- int len = sizeof(int);
+ socklen_t len = sizeof(int);
LOGE("Can read and write.");
if(getsockopt(mbtk_sock[handle]->inter_infos[index_free].fd, SOL_SOCKET, SO_ERROR, &error, &len) < 0){
LOGE("getsockopt fail.[%d]",errno);
@@ -818,7 +821,7 @@
printf("\nmbtk_sock_read:\n%s\n",mbtk_ftp_ssl_read_buf_s);
char cmd_buff[50];
- int len=0,code;
+ int len=0;
memset(cmd_buff,0,sizeof(cmd_buff));
len = snprintf(cmd_buff, 50, "AUTH TLS\r\n");
@@ -908,18 +911,18 @@
}
#ifdef MBTK_POLARSSL_SUPPORT
- if(mbtk_sock[handle]->inter_infos[index_free].ssl!=NULL);
+ if(mbtk_sock[handle]->inter_infos[index_free].ssl!=NULL)
printf("\nmbtk_sock[handle]->inter_infos[index_free].ssl not empty\n");
return mbtk_polarssl_close(&mbtk_sock[handle]->inter_infos[index_free]);
#else
- if(mbtk_sock[handle]->inter_infos[index_free].ssl!=NULL);
+ if(mbtk_sock[handle]->inter_infos[index_free].ssl!=NULL)
printf("\nmbtk_sock[handle]->inter_infos[index_free].ssl not empty\n");
return mbtk_openssl_close(&mbtk_sock[handle]->inter_infos[index_free]);
#endif
}
extern int mbtk_sock_write(mbtk_sock_handle handle,mbtk_sock_session session,
- void *buffer,
+ const void *buffer,
unsigned int buf_len,
unsigned int timeout,
int *mbtk_errno)
@@ -964,9 +967,9 @@
while(count < buf_len){
if(mbtk_sock[handle]->infos[index].is_support_ssl) {
#ifdef MBTK_POLARSSL_SUPPORT
- len = mbtk_polarssl_write(inter_info->ssl,(char*)buffer + count,buf_len - count);
+ len = mbtk_polarssl_write(inter_info->ssl,(const unsigned char*)buffer + count,buf_len - count);
#else
- len = mbtk_openssl_write(inter_info->ssl,(char*)buffer + count,buf_len - count);
+ len = mbtk_openssl_write(inter_info->ssl,(const unsigned char *)buffer + count,buf_len - count);
#endif
} else
@@ -1073,9 +1076,9 @@
try_count++;
if(mbtk_sock[handle]->infos[index].is_support_ssl) {
#ifdef MBTK_POLARSSL_SUPPORT
- len = mbtk_polarssl_read(inter_info->ssl,(char*)buffer + count,buf_len - count);
+ len = mbtk_polarssl_read(inter_info->ssl,(unsigned char*)buffer + count,buf_len - count);
#else
- len = mbtk_openssl_read(inter_info->ssl,(char*)buffer + count,buf_len - count);
+ len = mbtk_openssl_read(inter_info->ssl,(unsigned char *)buffer + count,buf_len - count);
#endif
} else
@@ -1224,12 +1227,12 @@
}
unsigned int count = 0;
- unsigned int read_count = 0;
+// unsigned int read_count = 0;
memset(buf_ptr, 0, buf_len);
char *temp_ptr = (char *)buffer;
copy_angin_ssl:
while(*read_line_count > 0 && *temp_ptr != '\n') {
- if(*temp_ptr == NULL)
+ if(temp_ptr == NULL)
{
printf("\n*temp_ptr is null\n");
goto read_end;
@@ -1249,9 +1252,9 @@
try_count++;
if(mbtk_sock[handle]->infos[index].is_support_ssl) {
#ifdef MBTK_POLARSSL_SUPPORT
- len = mbtk_polarssl_read(inter_info->ssl,(char*)buffer + count,buf_len - count);
+ len = mbtk_polarssl_read(inter_info->ssl,(unsigned char*)buffer + count,buf_len - count);
#else
- len = mbtk_openssl_read(inter_info->ssl,(char*)buffer + count,buf_len - count);
+ len = mbtk_openssl_read(inter_info->ssl,(unsigned char*)buffer + count,buf_len - count);
#endif
} else
len = read(inter_info->fd,(char*)buffer + count,buf_len - count);
@@ -1425,9 +1428,9 @@
while(read_count < buf_len) {
if(mbtk_sock[handle]->infos[index].is_support_ssl) {
#ifdef MBTK_POLARSSL_SUPPORT
- len = ssl_read(inter_info->ssl,(char*)buffer + read_count,buf_len - read_count);
+ len = ssl_read(inter_info->ssl,(unsigned char*)buffer + read_count,buf_len - read_count);
#else
- len = mbtk_openssl_read(inter_info->ssl,(char*)buffer + read_count,buf_len - read_count);
+ len = mbtk_openssl_read(inter_info->ssl,(unsigned char*)buffer + read_count,buf_len - read_count);
#endif
} else
@@ -1516,9 +1519,9 @@
memset(buffer,0x0,buf_len);
if(mbtk_sock[handle]->infos[index].is_support_ssl) {
#ifdef MBTK_POLARSSL_SUPPORT
- len = ssl_read(inter_info->ssl,(char*)buffer,buf_len);
+ len = ssl_read(inter_info->ssl,(unsigned char*)buffer,buf_len);
#else
- len = mbtk_openssl_read(inter_info->ssl,(char*)buffer,buf_len);
+ len = mbtk_openssl_read(inter_info->ssl,(unsigned char*)buffer,buf_len);
#endif
} else
@@ -1717,7 +1720,7 @@
return -1;
}
- unsigned int count = 0;
+// unsigned int count = 0;
int len = 0;
if(mbtk_sock[handle]->infos[index].type == MBTK_SOCK_TCP) {
if(ioctl(inter_info->fd, FIONREAD, &len))