Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdio/file: fix numerous issues in the fread/fwrite functions #376

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ziemleszcz
Copy link
Contributor

@ziemleszcz ziemleszcz commented Aug 21, 2024

Description

Motivation and Context

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (refactoring, style fixes, git/CI config, submodule management, no code logic changes)

How Has This Been Tested?

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing linter checks and tests passed.
  • My changes generate no new compilation warnings for any of the targets.

Special treatment

  • This PR needs additional PRs to work (list the PRs, preferably in merge-order).
  • I will merge this PR by myself when appropriate.

@ziemleszcz ziemleszcz self-assigned this Aug 21, 2024
Also fixed error handling in blocking safe read to always return -1 on error.

JIRA: RTOS-892, RTOS-874
Fixed fread function issues:
 - non-blocking fread was not supported
 - unbuffered read was not setting F_ERROR on read errors
 - unbuffered read was not setting F_EOF at the end-of-file
 - unbuffered read was dropping bytes on EAGAIN
 - buffered read was not setting F_ERROR when refilling the buffer
 - buffered read was dropping bytes on EAGAIN
 - buffered read was incorrectly setting F_EOF on EAGAIN

Fixed fwrite function issues:
 - interleaved fread/fwrite functions weren't working for Unix sockets (caused by an unnecessary seek trigerring an error)
 - fwrite was returning 0 when read buffer discarding failed due to seek errors

JIRA: RTOS-892
Copy link

Unit Test Results

7 700 tests  ±0   6 985 ✅ ±0   37m 30s ⏱️ - 1m 20s
  436 suites ±0     715 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 7058c9c. ± Comparison against base commit 0fbc038.

@ziemleszcz ziemleszcz changed the title Ziemleszcz/rtos 892 stdio/file: fix numerous issues in the fread/fwrite functions Aug 22, 2024
@ziemleszcz ziemleszcz marked this pull request as ready for review August 22, 2024 11:57
@@ -101,18 +101,26 @@ ssize_t __safe_read(int fd, void *buf, size_t size)
continue;
}
else {
break;
return -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also fixed error handling in blocking safe read to always return -1 on error.

How is this different? The else branch is taken when rlen < 0, so if (rlen < 0) below is still executed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right - disregard this comment.

@ziemleszcz ziemleszcz marked this pull request as draft September 23, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants