svn commit: r357731 - user/uqs/coverity
Ulrich Spoerlein
uqs at FreeBSD.org
Mon Feb 10 16:14:08 UTC 2020
Author: uqs
Date: Mon Feb 10 16:14:07 2020
New Revision: 357731
URL: https://svnweb.freebsd.org/changeset/base/357731
Log:
Add the Coverity modeling file for posterity.
Added:
user/uqs/coverity/
user/uqs/coverity/model.c (contents, props changed)
Added: user/uqs/coverity/model.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/uqs/coverity/model.c Mon Feb 10 16:14:07 2020 (r357731)
@@ -0,0 +1,35 @@
+/*
+ * This is a model as used by our Coverity Scan systems. It was also in use
+ * back when we were on Coverity Prevent.
+ *
+ * https://scan.coverity.com/projects/freebsd/model_file
+ * upload it via https://scan.coverity.com/projects/freebsd?tab=analysis_settings
+ */
+
+/* From <sys/malloc.h>. */
+#define M_WAITOK 0x0002
+
+/*
+ * If M_WAIT_OK is set, malloc() will always return something meaningful.
+ */
+void *
+malloc(unsigned long size, struct malloc_type *mtp, int flags)
+{
+ int has_memory;
+
+ __coverity_negative_sink__(size);
+
+ if (flags & M_WAITOK || has_memory)
+ return __coverity_alloc__(size);
+
+ return 0;
+}
+
+/*
+ * Don't complain about leaking FDs in unit tests.
+ */
+static void
+leak(int fd)
+{
+ __coverity_close__(fd);
+}
More information about the svn-src-user
mailing list