[clang] [NFC][analyzer] Add regression tests from bisection commits to the CSA's test suite (PR #241058)

Balázs Benics via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 11 02:40:22 PST 2026


================
@@ -175,3 +176,40 @@ void errno_realpath(char *Path, char *Buf) {
     if (errno) {} // expected-warning{{An undefined value may be read from 'errno'}}
   }
 }
+
+#define PATH_MAX 4096
+#define AF_UNIX 1
+#define SOCK_SEQPACKET 5
+#define SOCK_CLOEXEC 02000000
+
+void *malloc(size_t);
+void free(void *);
+int dosomething(char *);
+
+int GH43015_connect_socket(char **mname) {
+  int ret;
+  *mname = (char *)malloc(PATH_MAX);
+
+  int fd = socket(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
+  if (fd < 0) {
+    ret = errno;
+    free(*mname);
+    return ret;
+  }
+
+  {
+    ret = recv(fd, *mname, PATH_MAX, 0);
+    if (ret > 0) return 0;
+  }
+  close(fd);
+  return ret;
+}
+
+int GH43015(void) {
+  char *mname;
+  int ret = GH43015_connect_socket(&mname);
+  if (ret)
+    return ret;
+
+  return dosomething(mname); // no-warning
+}
----------------
steakhal wrote:

I'd kinda object to this test case as-is. I think it has a lot of unrelated stuff.
Importantly the intention of the test author is unclear. What warning was on that marked line and why, and why shouldn’t be a warning there.
What should happen if a warning appears at some other location in the test, is that okay or not?

Usually, the lower the complexity, the easier it is to convey the intent of the test. Naturally, it will diverge from the actual reported case.

https://github.com/llvm/llvm-project/pull/241058


More information about the cfe-commits mailing list