Fix code warning.

Change-Id: Ib11fb49f528d3688351ae349d5b4e307c28b3967
diff --git a/mbtk/libmbtk_lib/ftp/mbtk_ftp.c b/mbtk/libmbtk_lib/ftp/mbtk_ftp.c
index f485ec7..69208d6 100755
--- a/mbtk/libmbtk_lib/ftp/mbtk_ftp.c
+++ b/mbtk/libmbtk_lib/ftp/mbtk_ftp.c
@@ -6,12 +6,14 @@
  Date:
  2020/10/28 11:49:08
  *************************************************************/
+#include <ctype.h>
+
 #include "mbtk_ftp.h"
 #include "mbtk_list.h"
 #include "mbtk_sock.h"
 #include "mbtk_str.h"
 #include "mbtk_sock2.h"
-#include<linux/msg.h>
+#include <linux/msg.h>
 
 /*************************************************************
  Constants and Macros
@@ -105,12 +107,12 @@
     return ptr;
 }
 
-static int ftp_cmd_handle(mbtk_ftp_info_s *info, const void *cmd, void *rsp,
+static int ftp_cmd_handle(mbtk_ftp_info_s *info, void *cmd, void *rsp,
                           uint32 *rsp_len)
 {
     int err;
     int rsp_code;
-    int len = strlen((char*) cmd);
+    unsigned int len = strlen((char*) cmd);
     // Write cmd
     if(info->auth_type != 0)
     {
@@ -144,13 +146,13 @@
             {
                 printf("\n mbtk_sock_read error:%d \n",err);
             }
-            rsp_code = atoi(mbtk_ftp_ssl_read_buf);
+            rsp_code = atoi((char*)mbtk_ftp_ssl_read_buf);
             printf("%s -> Code:%d; RSP:%s\n", (char*)cmd, rsp_code, (char* )mbtk_ftp_ssl_read_buf);
             if (rsp_code == 0)
             {
                 goto read_angin_1;
             }
-            memcpy((char* )rsp, mbtk_ftp_ssl_read_buf, strlen(mbtk_ftp_ssl_read_buf));
+            memcpy((char* )rsp, mbtk_ftp_ssl_read_buf, strlen((char*)mbtk_ftp_ssl_read_buf));
             //printf("\nrsp = %s\n",(char* )rsp);
             return rsp_code;
         }
@@ -182,7 +184,7 @@
         memset(buff, 0x0, 1024);
         if(info->auth_type != 0)
         {
-            unsigned char mbtk_ftp_ssl_read_buf[16384 + 1];
+            char mbtk_ftp_ssl_read_buf[16384 + 1];
             len = mbtk_sock_read(info->ftp_ssl_handle,info->session,mbtk_ftp_ssl_read_buf,sizeof(mbtk_ftp_ssl_read_buf),FTP_TIMEOUT,&err);
             if(err != 0)
             {
@@ -190,9 +192,8 @@
             }
             rsp_code = atoi(mbtk_ftp_ssl_read_buf);
             printf("%s -> Code:%d; RSP:%s\n", (char*)cmd, rsp_code, (char* )mbtk_ftp_ssl_read_buf);
-            char *mbtk_ftp_ssl_read_buf_p = NULL;
-            mbtk_ftp_ssl_read_buf_p = strstr(mbtk_ftp_ssl_read_buf,"\n");
-            if(mbtk_ftp_ssl_read_buf_p!=NULL);
+            char *mbtk_ftp_ssl_read_buf_p = strstr(mbtk_ftp_ssl_read_buf,"\n");
+            if(mbtk_ftp_ssl_read_buf_p!=NULL)
             {
                 if(strlen(mbtk_ftp_ssl_read_buf_p)>1)
                 {
@@ -374,7 +375,7 @@
     }
 
     // Get IPv4 and port
-    uint8 *ptr = rsp + 4;
+    char *ptr = (char*)rsp + 4;
     while (*ptr)
     {
         if (isdigit(*ptr))
@@ -383,7 +384,7 @@
     }
     // ptr point to first digit.
     memcpy(sock->host, ptr, strlen((char*) ptr));
-    ptr = sock->host;
+    ptr = (char*)(sock->host);
     int count = 0;
     while (*ptr)
     {
@@ -601,7 +602,7 @@
             if (strlen(name) > 0)
             {
                 LOGV("Name:%s",name);
-                memset(file_ptr.name,0,strlen(file_ptr.name)+1);
+                memset(file_ptr.name,0,strlen((char*)(file_ptr.name))+1);
                 memcpy(file_ptr.name, name, strlen(name));
                 char *temp = (char*) file_ptr.name
                              + strlen((char*) file_ptr.name) - 1;
@@ -682,7 +683,7 @@
             if (strlen(name) > 0)
             {
                 LOGV("Name:%s",name);
-                memset(file_ptr.name,0,strlen(file_ptr.name)+1);
+                memset(file_ptr.name,0,strlen((char*)file_ptr.name)+1);
                 memcpy(file_ptr.name, name, strlen(name));
                 char *temp = (char*) file_ptr.name
                              + strlen((char*) file_ptr.name) - 1;
@@ -930,8 +931,8 @@
             info->ftp_sock_ssl_info_data->ftp_ssl_support=1;
             info->ftp_sock_ssl_info_data->port = sock.port;
             info->ftp_sock_ssl_info_data->type = MBTK_SOCK_TCP;
-            info->ftp_sock_ssl_info_data->ingnore_cert = ~(info->sock_info[FTP_SOCK_CTRL].use_cert);
-            memcpy(info->ftp_sock_ssl_info_data->address, sock.host, strlen(sock.host));
+            info->ftp_sock_ssl_info_data->ingnore_cert = !(info->sock_info[FTP_SOCK_CTRL].use_cert);
+            memcpy(info->ftp_sock_ssl_info_data->address, sock.host, strlen((char*)sock.host));
             if(info->ftp_sock_ssl_info_data->is_support_ssl != 0)
             {
                 info->ftp_sock_ssl_info_data->is_support_ssl = 0;
@@ -1015,12 +1016,12 @@
 
     if (cmd == FTP_CMD_GET)   // Is download
     {
-        char cmd[100];
+        char cmd[200];
         if (info->file_trans.size_send > 0)   // Resume transmission
         {
             // REST size
-            memset(cmd, 0x0, 100);
-            snprintf(cmd, 100, "REST %ld\r\n", info->file_trans.size_send);
+            memset(cmd, 0x0, sizeof(cmd));
+            snprintf(cmd, sizeof(cmd), "REST %d\r\n", info->file_trans.size_send);
             code = ftp_cmd_handle(info, cmd, NULL, NULL);
             if (code != 350)
             {
@@ -1030,8 +1031,8 @@
             }
         }
 
-        memset(cmd, 0x0, 100);
-        snprintf(cmd, 100, "RETR %s\r\n", info->file_trans.remote_name);
+        memset(cmd, 0x0, sizeof(cmd));
+        snprintf(cmd, sizeof(cmd), "RETR %s\r\n", info->file_trans.remote_name);
         code = ftp_cmd_handle(info, cmd, NULL, NULL);
         if (code != 125 && code != 150)
         {
@@ -1072,9 +1073,9 @@
         if(info->auth_type != 0)
         {
                 int mbtk_errno;
-                char cmd[100];
-                memset(cmd, 0x0, 100);
-                snprintf(cmd, 100, "STOR %s\r\n", info->file_trans.remote_name);
+                char cmd[200];
+                memset(cmd, 0x0, sizeof(cmd));
+                snprintf(cmd, sizeof(cmd), "STOR %s\r\n", info->file_trans.remote_name);
         		LOGE("STOR %s .name:%s ", cmd, info->file_trans.remote_name);
                 code = ftp_cmd_handle(info, cmd, NULL, NULL);
                 if (code != 125 && code != 150)
@@ -1106,9 +1107,9 @@
         }
         else
         {
-            char cmd[100];
-            memset(cmd, 0x0, 100);
-            snprintf(cmd, 100, "STOR %s\r\n", info->file_trans.remote_name);
+            char cmd[200];
+            memset(cmd, 0x0, sizeof(cmd));
+            snprintf(cmd, sizeof(cmd), "STOR %s\r\n", info->file_trans.remote_name);
     		LOGE("STOR %s .name:%s ", cmd, info->file_trans.remote_name);
             code = ftp_cmd_handle(info, cmd, NULL, NULL);
             if (code != 125 && code != 150)
@@ -1827,7 +1828,7 @@
     info->file_trans.size_count = 0;
     info->file_trans.size_send = 0;
 
-    char line_buf[1024];
+//    char line_buf[1024];
     if(info->auth_type != 0)
         len = mbtk_sock_read(info->ftp_ssl_handle,info->session,buff,sizeof(buff),FTP_TIMEOUT,&err);
     else
@@ -2212,7 +2213,7 @@
                 unsigned char mbtk_ftp_ssl_read_buf[16384 + 1];
                 char cmd[50];
                 memset(cmd,0,50);
-                int len_ssl;
+//                int len_ssl;
 
 
                 memset(cmd,0,50);
@@ -2272,7 +2273,7 @@
                             &mbtk_errno);
                 printf("\nmbtk_sock_read PASS:\n%s\n",mbtk_ftp_ssl_read_buf);
                 char *ptr = NULL;
-                if((ptr = strstr(mbtk_ftp_ssl_read_buf,"220 ")) || (ptr = strstr(mbtk_ftp_ssl_read_buf,"230 "))) {
+                if((ptr = strstr((char*)mbtk_ftp_ssl_read_buf,"220 ")) || (ptr = strstr((char*)mbtk_ftp_ssl_read_buf,"230 "))) {
                     LOGI("RSP:%s",ptr);
                     printf("RSP:%s\n",ptr);
                 }
@@ -2375,16 +2376,16 @@
                                     int *port,int iptype)
 {
     char psz_port_cmd[128];
-    int i=0;
+//    int i=0;
 
     *port = rand() % (60000 - 50000 + 1) + 50000;
     sprintf(psz_port_cmd, "netstat -an | grep :%d > /dev/null", *port);
 
-        char ipBuf[32] = "";
+        char ipBuf[1024] = {0};
         FILE *fstream=NULL;
 
-        char buff[1024];
-        char iptype_str[8];
+        char buff[1024] = {0};
+//        char iptype_str[8];
         memset(buff,0,sizeof(buff));
         /*eth0可以换成eth1、docker0、em1、lo等*/
         if(iptype == MBTK_ADDR_IPV6)
@@ -2396,7 +2397,7 @@
             }
             if(NULL!=fgets(buff, sizeof(buff), fstream))
             {
-                snprintf(ipBuf, 39, "%s",buff);
+                snprintf(ipBuf, sizeof(buff), "%s",buff);
             }
             else
             {
@@ -2412,7 +2413,7 @@
             }
             if(NULL!=fgets(buff, sizeof(buff), fstream))
             {
-                snprintf(ipBuf, 18, "%s",buff);
+                snprintf(ipBuf, sizeof(ipBuf), "%s",buff);
             }
             else
             {