Commit 12b5a8f9 authored by Philip Chimento's avatar Philip Chimento

profiler: Suppress cppcheck warning

The cppcheck program will warn about alloca() even though there's no
equivalent alternative in C++. I don't think there's necessarily a better
way to do this, so we suppress the warning and add a justification.
parent a824659f
......@@ -212,6 +212,8 @@ CPPCHECK=cppcheck
### cppcheck static code analysis
#
cppcheck:
$(CPPCHECK) --enable=warning,performance,portability,information,missingInclude --force -q $(top_srcdir) -I $(top_builddir)
$(CPPCHECK) --inline-suppr \
--enable=warning,performance,portability,information,missingInclude \
--force -q $(top_srcdir) -I $(top_builddir)
-include $(top_srcdir)/git.mk
......@@ -291,6 +291,15 @@ gjs_profiler_sigprof(int signum,
"in an unsigned short");
int64_t now = g_get_monotonic_time() * 1000L;
/* NOTE: cppcheck warns that alloca() is not recommended since it can
* easily overflow the stack; however, dynamic allocation is not an option
* here since we are in a signal handler.
* Another option would be to always allocate G_N_ELEMENTS(self->stack),
* but that is by definition at least as large of an allocation and
* therefore is more likely to overflow.
*/
// cppcheck-suppress allocaCalled
SpCaptureAddress *addrs = static_cast<SpCaptureAddress *>(alloca(sizeof *addrs * depth));
for (size_t ix = 0; ix < depth; ix++) {
......
......@@ -137,13 +137,13 @@ elif [[ $1 == "GJS_COVERAGE" ]]; then
elif [[ $1 == "CPPCHECK" ]]; then
echo
echo '-- Static code analyzer report --'
cppcheck --enable=warning,performance,portability,information,missingInclude --force -q . 2>&1 | \
cppcheck --inline-suppr --enable=warning,performance,portability,information,missingInclude --force -q . 2>&1 | \
sed -E 's/:[0-9]+]/:LINE]/' | tee /cwd/current-report.txt
echo
echo '-- Master static code analyzer report --'
git clone --depth 1 https://gitlab.gnome.org/GNOME/gjs.git tmp-upstream; cd tmp-upstream || exit 1
cppcheck --enable=warning,performance,portability,information,missingInclude --force -q . 2>&1 | \
cppcheck --inline-suppr --enable=warning,performance,portability,information,missingInclude --force -q . 2>&1 | \
sed -E 's/:[0-9]+]/:LINE]/' | tee /cwd/master-report.txt
echo
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment