fjpanag opened a new pull request, #7345:
URL: https://github.com/apache/incubator-nuttx/pull/7345

   ## Summary
   
   When `CONFIG_STDIO_DISABLE_BUFFERING` is not set (i.e. buffering IS 
enabled), and when a file is reopened (`freopen()`), then the read buffers 
where not flushed.
   
   This had as a result that the file position and the buffer became 
de-synchronized.  
   When reading from this file, wrong data were returned, from a position 
different to what the file position dictated.  
   
   The addition of the `fseek()` call ensures that the file position is 
correctly set to what the re-open wants, and internally calls `lib_rdflush()`.
   
   ## Impact
   
   Bug fix.
   
   ## Testing
   
   Tested on simulator with a test scenario that:
   1. Opened an existing file, and read 1 character from it.
   2. Re-opened the file.
   3. Read 1 character from the file again.
   
   Before, step 3 returned the *second* character of the file.  
   Now it correctly returns the *first* character, as it should.
   
   
   
   
   


-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to