Bug Summary

File:var/lib/jenkins/workspace/firefox-scan-build/tools/profiler/core/VTuneProfiler.cpp
Warning:line 23, column 15
Value stored to 'testEvent' during its initialization is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Unified_cpp_tools_profiler1.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/tools/profiler -fcoverage-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/tools/profiler -resource-dir /usr/lib/llvm-18/lib/clang/18 -include /var/lib/jenkins/workspace/firefox-scan-build/config/gcc_hidden.h -include /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D MOZ_REPLACE_MALLOC_PREFIX=profiler -D MOZ_VTUNE_INSTRUMENTATION -D MOZ_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /var/lib/jenkins/workspace/firefox-scan-build/tools/profiler -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/tools/profiler -I /var/lib/jenkins/workspace/firefox-scan-build/caps -I /var/lib/jenkins/workspace/firefox-scan-build/docshell/base -I /var/lib/jenkins/workspace/firefox-scan-build/ipc/chromium/src -I /var/lib/jenkins/workspace/firefox-scan-build/mozglue/linker -I /var/lib/jenkins/workspace/firefox-scan-build/netwerk/base -I /var/lib/jenkins/workspace/firefox-scan-build/netwerk/protocol/http -I /var/lib/jenkins/workspace/firefox-scan-build/toolkit/components/jsoncpp/include -I /var/lib/jenkins/workspace/firefox-scan-build/toolkit/crashreporter/google-breakpad/src -I /var/lib/jenkins/workspace/firefox-scan-build/tools/profiler/core -I /var/lib/jenkins/workspace/firefox-scan-build/tools/profiler/gecko -I /var/lib/jenkins/workspace/firefox-scan-build/xpcom/base -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /var/lib/jenkins/workspace/firefox-scan-build/ipc/chromium/src -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-deprecated-this-capture -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -Wno-error=stack-protector -Wno-ignored-qualifiers -fdeprecated-macro -ferror-limit 19 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-aligned-allocation -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2024-07-27-022226-2793976-1 -x c++ Unified_cpp_tools_profiler1.cpp
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* vim: set ts=8 sts=2 et sw=2 tw=80: */
3/* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7#ifdef XP_WIN
8# undef UNICODE
9# undef _UNICODE
10#endif
11
12#include "VTuneProfiler.h"
13#include "mozilla/Bootstrap.h"
14#include <memory>
15
16VTuneProfiler* VTuneProfiler::mInstance = nullptr;
17
18void VTuneProfiler::Initialize() {
19 // This is just a 'dirty trick' to find out if the ittnotify DLL was found.
20 // If it wasn't this function always returns 0, otherwise it returns
21 // incrementing numbers, if the library was found this wastes 2 events but
22 // that should be okay.
23 __itt_event testEvent =
Value stored to 'testEvent' during its initialization is never read
24 __itt_event_create(!__itt_event_create_ptr__3_0) ? 0 : __itt_event_create_ptr__3_0("Test event", strlen("Test event"));
25 testEvent = __itt_event_create(!__itt_event_create_ptr__3_0) ? 0 : __itt_event_create_ptr__3_0("Test event 2", strlen("Test event 2"));
26
27 if (testEvent) {
28 mInstance = new VTuneProfiler();
29 }
30}
31
32void VTuneProfiler::Shutdown() {}
33
34void VTuneProfiler::TraceInternal(const char* aName, TracingKind aKind) {
35 std::string str(aName);
36
37 auto iter = mStrings.find(str);
38
39 __itt_event event;
40 if (iter != mStrings.end()) {
41 event = iter->second;
42 } else {
43 event = __itt_event_create(!__itt_event_create_ptr__3_0) ? 0 : __itt_event_create_ptr__3_0(aName, str.length());
44 mStrings.insert({str, event});
45 }
46
47 if (aKind == TRACING_INTERVAL_START || aKind == TRACING_EVENT) {
48 // VTune will consider starts not matched with an end to be single point in
49 // time events.
50 __itt_event_start(!__itt_event_start_ptr__3_0) ? 0 : __itt_event_start_ptr__3_0(event);
51 } else {
52 __itt_event_end(!__itt_event_end_ptr__3_0) ? 0 : __itt_event_end_ptr__3_0(event);
53 }
54}
55
56void VTuneProfiler::RegisterThreadInternal(const char* aName) {
57 std::string str(aName);
58
59 if (!str.compare("GeckoMain")) {
60 // Process main thread.
61 switch (XRE_GetProcessType()) {
62 case GeckoProcessType::GeckoProcessType_Default:
63 __itt_thread_set_name(!__itt_thread_set_name_ptr__3_0) ? (void)0 : __itt_thread_set_name_ptr__3_0("Main Process");
64 break;
65 case GeckoProcessType::GeckoProcessType_Content:
66 __itt_thread_set_name(!__itt_thread_set_name_ptr__3_0) ? (void)0 : __itt_thread_set_name_ptr__3_0("Content Process");
67 break;
68 case GeckoProcessType::GeckoProcessType_GMPlugin:
69 __itt_thread_set_name(!__itt_thread_set_name_ptr__3_0) ? (void)0 : __itt_thread_set_name_ptr__3_0("Plugin Process");
70 break;
71 case GeckoProcessType::GeckoProcessType_GPU:
72 __itt_thread_set_name(!__itt_thread_set_name_ptr__3_0) ? (void)0 : __itt_thread_set_name_ptr__3_0("GPU Process");
73 break;
74 default:
75 __itt_thread_set_name(!__itt_thread_set_name_ptr__3_0) ? (void)0 : __itt_thread_set_name_ptr__3_0("Unknown Process");
76 }
77 return;
78 }
79 __itt_thread_set_name(!__itt_thread_set_name_ptr__3_0) ? (void)0 : __itt_thread_set_name_ptr__3_0(aName);
80}