Fix code warning.

Change-Id: Ib11fb49f528d3688351ae349d5b4e307c28b3967
diff --git a/mbtk/mbtk_logd/alog_read.c b/mbtk/mbtk_logd/alog_read.c
index a907662..cfb7556 100755
--- a/mbtk/mbtk_logd/alog_read.c
+++ b/mbtk/mbtk_logd/alog_read.c
@@ -9,7 +9,12 @@
 #include <time.h>
 #include <unistd.h>
 #include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pthread.h>
+
 #include "log_config.h"
+#include "mbtk_utils.h"
 
 #define  ALOG_DEV "/dev/log_radio"
 #define LOG_CONFIG_LEN 50
@@ -35,7 +40,7 @@
     android_LogPriority priority;
     int32_t pid;
     int32_t tid;
-    const char * tag;
+    char * tag;
     size_t messageLen;
     const char * message;
 } AndroidLogEntry;
@@ -45,10 +50,11 @@
 static int log_size = 1 * 1024 * 1024;
 
 static log_config_entry *config = NULL;
-static char tmp_log[48] = {0};
+static char tmp_log[1024] = {0};
 
 static int fd_radio = 0;
 
+int tcp_connect(char* ip, int port);
 
 void hex_print(char* buf, int len)
 {
@@ -135,7 +141,7 @@
 int alog_process(char* data, int len, AndroidLogEntry *entry)
 {
     int i, n = 0;
-    int tmp_len;
+//    int tmp_len;
 
     for (i = 0; i < len;) {
         if (data[i] == '\0') {
@@ -202,32 +208,32 @@
     int index = 0;
     int len = 0;
     struct stat s;
-    
+
 
     static char buffer[MAX_BUFFER_SIZE] = {0};
     static int buffer_index = 0;
-    
+
     if(access(tmp_log, W_OK) != 0)
     {
         fd_radio = open(tmp_log, O_CREAT | O_WRONLY| O_APPEND, 0600);
-        if (fd_radio < 0) 
+        if (fd_radio < 0)
         {
             fprintf(stderr, "failed to open %s: %s\n", tmp_log, strerror(errno));
             exit(-1);
         }
-        
+
     }
 
 
     if (log_size && (!stat(tmp_log, &s)) && (s.st_size > log_size))
     {
         fd_radio = get_rotate_file(fd_radio, log_file, _file_list);
-        if (fd_radio < 0) 
+        if (fd_radio < 0)
         {
             fprintf(stderr, "failed to open %s: %s\n", log_file, strerror(errno));
             exit(-1);
         }
-      
+
     }
 
     if(fileter_log(entry->priority, entry->tag, config->filter_list))
@@ -242,7 +248,7 @@
 
     totalLen = snprintf(defaultBuffer, sizeof(defaultBuffer),
     "%s %c/%s (%d): %s\n", timeBuf, priChar, entry->tag, entry->pid, entry->message);
-    
+
     len = strlen(defaultBuffer);
     if(access("/etc/syslog_encrypt_flag", F_OK) == 0)
     {
@@ -256,33 +262,33 @@
     if(buffer_index >= RADIOLOG_BUFF_SIZE)
     {
         // Flush the buffer if it's full
-        if (write(fd_radio, buffer, buffer_index) < 0) 
+        if (write(fd_radio, buffer, buffer_index) < 0)
         {
             perror("write error");
             return -1;
         }
         buffer_index = 0; // Reset buffer index after flushing
     }
-        
+
     if(totalLen < RADIOLOG_BUFF_SIZE)
     {
-        //copy buf to buffer 
+        //copy buf to buffer
         memcpy(buffer + buffer_index, defaultBuffer, totalLen);
         buffer_index += totalLen;
     }
     else
     {
-        write(fd_radio, defaultBuffer, totalLen);
+        mbtk_write(fd_radio, defaultBuffer, totalLen);
     }
-        
-    
+
+
     return 0;
 }
 
 void* alog_thread(void* argv)
 {
     int dev_fd, ret;
-    int log_fd;
+//    int log_fd;
     AndroidLogEntry entry;
     char buf[512] = {0};
     static struct file_list_t file_list;
@@ -312,33 +318,33 @@
 		strncpy(log_file, config->out_path, LOG_CONFIG_LEN - 1);
 	}
 
-    if (config->ip && config->port) 
+    if (config->ip && config->port)
     {
         int port = atoi(config->port);
         printf("%s %d : %s:%s\n", __FUNCTION__, __LINE__, config->ip, config->port);
-        log_fd = tcp_connect(config->ip, port);
-    } 
-    else if (strlen(log_file) > 0) 
+        tcp_connect(config->ip, port);
+    }
+    else if (strlen(log_file) > 0)
     {
         //sprintf(tmp_log, "/tmp/log%s", strstr_tail(log_file, "/"));
-        
+
         snprintf(tmp_log,sizeof(tmp_log), "%s", log_file);
         // 先将文件保存到 /tmp/log/ 目录下,后面到达 rotate_file_size 后,转移到out_path
-       
-    } 
-    else 
+
+    }
+    else
     {
-        log_fd = STDOUT_FILENO;
+        //log_fd = STDOUT_FILENO;
     }
     if(config->rotate_file_size)
     {
         log_size = config->rotate_file_size;
     }
     printf("android log start...\n");
-    while (1) 
+    while (1)
     {
         ret = read(dev_fd, buf, sizeof(buf));
-        if (ret < 0) 
+        if (ret < 0)
         {
             printf("read error\n");
             break;
@@ -348,7 +354,7 @@
         memset(buf, 0, sizeof(buf));
     }
     close(dev_fd);
-   
+
     printf("%s exit \n", __FUNCTION__);
     pthread_exit(NULL);
 	return NULL;