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 2023/10/29 15:09:26 UTC
(nuttx) 02/03: libc/stdio: Remove bforce from lib_fflush[_unlocked]
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/nuttx.git
commit 2c9511e655d75b03e60f8d4e0fd87b3ade0f0aef
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Oct 22 04:47:22 2023 +0800
libc/stdio: Remove bforce from lib_fflush[_unlocked]
since all callers set bforce to true
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
libs/libc/libc.h | 4 ++--
libs/libc/stdio/lib_fclose.c | 2 +-
libs/libc/stdio/lib_fflush.c | 2 +-
libs/libc/stdio/lib_fputc.c | 2 +-
libs/libc/stdio/lib_fputs.c | 4 ++--
libs/libc/stdio/lib_freopen.c | 2 +-
libs/libc/stdio/lib_libfflush.c | 9 ++++-----
libs/libc/stdio/lib_libflushall.c | 4 ++--
libs/libc/stdio/lib_libfwrite.c | 2 +-
libs/libc/stdio/lib_puts.c | 2 +-
libs/libc/stdio/lib_wrflush_unlocked.c | 2 +-
libs/libc/stream/lib_stdoutstream.c | 2 +-
libs/libc/stream/lib_stdsostream.c | 2 +-
13 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/libs/libc/libc.h b/libs/libc/libc.h
index 178fa44737..ba339d48d5 100644
--- a/libs/libc/libc.h
+++ b/libs/libc/libc.h
@@ -211,8 +211,8 @@ FAR char *lib_fgets_unlocked(FAR char *buf, size_t buflen, FILE *stream,
/* Defined in lib_libfflush.c */
-ssize_t lib_fflush(FAR FILE *stream, bool bforce);
-ssize_t lib_fflush_unlocked(FAR FILE *stream, bool bforce);
+ssize_t lib_fflush(FAR FILE *stream);
+ssize_t lib_fflush_unlocked(FAR FILE *stream);
/* Defined in lib_rdflush_unlocked.c */
diff --git a/libs/libc/stdio/lib_fclose.c b/libs/libc/stdio/lib_fclose.c
index 357f7f9f93..174238c45f 100644
--- a/libs/libc/stdio/lib_fclose.c
+++ b/libs/libc/stdio/lib_fclose.c
@@ -75,7 +75,7 @@ int fclose(FAR FILE *stream)
if ((stream->fs_oflags & O_WROK) != 0)
{
- ret = lib_fflush(stream, true);
+ ret = lib_fflush(stream);
errcode = get_errno();
}
diff --git a/libs/libc/stdio/lib_fflush.c b/libs/libc/stdio/lib_fflush.c
index 532b327264..cbe4e7a602 100644
--- a/libs/libc/stdio/lib_fflush.c
+++ b/libs/libc/stdio/lib_fflush.c
@@ -66,7 +66,7 @@ int fflush(FAR FILE *stream)
}
else
{
- ret = lib_fflush(stream, true);
+ ret = lib_fflush(stream);
}
/* Check the return value */
diff --git a/libs/libc/stdio/lib_fputc.c b/libs/libc/stdio/lib_fputc.c
index 132468e051..ac7c06f8ee 100644
--- a/libs/libc/stdio/lib_fputc.c
+++ b/libs/libc/stdio/lib_fputc.c
@@ -45,7 +45,7 @@ int fputc_unlocked(int c, FAR FILE *stream)
if (c == '\n' && (stream->fs_flags & __FS_FLAG_LBF) != 0)
{
- ret = lib_fflush_unlocked(stream, true);
+ ret = lib_fflush_unlocked(stream);
if (ret < 0)
{
return EOF;
diff --git a/libs/libc/stdio/lib_fputs.c b/libs/libc/stdio/lib_fputs.c
index 60b6793153..4ae8b50538 100644
--- a/libs/libc/stdio/lib_fputs.c
+++ b/libs/libc/stdio/lib_fputs.c
@@ -67,7 +67,7 @@ int fputs_unlocked(FAR const IPTR char *s, FAR FILE *stream)
if (ch == '\n' && (stream->fs_flags & __FS_FLAG_LBF) != 0)
{
- ret = lib_fflush_unlocked(stream, true);
+ ret = lib_fflush_unlocked(stream);
if (ret < 0)
{
return EOF;
@@ -107,7 +107,7 @@ int fputs_unlocked(FAR const IPTR char *s, FAR FILE *stream)
if (*s == '\n')
{
- ret = lib_fflush_unlocked(stream, true);
+ ret = lib_fflush_unlocked(stream);
if (ret < 0)
{
return EOF;
diff --git a/libs/libc/stdio/lib_freopen.c b/libs/libc/stdio/lib_freopen.c
index 7ca87f4c8a..b9b52dbd3e 100644
--- a/libs/libc/stdio/lib_freopen.c
+++ b/libs/libc/stdio/lib_freopen.c
@@ -106,7 +106,7 @@ FAR FILE *freopen(FAR const char *path, FAR const char *mode,
/* Flush the stream and invalidate the read buffer. */
- lib_fflush_unlocked(stream, true);
+ lib_fflush_unlocked(stream);
#ifndef CONFIG_STDIO_DISABLE_BUFFERING
lib_rdflush_unlocked(stream);
diff --git a/libs/libc/stdio/lib_libfflush.c b/libs/libc/stdio/lib_libfflush.c
index 94a8c37a66..2e268a0200 100644
--- a/libs/libc/stdio/lib_libfflush.c
+++ b/libs/libc/stdio/lib_libfflush.c
@@ -48,7 +48,6 @@
*
* Input Parameters:
* stream - the stream to flush
- * bforce - flush must be complete.
*
* Returned Value:
* A negated errno value on failure, otherwise the number of bytes remaining
@@ -56,7 +55,7 @@
*
****************************************************************************/
-ssize_t lib_fflush_unlocked(FAR FILE *stream, bool bforce)
+ssize_t lib_fflush_unlocked(FAR FILE *stream)
{
#ifndef CONFIG_STDIO_DISABLE_BUFFERING
FAR const char *src;
@@ -137,7 +136,7 @@ ssize_t lib_fflush_unlocked(FAR FILE *stream, bool bforce)
src += bytes_written;
nbuffer -= bytes_written;
}
- while (bforce && nbuffer > 0);
+ while (nbuffer > 0);
/* Reset the buffer position to the beginning of the buffer */
@@ -168,14 +167,14 @@ ssize_t lib_fflush_unlocked(FAR FILE *stream, bool bforce)
#endif
}
-ssize_t lib_fflush(FAR FILE *stream, bool bforce)
+ssize_t lib_fflush(FAR FILE *stream)
{
ssize_t ret;
/* Make sure that we have exclusive access to the stream */
flockfile(stream);
- ret = lib_fflush_unlocked(stream, bforce);
+ ret = lib_fflush_unlocked(stream);
funlockfile(stream);
return ret;
}
diff --git a/libs/libc/stdio/lib_libflushall.c b/libs/libc/stdio/lib_libflushall.c
index 11bda4577d..225482cb3c 100644
--- a/libs/libc/stdio/lib_libflushall.c
+++ b/libs/libc/stdio/lib_libflushall.c
@@ -63,7 +63,7 @@ int lib_flushall(FAR struct streamlist *list)
for (i = 0; i < 3; i++)
{
- lib_fflush(&list->sl_std[i], true);
+ lib_fflush(&list->sl_std[i]);
}
stream = list->sl_head;
@@ -77,7 +77,7 @@ int lib_flushall(FAR struct streamlist *list)
{
/* Flush the writable FILE */
- ret = lib_fflush(stream, true);
+ ret = lib_fflush(stream);
if (ret < 0)
{
/* An error occurred during the flush AND/OR we were unable
diff --git a/libs/libc/stdio/lib_libfwrite.c b/libs/libc/stdio/lib_libfwrite.c
index f5730c4dbe..6e00bb5362 100644
--- a/libs/libc/stdio/lib_libfwrite.c
+++ b/libs/libc/stdio/lib_libfwrite.c
@@ -130,7 +130,7 @@ ssize_t lib_fwrite_unlocked(FAR const void *ptr, size_t count,
{
/* Flush the buffered data to the IO stream */
- int bytes_buffered = lib_fflush_unlocked(stream, true);
+ int bytes_buffered = lib_fflush_unlocked(stream);
if (bytes_buffered < 0)
{
goto errout;
diff --git a/libs/libc/stdio/lib_puts.c b/libs/libc/stdio/lib_puts.c
index dfca094292..f6d45fc458 100644
--- a/libs/libc/stdio/lib_puts.c
+++ b/libs/libc/stdio/lib_puts.c
@@ -71,7 +71,7 @@ int puts(FAR const IPTR char *s)
if ((stream->fs_flags & __FS_FLAG_LBF) != 0)
{
- ret = lib_fflush_unlocked(stream, true);
+ ret = lib_fflush_unlocked(stream);
if (ret < 0)
{
nput = EOF;
diff --git a/libs/libc/stdio/lib_wrflush_unlocked.c b/libs/libc/stdio/lib_wrflush_unlocked.c
index 7bb9e699ff..0280ac7959 100644
--- a/libs/libc/stdio/lib_wrflush_unlocked.c
+++ b/libs/libc/stdio/lib_wrflush_unlocked.c
@@ -82,7 +82,7 @@ int lib_wrflush_unlocked(FAR FILE *stream)
* buffered write data was successfully flushed by lib_fflush().
*/
- return lib_fflush_unlocked(stream, true);
+ return lib_fflush_unlocked(stream);
#else
/* Verify that we were passed a valid (i.e., non-NULL) stream */
diff --git a/libs/libc/stream/lib_stdoutstream.c b/libs/libc/stream/lib_stdoutstream.c
index e168d8e358..8e168ffa55 100644
--- a/libs/libc/stream/lib_stdoutstream.c
+++ b/libs/libc/stream/lib_stdoutstream.c
@@ -113,7 +113,7 @@ static int stdoutstream_flush(FAR struct lib_outstream_s *self)
(FAR struct lib_stdoutstream_s *)self;
DEBUGASSERT(stream != NULL && stream->handle != NULL);
- return lib_fflush(stream->handle, true);
+ return lib_fflush(stream->handle);
}
#endif
diff --git a/libs/libc/stream/lib_stdsostream.c b/libs/libc/stream/lib_stdsostream.c
index 87dbbd1e7a..02886d6861 100644
--- a/libs/libc/stream/lib_stdsostream.c
+++ b/libs/libc/stream/lib_stdsostream.c
@@ -112,7 +112,7 @@ static int stdsostream_flush(FAR struct lib_sostream_s *self)
(FAR struct lib_stdsostream_s *)self;
DEBUGASSERT(stream != NULL && stream->handle != NULL);
- return lib_fflush(stream->handle, true);
+ return lib_fflush(stream->handle);
}
#endif