Skip to content

Commit

Permalink
hostfs: mask bit fields of not support
Browse files Browse the repository at this point in the history
Signed-off-by: wanggang26 <[email protected]>
  • Loading branch information
wanggang26 committed Sep 22, 2023
1 parent b53af56 commit 9e8f220
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion arch/arm/src/common/arm_hostfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ static ssize_t host_flen(long fd)

static int host_flags_to_mode(int flags)
{
static const int modemasks = O_RDONLY | O_WRONLY | O_TEXT | O_RDWR |
O_CREAT | O_TRUNC | O_APPEND;
static const int modeflags[] =
{
O_RDONLY | O_TEXT,
Expand All @@ -96,7 +98,7 @@ static int host_flags_to_mode(int flags)
int i;
for (i = 0; modeflags[i] != 0; i++)
{
if (modeflags[i] == flags)
if ((modemasks & flags) == modeflags[i])
{
return i;
}
Expand Down
4 changes: 3 additions & 1 deletion arch/arm64/src/common/arm64_hostfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ static ssize_t host_flen(long fd)

static int host_flags_to_mode(int flags)
{
static const int modemasks = O_RDONLY | O_WRONLY | O_TEXT | O_RDWR |
O_CREAT | O_TRUNC | O_APPEND;
static const int modeflags[] =
{
O_RDONLY | O_TEXT,
Expand All @@ -96,7 +98,7 @@ static int host_flags_to_mode(int flags)
int i;
for (i = 0; modeflags[i] != 0; i++)
{
if (modeflags[i] == flags)
if ((modemasks & flags) == modeflags[i])
{
return i;
}
Expand Down
4 changes: 3 additions & 1 deletion arch/risc-v/src/common/riscv_hostfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ static ssize_t host_flen(long fd)

static int host_flags_to_mode(int flags)
{
static const int modemasks = O_RDONLY | O_WRONLY | O_TEXT | O_RDWR |
O_CREAT | O_TRUNC | O_APPEND;
static const int modeflags[] =
{
O_RDONLY | O_TEXT,
Expand All @@ -96,7 +98,7 @@ static int host_flags_to_mode(int flags)
int i;
for (i = 0; modeflags[i] != 0; i++)
{
if (modeflags[i] == flags)
if ((modemasks & flags) == modeflags[i])
{
return i;
}
Expand Down

0 comments on commit 9e8f220

Please sign in to comment.