[clang][analyzer] No end-of-file when seek to file begin.
authorBalázs Kéri <balazs.keri@ericsson.com>
Fri, 30 Jun 2023 07:40:30 +0000 (09:40 +0200)
committerBalázs Kéri <balazs.keri@ericsson.com>
Fri, 30 Jun 2023 08:29:49 +0000 (10:29 +0200)
commit2eefd19613b8ea1f4cf59a4f0321bdc5f5ab0841
treee36f7ae47ece36b536f456fe3cb11a33a8cf3885
parentdb15ace6ab667af302f8788ab2a14c3382522ed4
[clang][analyzer] No end-of-file when seek to file begin.

If `fseek` is used with 0 position and SEEK_SET it sets the position
to the start of the file. This should not cause FEOF (end of file) error.
The case of an empty file is not handled for simplification.
It is not exactly defined in what cases `fseek` produces the different
error states. Normally feof should not happen at all because it is
possible to set the position after the end of file, but previous tests
showed that still feof (and any other error cases) can happen.

Reviewed By: donat.nagy

Differential Revision: https://reviews.llvm.org/D153363
clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
clang/test/Analysis/stream-error.c