Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Feb 2020 16:14:08 +0000 (UTC)
From:      Ulrich Spoerlein <uqs@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r357731 - user/uqs/coverity
Message-ID:  <202002101614.01AGE87e022679@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002101614.01AGE87e022679>