Fix code warning.

Change-Id: Ib11fb49f528d3688351ae349d5b4e307c28b3967
diff --git a/mbtk/libmbtk_lib/wifi/sta_ctrl.c b/mbtk/libmbtk_lib/wifi/sta_ctrl.c
old mode 100644
new mode 100755
index e5e24aa..cad497c
--- a/mbtk/libmbtk_lib/wifi/sta_ctrl.c
+++ b/mbtk/libmbtk_lib/wifi/sta_ctrl.c
@@ -11,6 +11,7 @@
 #include "wpa_ctrl.h"

 #include "sta_ctrl.h"

 #include "mbtk_log.h"

+#include "mbtk_utils.h"

 

 //#include "sta_log.h"

 

@@ -41,7 +42,7 @@
     char *value

 );

 

-extern struct wpa_ctrl;

+// extern struct wpa_ctrl;

 

 static struct wpa_ctrl *sta_ctrl_conn;

 static struct wpa_ctrl *sta_mon_conn;

@@ -108,9 +109,12 @@
         bzero(pid_s, STA_BUF_SIZE);

         if(cmd)

         {

-            fgets(pid_s, STA_BUF_SIZE, cmd);

+            if(fgets(pid_s, STA_BUF_SIZE, cmd) == NULL) {

+

+            }

             pclose(cmd);

         }

+

         pid = atoi(pid_s);

         LOGE("%s pid =%d\n", name,pid);

         /* If pid is zero we break from while*/

@@ -142,7 +146,9 @@
     bzero(pid_s, STA_BUF_SIZE);

     if(cmd)

     {

-        fgets(pid_s, STA_BUF_SIZE, cmd);

+        if(fgets(pid_s, STA_BUF_SIZE, cmd) == NULL) {

+

+        }

         pclose(cmd);

     }

 

@@ -165,7 +171,7 @@
 {

     LOGE("Thread[%ld] run().\n",pthread_self());

 

-    int nready;

+    int nready = 0;

     struct epoll_event ev_sock,ev_pipe,events[20];

     int epfd = epoll_create(256);

     ev_sock.data.fd = wpa_ctrl_get_fd(sta_mon_conn);

@@ -252,7 +258,7 @@
         LOGE("sta_ctrl_conf_file_parse() fail(%d).\n",result);

         return result;

     }

-    snprintf(ctrl_path + strlen(ctrl_path),10,

+    sprintf(ctrl_path + strlen(ctrl_path),

         "/%s",

         sta_ctrl_ifname);

 

@@ -363,7 +369,7 @@
                 }else{

                     break;

                 }

-                *tmp--;

+                tmp--;

             }

 

             int size = snprintf(value,100,

@@ -416,7 +422,7 @@
             LOGE("\n");

     }

 

-end_success:

+//end_success:

 

     return result;

 end_fail:

@@ -441,7 +447,9 @@
 

     if(fd_tmp){

         char buf[200] = {0};

-        fgets(buf,200,fd_tmp);

+        if(fgets(buf,200,fd_tmp) == NULL) {

+

+        }

         pclose(fd_tmp);

         if(strlen(buf) > 0){

             LOGE("Driver %s fail.(%s)\n",(open?"open":"close"),buf);

@@ -500,19 +508,21 @@
     FILE *fd_tmp = popen("pidof wpa_supplicant","r");

     if(fd_tmp){

         char buf[200] = {0};

-        fgets(buf,200,fd_tmp);

+        if(fgets(buf,200,fd_tmp) == NULL) {

+

+        }

         pclose(fd_tmp);

         if(strlen(buf) > 0){

             LOGE("wpa_supplicant is running.(%s)\n",buf);

         }else{// Open wpa_supplicant

             bzero(buf,200);

-            

+

             snprintf(buf,200,

                 "wpa_supplicant -Dnl80211 -c%s -i%s -f%s -ddd &",

                 conf_file,

                 interface,

                 WPA_SUPPLICANT_LOG_FILE);

-            

+

             /*

              snprintf(buf,200,

                 "wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wifi/wpa_supplicant.conf -B");

@@ -538,7 +548,7 @@
         goto end_fail;

     }

 

-end_success:

+//end_success:

 

     return result;

 end_fail:

@@ -563,7 +573,7 @@
 

     sta_event_thread_is_running = 0;

     // End thread.

-    write(sta_ctrl_pipe_fd[1],"0",1);

+    mbtk_write(sta_ctrl_pipe_fd[1],"0",1);

 

 

     LOGE("Waitting for thread(%ld) exit.\n",sta_event_thread_id);

@@ -591,7 +601,7 @@
         }

     }

 

-end_success:

+//end_success:

     LOGE("sta_ctrl_wpa_deinit() end(success).\n");

     return result;

 end_fail: