mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 09:18:00 +08:00
libc/stdio: Remove bforce from lib_fflush[_unlocked]
since all callers set bforce to true Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
committed by
Petro Karashchenko
parent
c3be772441
commit
2c9511e655
+2
-2
@@ -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 */
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ int fflush(FAR FILE *stream)
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = lib_fflush(stream, true);
|
||||
ret = lib_fflush(stream);
|
||||
}
|
||||
|
||||
/* Check the return value */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user