From d8aa41de7b1663300d274443d2907a3ced1ee47e Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 2 Jun 2022 14:26:49 +0800 Subject: [PATCH] libc/stdio: Add FLAG_KEEP to avoid the duplication of (O_BINARY | O_EXCL) Signed-off-by: Xiang Xiao --- 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,