]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Upload the result of preprocessing a modeling file (#4892)
authorJames Jones <jejones3141@gmail.com>
Tue, 14 Feb 2023 15:16:09 +0000 (09:16 -0600)
committerGitHub <noreply@github.com>
Tue, 14 Feb 2023 15:16:09 +0000 (09:16 -0600)
We can't run cov-make-library ourselves, which is the only command
that lets you say where to find header files. So, we'll preprocess
a single model file that includes whatever we choose to model the
stubs for, grouped at least by the source file they come from, each
group starting with #include directives appearing in the source file.

.github/workflows/coverity.yml
src/coverity-model/exfile.c [deleted file]
src/coverity-model/merged_model.c [new file with mode: 0644]
src/coverity-model/pool.c [deleted file]

index c5f2d9d0a10090d4a95ea6bd00effd3e40c947dc..04314fe193a64bf8d3604c9e40baa48467e79b06 100644 (file)
@@ -66,8 +66,6 @@ jobs:
           export CC=clang
           export PATH=`pwd`/coverity_tool/bin:$PATH
           ./configure -with-rlm-python-bin=/usr/bin/python2.7
-          mkdir -p coverity_tool/config
-          cov-make-library --compiler-opt -I --compiler-opt src/freeradius-devel src/coverity-model/*
           cov-configure --template --compiler clang --comptype clangcc
           cov-build --dir cov-int make
 
diff --git a/src/coverity-model/exfile.c b/src/coverity-model/exfile.c
deleted file mode 100644 (file)
index cbc447b..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-#include <freeradius-devel/protocol/freeradius/freeradius.internal.h>
-#include <freeradius-devel/server/base.h>
-#include <freeradius-devel/server/exfile.h>
-
-#include <freeradius-devel/util/debug.h>
-#include <freeradius-devel/util/misc.h>
-#include <freeradius-devel/util/perm.h>
-#include <freeradius-devel/util/syserror.h>
-
-#include <sys/stat.h>
-#include <fcntl.h>
-
-int exfile_open(exfile_t *ef, char const *filename, mode_t permissions, off_t *offset)
-{
-    int result;
-
-    if (ef->locking && result > 0) __coverity_exclusive_lock_acquire__(ef->mutex);
-    return result;
-}
-
-int exfile_close(exfile_t *ef, int fd)
-{
-    int result;
-
-    if (ef->locking) __coverity_exclusive_lock_release__(ef->mutex);
-    return result;
-}
diff --git a/src/coverity-model/merged_model.c b/src/coverity-model/merged_model.c
new file mode 100644 (file)
index 0000000..f204611
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Below are modeling functions that use Coverity functions (the __coverity_*__())
+ * to tell it the functions' intent.
+ *
+ * cov-make-library is the only model-related program that lets one specify compiler
+ * options, notably -I to specify where header files live....but it is NOT in the
+ * gzipped tar file of coverity programs one can run locally, so pending further
+ * information, one must create a file with modelig functions that one can upload via
+ * the web interfacet that does not #include header files not in the C standard.
+ *
+ * Speaking of -I, it would need to be cc -E -I <path to get to src>, since
+ * src contains the freeradius-devel symlink.
+ *
+ * The most nearly sane way to do that is to preprocessthis file and upload the
+ * output via the web. It would be good if this could be automated. One can do this
+ * from the command line in the top-level directory of the reposiitory with the command
+ *
+ *     cc -E -I src -I/usr/include/kqueue -D HAVE_CLOCK_GETTIME src/coverity-model/merged_model.c
+ *
+ * and redirecting standard output to a file to then upload via Coverity's web interface as the
+ * modeling file.
+ *
+ * (One may well ask what static functions are doing here. Coverity says that one
+ * can model static functions, so here they are. This may require further change.)
+ *
+ * Since standard header files are guaranteed idempotent and FreeRADIUS header files
+ * are idempotent, we group modeling functions according to the source file the
+ * functions being modeled come from and keep the #include directives in that file
+ * with them.
+ */
+
+
+#include <freeradius-devel/protocol/freeradius/freeradius.internal.h>
+#include <freeradius-devel/server/base.h>
+#include <freeradius-devel/server/exfile.h>
+
+#include <freeradius-devel/util/debug.h>
+#include <freeradius-devel/util/misc.h>
+#include <freeradius-devel/util/perm.h>
+#include <freeradius-devel/util/syserror.h>
+
+#include <sys/stat.h>
+#include <fcntl.h>
+
+int exfile_open(exfile_t *ef, char const *filename, mode_t permissions, off_t *offset)
+{
+    int result;
+
+    if (ef->locking && result > 0) __coverity_exclusive_lock_acquire__(ef->mutex);
+    return result;
+}
+
+int exfile_close(exfile_t *ef, int fd)
+{
+    int result;
+
+    if (ef->locking) __coverity_exclusive_lock_release__(ef->mutex);
+    return result;
+}
+
+#include <freeradius-devel/server/base.h>
+#include <freeradius-devel/server/modpriv.h>
+#include <freeradius-devel/util/debug.h>
+
+#include <freeradius-devel/util/heap.h>
+#include <freeradius-devel/util/misc.h>
+
+#include <time.h>
+
+static fr_pool_connection_t *connection_spawn(fr_pool_t *pool, request_t *request, fr_time_t now, bool in_use, bool unlock)
+{
+       fr_pool_connection_t *result;
+
+       if (result && !unlock)  __coverity_exclusive_lock_acquire__(pool->mutex);
+       return result;
+}
+
+static fr_pool_connection_t *connection_find(fr_pool_t *pool, void *conn)
+{
+       fr_pool_connection_t *result;
+
+       if (result)  __coverity_exclusive_lock_acquire__(pool->mutex);
+       return result;
+}
+
diff --git a/src/coverity-model/pool.c b/src/coverity-model/pool.c
deleted file mode 100644 (file)
index e1713d7..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <freeradius-devel/server/base.h>
-#include <freeradius-devel/server/modpriv.h>
-#include <freeradius-devel/util/debug.h>
-
-#include <freeradius-devel/util/heap.h>
-#include <freeradius-devel/util/misc.h>
-
-#include <time.h>
-
-static fr_pool_connection_t *connection_spawn(fr_pool_t *pool, request_t *request, fr_time_t now, bool in_use, bool unlock)
-{
-       fr_pool_connection_t *result;
-       
-       if (result && !unlock)  __coverity_exclusive_lock_acquire__(pool->mutex);
-       return result;
-}
-
-static fr_pool_connection_t *connection_find(fr_pool_t *pool, void *conn)
-{
-       fr_pool_connection_t *result;
-       
-       if (result)  __coverity_exclusive_lock_acquire__(pool->mutex); 
-       return result;
-}