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

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


The following commit(s) were added to refs/heads/master by this push:
     new 326b68aa3 examples/userfs: use designated initializers for struct 
dirent
326b68aa3 is described below

commit 326b68aa3682a1f4efbf286086e610ffd96fbd9d
Author: Xiang Xiao <[email protected]>
AuthorDate: Sun Jun 21 01:08:24 2026 +0800

    examples/userfs: use designated initializers for struct dirent
    
    The g_rootdir[] table initialized each entry's struct dirent member
    positionally as { DTYPE_FILE, "FileN" }, which assumes d_type is the
    first field.  This breaks when struct dirent gains the POSIX d_ino field
    as its first member (see apache/nuttx: "fs/dirent: add d_ino member to
    struct dirent"): the file-name string would be assigned to d_type,
    producing -Wint-conversion warnings and an "initializer element is not
    computable at load time" error.
    
    Use designated initializers (.d_type / .d_name) so the table is robust
    against the field order of struct dirent.
    
    Also fix a 'Initiallly' typo in a nearby comment flagged by codespell.
    
    Signed-off-by: Xiang Xiao <[email protected]>
---
 examples/userfs/userfs_main.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/examples/userfs/userfs_main.c b/examples/userfs/userfs_main.c
index a2cf97ea5..0a6b89cee 100644
--- a/examples/userfs/userfs_main.c
+++ b/examples/userfs/userfs_main.c
@@ -142,19 +142,28 @@ static char g_file3_data[UFSTEST_FILE3_MXSIZE] = "This is 
file 3";
 static struct ufstest_file_s g_rootdir[UFSTEST_NFILES] =
 {
     {
-      { DTYPE_FILE, "File1" },
+      {
+        .d_type = DTYPE_FILE,
+        .d_name = "File1"
+      },
       UFSTEST_INIT_FILE1_SIZE,
       UFSTEST_FILE1_MXSIZE,
       g_file1_data
     },
     {
-      { DTYPE_FILE, "File2" },
+      {
+        .d_type = DTYPE_FILE,
+        .d_name = "File2"
+      },
       UFSTEST_INIT_FILE2_SIZE,
       UFSTEST_FILE2_MXSIZE,
       g_file2_data
     },
     {
-      { DTYPE_FILE, "File3" },
+      {
+        .d_type = DTYPE_FILE,
+        .d_name = "File3"
+      },
       UFSTEST_INIT_FILE3_SIZE,
       UFSTEST_FILE3_MXSIZE,
       g_file3_data
@@ -247,7 +256,7 @@ static int ufstest_open(FAR void *volinfo, FAR const char 
*relpath,
 
       opriv->file = file;
 
-      /* Initiallly, there is one reference count on the open data.  This may
+      /* Initially, there is one reference count on the open data.  This may
        * be incremented in the event that the file is dup'ed.
        */
 

Reply via email to