diff --git a/cfg/sqlite3.cfg b/cfg/sqlite3.cfg new file mode 100644 index 000000000..37f64a2a4 --- /dev/null +++ b/cfg/sqlite3.cfg @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + sqlite3_malloc + sqlite3_malloc64 + sqlite3_free + + + + sqlite3_str_new + sqlite3_str_finish + + + + sqlite3_str_finish + sqlite3_free + + + + + sqlite3_open + sqlite3_open16 + sqlite3_open_v2 + sqlite3_close + sqlite3_close_v2 + + + + + + + false + + + + + + + + + + + false + + + + + + + + + + false + + + + + + + + + false + + + + + + + + + false + + + + + 1: + + + + + false + + + + + 1: + + + + + false + + + + + + + + + + false + + + + + + + + + + + + diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index 9dfa5f810..7e00a00cf 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -151,6 +151,33 @@ else fi ${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=boost ${DIR}boost.cpp +# sqlite3.c +set +e +pkg-config --version +PKGCONFIG_RETURNCODE=$? +set -e +if [ $PKGCONFIG_RETURNCODE -ne 0 ]; then + echo "pkg-config needed to retrieve SQLite3 configuration is not available, skipping syntax check." +else + set +e + SQLITE3CONFIG=$(pkg-config --cflags sqlite3) + SQLITE3CONFIG_RETURNCODE=$? + set -e + if [ $SQLITE3CONFIG_RETURNCODE -eq 0 ]; then + set +e + echo -e "#include " | ${CC} ${CC_OPT} ${SQLITE3CONFIG} -x c - + SQLITE3CHECK_RETURNCODE=$? + set -e + if [ $SQLITE3CHECK_RETURNCODE -ne 0 ]; then + echo "SQLite3 not completely present or not working, skipping syntax check with ${CC}." + else + echo "SQLite3 found and working, checking syntax with ${CC} now." + ${CC} ${CC_OPT} ${SQLITE3CONFIG} ${DIR}sqlite3.c + fi + fi +fi +${CPPCHECK} ${CPPCHECK_OPT} --inconclusive --library=sqlite3 ${DIR}sqlite3.c + # Check the syntax of the defines in the configuration files set +e xmlstarlet --version diff --git a/test/cfg/sqlite3.c b/test/cfg/sqlite3.c new file mode 100644 index 000000000..4a9a1856c --- /dev/null +++ b/test/cfg/sqlite3.c @@ -0,0 +1,57 @@ + +// Test library configuration for sqlite3.cfg +// +// Usage: +// $ cppcheck --check-library --library=sqlite3 --enable=information --error-exitcode=1 --inline-suppr --suppress=missingIncludeSystem test/cfg/sqlite3.c +// => +// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0 +// + +#include +#include + +void validCode() +{ + sqlite3 * db; + + int rc = sqlite3_open("/db", &db); + if (rc != SQLITE_OK) { + fprintf(stderr, "Error opening sqlite3 db: %s\n", sqlite3_errmsg(db)); + sqlite3_close(db); + } else { + sqlite3_close(db); + } + + { + char * buf = sqlite3_malloc(10); + printf("size: %ull\n", sqlite3_msize(buf)); + sqlite3_free(buf); + } +} + +void memleak_sqlite3_malloc() +{ + char * buf = sqlite3_malloc(10); + if (buf) { + buf[0] = 0; + } + // cppcheck-suppress memleak +} + +void resourceLeak_sqlite3_open() +{ + sqlite3 * db; + + sqlite3_open("/db", &db); + // TODO: cppcheck-suppress resourceLeak +} + +void ignoredReturnValue(char * buf) +{ + // cppcheck-suppress leakReturnValNotUsed + sqlite3_malloc(10); + // cppcheck-suppress leakReturnValNotUsed + sqlite3_malloc64(5); + // cppcheck-suppress ignoredReturnValue + sqlite3_msize(buf); +} diff --git a/tools/donate-cpu.py b/tools/donate-cpu.py index b1cf27424..f879b0ed4 100644 --- a/tools/donate-cpu.py +++ b/tools/donate-cpu.py @@ -245,6 +245,7 @@ def scanPackage(workPath, cppcheckPath, jobs, fast): 'python': [''], 'qt': ['', '', '', '', ''], + #'sqlite3': [''], <- Enable after release of 1.88 'tinyxml2': [''],