Fixed a bug with reversed arguments to the fwrite and fread functions for libc file mode.#333
Merged
armink merged 1 commit intoarmink:masterfrom Dec 25, 2024
Merged
Conversation
armink
reviewed
Dec 23, 2024
| if (fp) { | ||
| addr = addr % db->sec_size; | ||
| if ((fseek(fp, addr, SEEK_SET) != 0) || (fread(buf, size, 1, fp) != size)) | ||
| if ((fseek(fp, addr, SEEK_SET) != 0) || (fread(buf, size, 1, fp) != 1)) |
Owner
There was a problem hiding this comment.
Suggested change
| if ((fseek(fp, addr, SEEK_SET) != 0) || (fread(buf, size, 1, fp) != 1)) | |
| if ((fseek(fp, addr, SEEK_SET) != 0) || (fread(buf, 1, size, fp) != size)) |
Would this change be better?
Contributor
There was a problem hiding this comment.
- Armink's modification is more reasonable, and it is easier to understand by bytes. And it is the same as the way of the POSIX interface, which is read by bytes
- If you read by element, it must be strongly related to the write.
- If you follow the Armank method, you need to modify the implementation of the ERASE interface at the same time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When
FDB_USING_FILE_LIBC_MODEis enabled, thelibcfunctionsfwriteandfreadawaited an incorrect return.Current function calls want to write
sizebytes once, and wait for the size of bytes written to be returned, but the functions return how many times thesizewas written (written as1in the code), which always returns1, if it succeeds.[source]