This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit c1b097d70743746e8aacf723048a5bbe3daba532
Author: zhanghongyu <[email protected]>
AuthorDate: Fri Nov 27 19:59:12 2026 +0800

    arch/sim: fix the coding style of sim_wifihost.c.
    
    checkpatch reports 52 errors in this file, all of them about alignment:
    the case labels of fourteen switch statements sit at the column of the
    brace instead of two past it, a few braces and continuation lines are
    off, and two comment blocks are misaligned.
    
    Re-indent them.  The previous commit of this series touches this file,
    so the series would otherwise land with checkpatch errors on it.
    
    Whitespace only, apart from one pair of braces: the bare scope under
    case IW_MODE_INFRA in wifidriver_get_essid() held no declaration, so it
    only added a level of indentation and is removed.
    
    Signed-off-by: zhanghongyu <[email protected]>
---
 arch/sim/src/sim/sim_wifihost.c | 285 ++++++++++++++++++++--------------------
 1 file changed, 142 insertions(+), 143 deletions(-)

diff --git a/arch/sim/src/sim/sim_wifihost.c b/arch/sim/src/sim/sim_wifihost.c
index 90bb485f7ba..8f51511af18 100644
--- a/arch/sim/src/sim/sim_wifihost.c
+++ b/arch/sim/src/sim/sim_wifihost.c
@@ -333,12 +333,12 @@ static const char *get_auth_algstr(uint32_t auth_alg)
 {
   switch (auth_alg)
     {
-    case IW_ENCODE_ALG_TKIP:
-    case IW_ENCODE_ALG_CCMP:
-      return "OPEN";
-    default:
-      nerr("ERROR: Failed to transfer wireless auth alg: %u", auth_alg);
-      return NULL;
+      case IW_ENCODE_ALG_TKIP:
+      case IW_ENCODE_ALG_CCMP:
+        return "OPEN";
+      default:
+        nerr("ERROR: Failed to transfer wireless auth alg: %u", auth_alg);
+        return NULL;
     }
 }
 
@@ -346,17 +346,17 @@ static const char *get_authstr(int auth)
 {
   switch (auth)
     {
-    case IW_AUTH_WPA_VERSION_DISABLED:
-      return NULL;
+      case IW_AUTH_WPA_VERSION_DISABLED:
+        return NULL;
 
-    case IW_AUTH_WPA_VERSION_WPA:
-      return "WPA";
+      case IW_AUTH_WPA_VERSION_WPA:
+        return "WPA";
 
-    case IW_AUTH_WPA_VERSION_WPA2:
-      return "RSN";
-    default:
-      nerr("ERROR: Failed to transfer wifi auth: %d", auth);
-      return NULL;
+      case IW_AUTH_WPA_VERSION_WPA2:
+        return "RSN";
+      default:
+        nerr("ERROR: Failed to transfer wifi auth: %d", auth);
+        return NULL;
     }
 }
 
@@ -364,27 +364,27 @@ static const char *get_cipherstr(int cipher)
 {
   switch (cipher)
     {
-    case IW_AUTH_CIPHER_NONE:
-      return "NONE";
+      case IW_AUTH_CIPHER_NONE:
+        return "NONE";
 
-    case IW_AUTH_CIPHER_WEP40:
-      return "WEP40";
+      case IW_AUTH_CIPHER_WEP40:
+        return "WEP40";
 
-    case IW_AUTH_CIPHER_WEP104:
-      return "WEP104";
+      case IW_AUTH_CIPHER_WEP104:
+        return "WEP104";
 
-    case IW_AUTH_CIPHER_TKIP:
-      return "TKIP";
+      case IW_AUTH_CIPHER_TKIP:
+        return "TKIP";
 
-    case IW_AUTH_CIPHER_CCMP:
-      return "CCMP";
+      case IW_AUTH_CIPHER_CCMP:
+        return "CCMP";
 
-    case IW_AUTH_CIPHER_AES_CMAC:
-      return "AES-128-CMAC";
+      case IW_AUTH_CIPHER_AES_CMAC:
+        return "AES-128-CMAC";
 
-    default:
-      nerr("ERROR: Failed to transfer wifi cipher: %d", cipher);
-      return NULL;
+      default:
+        nerr("ERROR: Failed to transfer wifi cipher: %d", cipher);
+        return NULL;
     }
 }
 
@@ -488,12 +488,12 @@ static int utf8_escape(char *outp, int out_size,
               }
 
           case '\"':
-            if (res_size++ >= out_size)
-              {
-                return -EINVAL;
-              }
+          if (res_size++ >= out_size)
+            {
+              return -EINVAL;
+            }
 
-            *outp++ = '\\';
+          *outp++ = '\\';
 
           default:
             *outp++ = *inp++;
@@ -608,80 +608,80 @@ static size_t wpa_ssid_decode(char *buf, size_t maxlen, 
const char *str)
       switch (*pos)
         {
           case '\\':
-            pos++;
-            switch (*pos)
-              {
-                case '\\':
-                    buf[len++] = '\\';
-                    pos++;
-                    break;
-                case '"':
-                    buf[len++] = '"';
-                    pos++;
-                    break;
-                case 'n':
-                    buf[len++] = '\n';
-                    pos++;
-                    break;
-                case 'r':
-                    buf[len++] = '\r';
-                    pos++;
-                    break;
-                case 't':
-                    buf[len++] = '\t';
-                    pos++;
-                    break;
-                case 'e':
-                    buf[len++] = '\033';
-                    pos++;
-                    break;
-                case 'x':
-                    pos++;
-                    val = hex2byte(pos);
-                    if (val < 0)
-                      {
-                        val = hex2nibble(*pos);
-                        if (val < 0)
-                            break;
-                        buf[len++] = val;
-                        pos++;
-                      }
-                    else
-                      {
-                        buf[len++] = val;
-                        pos += 2;
-                      }
-                    break;
-                case '0':
-                case '1':
-                case '2':
-                case '3':
-                case '4':
-                case '5':
-                case '6':
-                case '7':
-                    val = *pos++ - '0';
-                    if (*pos >= '0' && *pos <= '7')
-                      {
-                        val = val * 8 + (*pos++ - '0');
-                      }
-
-                    if (*pos >= '0' && *pos <= '7')
-                      {
-                        val = val * 8 + (*pos++ - '0');
-                      }
-
-                    buf[len++] = val;
-                    break;
-                default:
-                    break;
-              }
+          pos++;
+          switch (*pos)
+            {
+              case '\\':
+                  buf[len++] = '\\';
+                  pos++;
+                  break;
+              case '"':
+                  buf[len++] = '"';
+                  pos++;
+                  break;
+              case 'n':
+                  buf[len++] = '\n';
+                  pos++;
+                  break;
+              case 'r':
+                  buf[len++] = '\r';
+                  pos++;
+                  break;
+              case 't':
+                  buf[len++] = '\t';
+                  pos++;
+                  break;
+              case 'e':
+                  buf[len++] = '\033';
+                  pos++;
+                  break;
+              case 'x':
+                  pos++;
+                  val = hex2byte(pos);
+                  if (val < 0)
+                    {
+                      val = hex2nibble(*pos);
+                      if (val < 0)
+                          break;
+                      buf[len++] = val;
+                      pos++;
+                    }
+                  else
+                    {
+                      buf[len++] = val;
+                      pos += 2;
+                    }
+                  break;
+              case '0':
+              case '1':
+              case '2':
+              case '3':
+              case '4':
+              case '5':
+              case '6':
+              case '7':
+                  val = *pos++ - '0';
+                  if (*pos >= '0' && *pos <= '7')
+                    {
+                      val = val * 8 + (*pos++ - '0');
+                    }
+
+                  if (*pos >= '0' && *pos <= '7')
+                    {
+                      val = val * 8 + (*pos++ - '0');
+                    }
+
+                  buf[len++] = val;
+                  break;
+              default:
+                  break;
+            }
             break;
         default:
             buf[len++] = *pos++;
             break;
-      }
-  }
+        }
+    }
 
   return len;
 }
@@ -1279,7 +1279,7 @@ static int wifidriver_set_psk(struct sim_wifi_s *wifidev,
       break;
     case IW_MODE_MASTER:
 
-       /* set wpa_passphrase psk_buf */
+      /* set wpa_passphrase psk_buf */
 
       ret = set_cmd(wifidev, "set wpa_passphrase %s", wifidev->password);
       wifidev->psk_flag = 1;
@@ -1392,22 +1392,21 @@ static int wifidriver_get_essid(struct sim_wifi_s 
*wifidev,
   switch (wifidev->mode)
     {
     case IW_MODE_INFRA:
-      {
-        /* get essid */
-
-        get_wpa_ssid(wifidev, essid);
-
-        /* get wpa_state */
-
-        if (get_wpa_state(wifidev))
-          {
-            essid->flags = IW_ESSID_ON;
-          }
-        else
-          {
-            essid->flags = IW_ESSID_OFF;
-          }
-      }
+
+      /* get essid */
+
+      get_wpa_ssid(wifidev, essid);
+
+      /* get wpa_state */
+
+      if (get_wpa_state(wifidev))
+        {
+          essid->flags = IW_ESSID_ON;
+        }
+      else
+        {
+          essid->flags = IW_ESSID_OFF;
+        }
       break;
     case IW_MODE_MASTER:
       break;
@@ -1467,14 +1466,14 @@ static int wifidriver_get_bssid(struct sim_wifi_s 
*wifidev,
   switch (wifidev->mode)
     {
       case IW_MODE_INFRA:
-        if (get_wpa_state(wifidev) && get_wpa_bssid(wifidev, bssid))
-          {
-            ret = OK;
-          }
-        else
-          {
-            ret = -ENOTTY;
-          }
+      if (get_wpa_state(wifidev) && get_wpa_bssid(wifidev, bssid))
+        {
+          ret = OK;
+        }
+      else
+        {
+          ret = -ENOTTY;
+        }
         break;
 
       case IW_MODE_MASTER:
@@ -1514,20 +1513,20 @@ static int wifidriver_start_connect(struct sim_wifi_s 
*wifidev)
 
       while (timeout--)
         {
-           if (get_wpa_state(wifidev))
-             {
-               unsigned char bssid[ETH_ALEN];
-               union iwreq_data wrqu;
+          if (get_wpa_state(wifidev))
+            {
+              unsigned char bssid[ETH_ALEN];
+              union iwreq_data wrqu;
 
-               get_wpa_bssid(wifidev, bssid);
+              get_wpa_bssid(wifidev, bssid);
 
-               memset(&wrqu, 0, sizeof(wrqu));
-               memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN);
-               wifi_send_event(&wifidev->dev->netdev, SIOCGIWAP, &wrqu);
-               return OK;
-             }
+              memset(&wrqu, 0, sizeof(wrqu));
+              memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN);
+              wifi_send_event(&wifidev->dev->netdev, SIOCGIWAP, &wrqu);
+              return OK;
+            }
 
-           sleep(1);
+          sleep(1);
         }
 
       return ERROR;
@@ -1598,8 +1597,8 @@ static int wifidriver_set_mode(struct sim_wifi_s *wifidev,
       if (ret == 0)
         {
           /* Check the network number, if no network, should add new network.
-          * Then, set the new network id to network_id.
-          */
+           * Then, set the new network id to network_id.
+           */
 
           int num;
 

Reply via email to