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

Add VSIFErrorL() and VSIFClearErrL(), robustness fixes in VSICopyFile() #9937

Merged
merged 13 commits into from
May 28, 2024

Conversation

rouault
Copy link
Member

@rouault rouault commented May 15, 2024

Those rationale for this big set of changes is a robustnes fix in VSICopyFile() to detect an error when reading the source file. But it turns out that we have no clean way in the API to distinguish from end-of-file vs error when Read() returns less bytes than requested. Well, we could use Eof() not return true to potentially mean that an error occured, but a number of file systems (e.g /vsigzip/) actually set the Eof flag when an error occured. So to be in known territory, let's fully implement POSIX FILE* API, by adding a Error() and ClearErr() methods that map to POSIX ferror() and clearerr(), and fix implementations where needed. This is a somewhat risky change, and not easy to fully test. MIGRATION_GUIDE.TXT is updated to hint that testing for VSIFEofL() is no longer sufficient to exit a reading loop.

@rouault rouault added this to the 3.10.0 milestone May 15, 2024
@rouault rouault force-pushed the vsiferrorl branch 9 times, most recently from e39b6d4 to d385d28 Compare May 16, 2024 01:26
@coveralls
Copy link
Collaborator

coveralls commented May 16, 2024

Coverage Status

coverage: 69.131%. remained the same
when pulling b1cc25f on rouault:vsiferrorl
into 77031d7 on OSGeo:master.

```
 * \fn VSIVirtualHandle::Error()
 * \brief Test the error indicator.
 *
 * Returns TRUE (non-zero) if an error condition occurred during the
 * previous read operation. The error indicator is cleared by a call to
 * VSIFClearErrL(). Note that a end-of-file situation, reported by VSIFEofL(),
 * is *not* an error reported by VSIFErrorL().
```

```
 * \fn VSIVirtualHandle::ClearErr()
 * \brief Reset the error and end-of-file indicators.
```
@rouault rouault merged commit 06e1043 into OSGeo:master May 28, 2024
35 checks passed
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.

None yet

2 participants