You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/06/07 17:22:34 UTC
[incubator-nuttx] 03/05: libc/stdio: Add FLAG_KEEP to avoid the duplication of (O_BINARY | O_EXCL)
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit d8aa41de7b1663300d274443d2907a3ced1ee47e
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Jun 2 14:26:49 2022 +0800
libc/stdio: Add FLAG_KEEP to avoid the duplication of (O_BINARY | O_EXCL)
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
libs/libc/stdio/lib_fopen.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/libs/libc/stdio/lib_fopen.c b/libs/libc/stdio/lib_fopen.c
index d1b77fbe12..9798654735 100644
--- a/libs/libc/stdio/lib_fopen.c
+++ b/libs/libc/stdio/lib_fopen.c
@@ -49,6 +49,8 @@
#define MODE_NONE 0 /* No access mode determined */
#define MODE_MASK (MODE_R | MODE_W | MODE_A)
+#define FLAG_KEEP (O_BINARY | O_EXCL)
+
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -204,7 +206,7 @@ int lib_mode2oflags(FAR const char *mode)
{
/* Retain any binary and exclusive mode selections */
- oflags &= (O_BINARY | O_EXCL);
+ oflags &= FLAG_KEEP;
/* Open for read/write access */
@@ -216,7 +218,7 @@ int lib_mode2oflags(FAR const char *mode)
{
/* Retain any binary and exclusive mode selections */
- oflags &= (O_BINARY | O_EXCL);
+ oflags &= FLAG_KEEP;
/* Open for write read/access, truncating any existing
* file.
@@ -230,7 +232,7 @@ int lib_mode2oflags(FAR const char *mode)
{
/* Retain any binary and exclusive mode selections */
- oflags &= (O_BINARY | O_EXCL);
+ oflags &= FLAG_KEEP;
/* Read from the beginning of the file; write to the
* end,