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 ffc29e9a5dfe1313e7b631f84e265d1310de4ed5
Author: AlmAck <[email protected]>
AuthorDate: Wed Sep 2 23:13:14 2026 +0200

    drivers/mtd/filemtd: fix nxstyle errors in filemtd.c
    
    Pre-existing violations in this file, reported by checkpatch because the
    preceding commit touches it, and requested by a reviewer.
    
    Three "Missing blank line after declarations", in the BIOC_PARTINFO,
    MTDIOC_ERASESTATE and register-time-erase blocks.
    
    The rest were one problem: the whole mtd_loop_ioctl() switch body sits two
    columns short of NuttX style. With `switch` at 2 and its brace at 4, case
    labels belong at 6 — as they already are in filemtd_ioctl() earlier in this
    same file — but here the comments and cases sit at 4 and everything under
    them follows suit, which checkpatch reports as 21 separate comment,
    alignment and brace errors. Reindented the block to match, including the
    two stray closing lines that had drifted to seven and five columns.
    
    Whitespace only: `git diff -w` is empty apart from the three added blank
    lines, and the brace count is unchanged. checkpatch is clean against
    master.
    
    Signed-off-by: AlmAck <[email protected]>
---
 drivers/mtd/filemtd.c | 107 ++++++++++++++++++++++++++------------------------
 1 file changed, 55 insertions(+), 52 deletions(-)

diff --git a/drivers/mtd/filemtd.c b/drivers/mtd/filemtd.c
index 87c9e710229..92c0102770d 100644
--- a/drivers/mtd/filemtd.c
+++ b/drivers/mtd/filemtd.c
@@ -507,6 +507,7 @@ static int filemtd_ioctl(FAR struct mtd_dev_s *dev, int cmd,
         {
           FAR struct partition_info_s *info =
             (FAR struct partition_info_s *)arg;
+
           if (info != NULL)
             {
               info->numsectors  = priv->nblocks *
@@ -530,6 +531,7 @@ static int filemtd_ioctl(FAR struct mtd_dev_s *dev, int cmd,
       case MTDIOC_ERASESTATE:
         {
           FAR uint8_t *result = (FAR uint8_t *)arg;
+
           *result = CONFIG_FILEMTD_ERASESTATE;
 
           ret = OK;
@@ -580,6 +582,7 @@ static int mtd_loop_setup(FAR const char *devname, FAR 
const char *filename,
           /* Try to erase the entire device, before register */
 
           FAR struct file_dev_s *fdev = (FAR struct file_dev_s *)mtd;
+
           mtd->erase(mtd, offset / erasesize, fdev->nblocks);
         }
 
@@ -698,61 +701,61 @@ static int mtd_loop_ioctl(FAR struct file *filep, int cmd,
 
   switch (cmd)
     {
-    /* Command:      LOOPIOC_SETUP
-     * Description:  Setup the loop device
-     * Argument:     A pointer to a read-only instance of struct losetup_s.
-     * Dependencies: The loop device must be enabled (CONFIG_MTD_LOOP=y)
-     */
-
-    case MTD_LOOPIOC_SETUP:
-      {
-        FAR struct mtd_losetup_s *setup =
-          (FAR struct mtd_losetup_s *)((uintptr_t)arg);
-
-        if (setup == NULL)
-          {
-            ret = -EINVAL;
-          }
-        else
-          {
+      /* Command:      LOOPIOC_SETUP
+       * Description:  Setup the loop device
+       * Argument:     A pointer to a read-only instance of struct losetup_s.
+       * Dependencies: The loop device must be enabled (CONFIG_MTD_LOOP=y)
+       */
+
+      case MTD_LOOPIOC_SETUP:
+        {
+          FAR struct mtd_losetup_s *setup =
+            (FAR struct mtd_losetup_s *)((uintptr_t)arg);
+
+          if (setup == NULL)
+            {
+              ret = -EINVAL;
+            }
+          else
+            {
 #  ifndef CONFIG_MTD_CONFIG_NONE
-            ret = mtd_loop_setup(setup->devname, setup->filename,
-                                 setup->sectsize, setup->erasesize,
-                                 setup->offset, setup->configdata);
+              ret = mtd_loop_setup(setup->devname, setup->filename,
+                                   setup->sectsize, setup->erasesize,
+                                   setup->offset, setup->configdata);
 #  else
-            ret = mtd_loop_setup(setup->devname, setup->filename,
-                                 setup->sectsize, setup->erasesize,
-                                 setup->offset);
+              ret = mtd_loop_setup(setup->devname, setup->filename,
+                                   setup->sectsize, setup->erasesize,
+                                   setup->offset);
 #  endif
-          }
-      }
-      break;
-
-    /* Command:      LOOPIOC_TEARDOWN
-     * Description:  Teardown a loop device previously setup via
-     *               LOOPIOC_SETUP
-     * Argument:     A read-able pointer to the path of the device to be
-     *               torn down
-     * Dependencies: The loop device must be enabled (CONFIG_MTD_LOOP=y)
-     */
-
-    case MTD_LOOPIOC_TEARDOWN:
-      {
-        FAR const char *devname = (FAR const char *)((uintptr_t)arg);
-
-        if (devname == NULL)
-          {
-            ret = -EINVAL;
-          }
-        else
-          {
-            ret = mtd_loop_teardown(devname);
-          }
-       }
-       break;
-
-     default:
-       ret = -ENOTTY;
+            }
+        }
+        break;
+
+      /* Command:      LOOPIOC_TEARDOWN
+       * Description:  Teardown a loop device previously setup via
+       *               LOOPIOC_SETUP
+       * Argument:     A read-able pointer to the path of the device to be
+       *               torn down
+       * Dependencies: The loop device must be enabled (CONFIG_MTD_LOOP=y)
+       */
+
+      case MTD_LOOPIOC_TEARDOWN:
+        {
+          FAR const char *devname = (FAR const char *)((uintptr_t)arg);
+
+          if (devname == NULL)
+            {
+              ret = -EINVAL;
+            }
+          else
+            {
+              ret = mtd_loop_teardown(devname);
+            }
+        }
+        break;
+
+      default:
+        ret = -ENOTTY;
     }
 
   return ret;

Reply via email to