Shanks0224 commented on code in PR #22179:
URL: https://github.com/apache/nuttx/pull/22179#discussion_r4676134444


##########
libs/libc/stdio/lib_libfflush.c:
##########
@@ -90,11 +120,13 @@ ssize_t lib_fflush_unlocked(FAR FILE *stream)
 
       if (stream->fs_bufread != stream->fs_bufstart)
         {
-          /* The buffer holds read data... just return zero meaning "no bytes
-           * remaining in the buffer."
+          /* The buffer holds read data.  Discard it, including any
+           * characters pushed back with ungetc(), and set the file offset
+           * to the stream position.  There are no bytes remaining in the
+           * buffer.
            */
 
-          return 0;
+          return lib_fflush_rdflush(stream);

Review Comment:
   Fixed. The read data is now discarded only by an explicit 
fflush()/fflush_unlocked(); lib_fflush_unlocked(), which the read path calls, 
is unchanged. Your FIFO case ("r+", two fgetc()) gives a, b, and reading
     an "r+" file is as fast as on master. This change moved to #22241.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to