[clang-tools-extra] [clang-tidy] Add 'bugprone-suspicious-fread-fwrite-return' check (PR #206359)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 28 19:59:56 PDT 2026
================
@@ -227,6 +225,15 @@ New checks
Finds instances where the result of a standard algorithm is used in a Boolean
context without being compared to the end iterator.
+- New :doc:`bugprone-suspicious-fread-fwrite-return
+ <clang-tidy/checks/bugprone/suspicious-fread-fwrite-return>` check.
+
+ Finds suspicious checks of the return value of ``fread`` and ``fwrite``.
+ Developers sometimes mistakenly treat the result like the ``ssize_t``
+ return value of POSIX ``read`` and ``write``. ``fread`` and ``fwrite`` instead
+ return the number of elements transferred as a ``size_t``, making tests
+ such as ``<= 0`` incorrect.
----------------
EugeneZelenko wrote:
```suggestion
```
One sentence is enough.
https://github.com/llvm/llvm-project/pull/206359
More information about the cfe-commits
mailing list