From: Jordan Rose Date: Sat, 5 Apr 2014 06:10:28 +0000 (+0000) Subject: [analyzer] Add an ErrnoChecker (PR18701) to the Potential Checkers list. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b2887d4c99917625f6361f0faa386fe064c3b31c;p=clang [analyzer] Add an ErrnoChecker (PR18701) to the Potential Checkers list. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@205667 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/www/analyzer/potential_checkers.html b/www/analyzer/potential_checkers.html index 5b32dd0329..6ec68a9909 100644 --- a/www/analyzer/potential_checkers.html +++ b/www/analyzer/potential_checkers.html @@ -314,6 +314,34 @@ int foo(bool cond) { + +

POSIX

+ ++ + + + +
Name, DescriptionExampleProgress
posix.Errno

+Record that errno is non-zero when certain functions fail. +
+#include <stdlib.h>
+
+int readWrapper(int fd, int *count) {
+  int lcount = read(fd, globalBuf, sizeof(globalBuf));
+  if (lcount < 0)
+    return errno;
+  *count = lcount;
+  return 0;
+}
+
+void use(int fd) {
+  int count;
+  if (!readWrapper(fd))
+    print("%d", count); // should not warn
+}
+
PR18701
+

undefined behavior