wlan: Fix of batch scan result  string format

If previous batch scan response was truncated then subsequent
batch scan results should not start with "####" if it is not
new batch scan list

Change-Id: I6a87118944c8924e27187b1b3ff57e427c367097
CRs-fixed: 575694
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c
index af90047..afbf0a4 100644
--- a/CORE/HDD/src/wlan_hdd_main.c
+++ b/CORE/HDD/src/wlan_hdd_main.c
@@ -814,6 +814,7 @@
     tANI_U32 nBestN;
     tANI_U8  ucRfBand;
     tANI_U32 nRtt;
+    tANI_U32 temp;
 
     /*initialize default values*/
     nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ;
@@ -848,11 +849,11 @@
     if ((strncmp(inPtr, "SCANFREQ", 8) == 0))
     {
         inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
-                    &nScanFreq, &lastArg);
+                    &temp, &lastArg);
 
-        if (0 == nScanFreq)
+        if (0 != temp)
         {
-           nScanFreq = HDD_SET_BATCH_SCAN_DEFAULT_FREQ;
+           nScanFreq = temp;
         }
 
         if ( (NULL == inPtr) || (TRUE == lastArg))
@@ -892,11 +893,11 @@
     if ((strncmp(inPtr, "BESTN", 5) == 0))
     {
         inPtr = hdd_extract_assigned_int_from_str(inPtr, 10,
-                    &nBestN, &lastArg);
+                    &temp, &lastArg);
 
-        if (0 == nBestN)
+        if (0 != temp)
         {
-           nBestN = HDD_SET_BATCH_SCAN_BEST_NETWORK;
+           nBestN = temp;
         }
 
         if (TRUE == lastArg)
@@ -913,14 +914,7 @@
     if ((strncmp(inPtr, "CHANNEL", 7) == 0))
     {
         inPtr = hdd_extract_assigned_char_from_str(inPtr, &val, &lastArg);
-        if (TRUE == lastArg)
-        {
-            goto done;
-        }
-        else if (NULL == inPtr)
-        {
-            return -EINVAL;
-        }
+
         if (('A' == val) || ('a' == val))
         {
             ucRfBand = HDD_SET_BATCH_SCAN_24GHz_BAND_ONLY;
@@ -931,6 +925,15 @@
         }
         else
         {
+            ucRfBand = HDD_SET_BATCH_SCAN_DEFAULT_BAND;
+        }
+
+        if (TRUE == lastArg)
+        {
+            goto done;
+        }
+        else if (NULL == inPtr)
+        {
             return -EINVAL;
         }
     }
@@ -1399,8 +1402,9 @@
       pAdapter->isTruncated = TRUE;
       if (rem_len >= strlen("%%%%"))
       {
-          ret = snprintf(pDest, strlen("%%%%"), "%%%%%%%%");
+          ret = snprintf(pDest, sizeof(temp), "%%%%");
       }
+      else
       {
           ret = 0;
       }