From: James Jones Date: Tue, 14 Feb 2023 15:16:09 +0000 (-0600) Subject: Upload the result of preprocessing a modeling file (#4892) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94a1adb5213a7cd4b7a8b6dee8567c1d63e0d984;p=thirdparty%2Ffreeradius-server.git Upload the result of preprocessing a modeling file (#4892) 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. --- diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index c5f2d9d0a10..04314fe193a 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -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 index cbc447b5e71..00000000000 --- a/src/coverity-model/exfile.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -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 index 00000000000..f204611c14d --- /dev/null +++ b/src/coverity-model/merged_model.c @@ -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 , 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 +#include +#include + +#include +#include +#include +#include + +#include +#include + +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 +#include +#include + +#include +#include + +#include + +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 index e1713d7a079..00000000000 --- a/src/coverity-model/pool.c +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include - -#include -#include - -#include - -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; -}