summaryrefslogtreecommitdiff
path: root/gjs/profiler.cpp
diff options
context:
space:
mode:
authorPhilip Chimento <philip@endlessm.com>2018-01-18 16:46:27 -0800
committerPhilip Chimento <philip@endlessm.com>2018-01-24 14:21:13 -0800
commit12b5a8f93cf398f57075035b894c4c970aa5ec4d (patch)
treeadce8f4d3c8797cf6b5b0b87c50fc0dd544c6cf0 /gjs/profiler.cpp
parenta824659f546c5ee97ccb207abeb9e710194fb30c (diff)
downloadgjs-12b5a8f93cf398f57075035b894c4c970aa5ec4d.tar.gz
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.
Diffstat (limited to 'gjs/profiler.cpp')
-rw-r--r--gjs/profiler.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/gjs/profiler.cpp b/gjs/profiler.cpp
index c199179b..1ee9220c 100644
--- a/gjs/profiler.cpp
+++ b/gjs/profiler.cpp
@@ -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++) {