[PATCH] D69948: [Checkers] Added support for freopen to StreamChecker.

Gabor Marton via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 28 07:52:36 PST 2019


martong added inline comments.


================
Comment at: clang/test/Analysis/stream.c:160
+    } else {
+      // Open failed, f1 points now to an invalid stream but this condition is currently not checked.
+      rewind(f1);
----------------
This comment is confusing for me. Maybe there are typos here?
Isn't the 'freopen' failed? `fopen` was successful and it's return value was checked in line 153.
`f1` seems to be ok here (still associated with "foo.c"), only `f2` is bad, as we see in line 162.

Or `f1` is already closed here, even though it could not open the new file?


> If a new filename is specified, the function first attempts to close any file already associated with stream (third parameter) and disassociates it. Then, independently of whether that stream was successfuly closed or not, freopen opens the file specified by filename and associates it with the stream just as fopen would do using the specified mode.

https://stackoverflow.com/questions/20908740/check-the-return-value-of-freopen-in-c



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69948/new/

https://reviews.llvm.org/D69948





More information about the cfe-commits mailing list