mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
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 <87569709+nightt5879@users.noreply.github.com>
This commit is contained in:
parent
5c703f5603
commit
b4f1e29494
12 changed files with 15 additions and 14 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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++)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue