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-apps.git

commit b4f1e2949462a6e3c8ba7233e48649757906a2aa
Author: Nightt <[email protected]>
AuthorDate: Tue May 19 17:56:09 2026 +0800

    apps: Fix additional open() arguments.
    
    Add missing mode arguments to direct open() calls that use O_CREAT.
    
    Also open the lp503x device with explicit read-only flags instead of 
O_CREAT, matching the device-node usage.
    
    Signed-off-by: Nightt <[email protected]>
---
 benchmarks/sd_bench/sd_bench_main.c                   | 2 +-
 examples/lp503x/lp503x_main.c                         | 2 +-
 examples/settings/settings_main.c                     | 4 ++--
 system/nxcamera/nxcamera.c                            | 2 +-
 testing/drivers/drivertest/drivertest_audio.c         | 3 ++-
 testing/drivers/sd_stress/sd_stress_main.c            | 2 +-
 testing/fs/smart_test/smart_test.c                    | 2 +-
 testing/testsuites/kernel/fs/cases/fs_poll_test.c     | 4 ++--
 testing/testsuites/kernel/syscall/cases/fcntl_test.c  | 2 +-
 testing/testsuites/kernel/syscall/cases/lseek_test.c  | 2 +-
 testing/testsuites/kernel/syscall/cases/rmdir_test.c  | 2 +-
 testing/testsuites/kernel/syscall/cases/unlink_test.c | 2 +-
 12 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/benchmarks/sd_bench/sd_bench_main.c 
b/benchmarks/sd_bench/sd_bench_main.c
index 44d30fa63..9822ac748 100644
--- a/benchmarks/sd_bench/sd_bench_main.c
+++ b/benchmarks/sd_bench/sd_bench_main.c
@@ -451,7 +451,7 @@ int main(int argc, char *argv[])
 
   cfg.run_duration *= 1000;
   bench_fd = open(BENCHMARK_FILE,
-                  O_CREAT | (verify ? O_RDWR : O_WRONLY) | O_TRUNC);
+                  O_CREAT | (verify ? O_RDWR : O_WRONLY) | O_TRUNC, 0666);
 
   if (bench_fd < 0)
     {
diff --git a/examples/lp503x/lp503x_main.c b/examples/lp503x/lp503x_main.c
index 5a43da39c..0eba5c1b3 100644
--- a/examples/lp503x/lp503x_main.c
+++ b/examples/lp503x/lp503x_main.c
@@ -632,7 +632,7 @@ int main(int argc, FAR char *argv[])
   int len;
   int x;
 
-  fd = open(CONFIG_EXAMPLES_LP503X_DEVPATH, O_CREAT);
+  fd = open(CONFIG_EXAMPLES_LP503X_DEVPATH, O_RDONLY);
   if (fd < 0)
     {
       fprintf(stderr, "ERROR: Failed to open %s: %d\n",
diff --git a/examples/settings/settings_main.c 
b/examples/settings/settings_main.c
index b284a4843..3f718aa7c 100644
--- a/examples/settings/settings_main.c
+++ b/examples/settings/settings_main.c
@@ -115,7 +115,7 @@ int settings_main(int argc, FAR char *argv[])
   if (ret == -ENOENT)
     {
       printf("No existing binary storage file found. Creating it.\n");
-      fd = open(bin_path, O_CREAT);
+      fd = open(bin_path, O_CREAT, 0666);
       if (fd < 0)
         {
           printf("Failed to create settings file\n");
@@ -138,7 +138,7 @@ int settings_main(int argc, FAR char *argv[])
   if (ret == -ENOENT)
     {
       printf("No existing text storage file found. Creating it.\n");
-      fd = open(text_path, O_CREAT);
+      fd = open(text_path, O_CREAT, 0666);
       if (fd < 0)
         {
           printf("Failed to create settings file\n");
diff --git a/system/nxcamera/nxcamera.c b/system/nxcamera/nxcamera.c
index b8f5d41aa..331ff6214 100644
--- a/system/nxcamera/nxcamera.c
+++ b/system/nxcamera/nxcamera.c
@@ -575,7 +575,7 @@ int nxcamera_setfile(FAR struct nxcamera_s *pcam, FAR const 
char *pfile,
 
   /* Try to open the file */
 
-  temp_fd = open(pfile, O_CREAT | O_RDWR);
+  temp_fd = open(pfile, O_CREAT | O_RDWR, 0666);
   if (temp_fd == -1)
     {
       /* Error opening the file */
diff --git a/testing/drivers/drivertest/drivertest_audio.c 
b/testing/drivers/drivertest/drivertest_audio.c
index de12da3d1..0232d32b7 100644
--- a/testing/drivers/drivertest/drivertest_audio.c
+++ b/testing/drivers/drivertest/drivertest_audio.c
@@ -382,7 +382,8 @@ static int audio_test_prepare(FAR struct audio_state_s 
*state,
     }
   else
     {
-      state->out_fd = open(state->outfile, O_WRONLY | O_CREAT | O_TRUNC);
+      state->out_fd = open(state->outfile,
+                           O_WRONLY | O_CREAT | O_TRUNC, 0666);
     }
 
   if (state->out_fd == -1)
diff --git a/testing/drivers/sd_stress/sd_stress_main.c 
b/testing/drivers/sd_stress/sd_stress_main.c
index da6e4f5c7..39c3e563e 100644
--- a/testing/drivers/sd_stress/sd_stress_main.c
+++ b/testing/drivers/sd_stress/sd_stress_main.c
@@ -160,7 +160,7 @@ static bool create_files(const char *dir, const char *name,
           bytes[j] = (bytes[j] + i) & 0xff;
         }
 
-      int fd = open(path, O_CREAT | O_RDWR);
+      int fd = open(path, O_CREAT | O_RDWR, 0666);
 
       if (fd < 0)
         {
diff --git a/testing/fs/smart_test/smart_test.c 
b/testing/fs/smart_test/smart_test.c
index 13bd393c8..f439cdfda 100644
--- a/testing/fs/smart_test/smart_test.c
+++ b/testing/fs/smart_test/smart_test.c
@@ -393,7 +393,7 @@ static int smart_circular_log_test(char *filename)
 
   /* Open the circular log file */
 
-  fd = open(filename, O_RDWR | O_CREAT);
+  fd = open(filename, O_RDWR | O_CREAT, 0666);
   if (fd == -1)
     {
       printf("Unable to create file %s\n", filename);
diff --git a/testing/testsuites/kernel/fs/cases/fs_poll_test.c 
b/testing/testsuites/kernel/fs/cases/fs_poll_test.c
index e51ae9ee9..fcbcaf246 100644
--- a/testing/testsuites/kernel/fs/cases/fs_poll_test.c
+++ b/testing/testsuites/kernel/fs/cases/fs_poll_test.c
@@ -59,13 +59,13 @@ void test_nuttx_fs_poll01(FAR void **state)
   int poll01_ret;
   struct pollfd poll01_fds[5];
 
-  poll01_fd1 = open(I_FILE1, O_RDONLY | O_CREAT);
+  poll01_fd1 = open(I_FILE1, O_RDONLY | O_CREAT, 0666);
   assert_true(poll01_fd1 >= 0);
 
   poll01_fds[0].fd = poll01_fd1;
   poll01_fds[0].events = POLLOUT;
 
-  poll01_fd2 = open(I_FILE2, O_RDWR | O_CREAT);
+  poll01_fd2 = open(I_FILE2, O_RDWR | O_CREAT, 0666);
   assert_true(poll01_fd2 >= 0);
 
   poll01_fds[1].fd = poll01_fd2;
diff --git a/testing/testsuites/kernel/syscall/cases/fcntl_test.c 
b/testing/testsuites/kernel/syscall/cases/fcntl_test.c
index 0897f65b4..2dfdcc370 100644
--- a/testing/testsuites/kernel/syscall/cases/fcntl_test.c
+++ b/testing/testsuites/kernel/syscall/cases/fcntl_test.c
@@ -306,7 +306,7 @@ void test_nuttx_syscall_fcntl06(FAR void **state)
 
   sprintf(fname, "fcntl06_%d", gettid());
 
-  fd = open(fname, O_RDWR | O_CREAT);
+  fd = open(fname, O_RDWR | O_CREAT, 0700);
   assert_true(fd > 0);
 
   for (lc = 0; lc < 10; lc++)
diff --git a/testing/testsuites/kernel/syscall/cases/lseek_test.c 
b/testing/testsuites/kernel/syscall/cases/lseek_test.c
index cef521915..619f61a72 100644
--- a/testing/testsuites/kernel/syscall/cases/lseek_test.c
+++ b/testing/testsuites/kernel/syscall/cases/lseek_test.c
@@ -91,7 +91,7 @@ void test_nuttx_syscall_lseek01(FAR void **state)
 
   snprintf(filename, sizeof(filename), "%s_file", __func__);
 
-  fd = open(filename, O_RDWR | O_CREAT);
+  fd = open(filename, O_RDWR | O_CREAT, 0644);
 
   if (fd > 0)
     {
diff --git a/testing/testsuites/kernel/syscall/cases/rmdir_test.c 
b/testing/testsuites/kernel/syscall/cases/rmdir_test.c
index 8068a2253..20c74a9c6 100644
--- a/testing/testsuites/kernel/syscall/cases/rmdir_test.c
+++ b/testing/testsuites/kernel/syscall/cases/rmdir_test.c
@@ -103,7 +103,7 @@ void test_nuttx_syscall_rmdir02(FAR void **state)
   assert_int_equal(ret, 0);
   ret = mkdir("Rmdir02_testdir/test1", (S_IRWXU | S_IRWXG | S_IRWXO));
   assert_int_equal(ret, 0);
-  fd = open("Rmdir02_testfile2", O_CREAT | O_RDWR);
+  fd = open("Rmdir02_testfile2", O_CREAT | O_RDWR, 0700);
 
   if (fd > 0)
     close(fd);
diff --git a/testing/testsuites/kernel/syscall/cases/unlink_test.c 
b/testing/testsuites/kernel/syscall/cases/unlink_test.c
index f3a7e1697..e5b771786 100644
--- a/testing/testsuites/kernel/syscall/cases/unlink_test.c
+++ b/testing/testsuites/kernel/syscall/cases/unlink_test.c
@@ -55,7 +55,7 @@ void test_nuttx_syscall_unlink01(FAR void **state)
 
   sprintf(fname, "%s_file", __func__);
 
-  fd = open(fname, O_RDWR | O_CREAT);
+  fd = open(fname, O_RDWR | O_CREAT, 0700);
   if (fd > 0)
     {
       close(fd);

Reply via email to