Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/test/./../../../../toolkit/crashreporter/google-breakpad/src/processor/logging.cc
Warning:line 64, column 15
Value stored to 'severity_string' during its initialization is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Unified_cpp_crashreporter_test0.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=/root/firefox-clang/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/test -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/test -resource-dir /usr/lib/llvm-23/lib/clang/23 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -D _GLIBCXX_ASSERTIONS=1 -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D MOZ_PHC -D SHARED_LIBRARY=libtestcrasher.so -D NO_STABS_SUPPORT -D MOZ_HAS_MOZGLUE -I /root/firefox-clang/toolkit/crashreporter/test -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/toolkit/crashreporter/test -I /root/firefox-clang/toolkit/crashreporter/breakpad-client -I /root/firefox-clang/toolkit/crashreporter/google-breakpad/src -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/x86_64-linux-gnu/c++/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../include/c++/16/backward -internal-isystem /usr/lib/llvm-23/lib/clang/23/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-error=pessimizing-move -Wno-error=large-by-value-copy=128 -Wno-error=implicit-int-float-conversion -Wno-error=thread-safety-analysis -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-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-character-conversion -Wno-unused-local-typedefs -Wno-deprecated-declarations -Wno-bool-compare -Wno-unused-but-set-variable -Wno-c++11-narrowing -Wno-implicit-fallthrough -std=gnu++20 -fdeprecated-macro -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fno-sized-deallocation -fno-aligned-allocation -fdiagnostics-absolute-paths -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -mllvm -dwarf-linkage-names=Abstract -faddrsig -fdwarf2-cfi-asm -o /tmp/scan-build-2026-09-01-224014-2642839-1 -x c++ Unified_cpp_crashreporter_test0.cpp
1// Copyright (c) 2007, Google Inc.
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met:
7//
8// * Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// * Redistributions in binary form must reproduce the above
11// copyright notice, this list of conditions and the following disclaimer
12// in the documentation and/or other materials provided with the
13// distribution.
14// * Neither the name of Google Inc. nor the names of its
15// contributors may be used to endorse or promote products derived from
16// this software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30// logging.cc: Breakpad logging
31//
32// See logging.h for documentation.
33//
34// Author: Mark Mentovai
35
36#include <assert.h>
37#include <errno(*__errno_location ()).h>
38#include <string.h>
39#include <time.h>
40
41#include <string>
42
43#include "common/stdio_wrapper.h"
44#include "common/using_std_string.h"
45#include "processor/logging.h"
46#include "processor/pathname_stripper.h"
47
48namespace google_breakpad {
49
50LogStream::LogStream(std::ostream &stream, Severity severity,
51 const char *file, int line)
52 : stream_(stream) {
53 time_t clock;
54 time(&clock);
55 struct tm tm_struct;
56#ifdef _WIN32
57 localtime_s(&tm_struct, &clock);
58#else
59 localtime_r(&clock, &tm_struct);
60#endif
61 char time_string[20];
62 strftime(time_string, sizeof(time_string), "%Y-%m-%d %H:%M:%S", &tm_struct);
63
64 const char *severity_string = "UNKNOWN_SEVERITY";
Value stored to 'severity_string' during its initialization is never read
65 switch (severity) {
66 case SEVERITY_INFO:
67 severity_string = "INFO";
68 break;
69 case SEVERITY_ERROR:
70 severity_string = "ERROR";
71 break;
72 case SEVERITY_CRITICAL:
73 severity_string = "CRITICAL";
74 break;
75 }
76
77 stream_ << time_string << ": " << PathnameStripper::File(file) << ":" <<
78 line << ": " << severity_string << ": ";
79}
80
81LogStream::~LogStream() {
82 stream_ << std::endl;
83}
84
85string HexString(uint32_t number) {
86 char buffer[11];
87 snprintf(buffer, sizeof(buffer), "0x%x", number);
88 return string(buffer);
89}
90
91string HexString(uint64_t number) {
92 char buffer[19];
93 snprintf(buffer, sizeof(buffer), "0x%" PRIx64"l" "x", number);
94 return string(buffer);
95}
96
97string HexString(int number) {
98 char buffer[19];
99 snprintf(buffer, sizeof(buffer), "0x%x", number);
100 return string(buffer);
101}
102
103int ErrnoString(string *error_string) {
104 assert(error_string)(static_cast <bool> (error_string) ? void (0) : __assert_fail
("error_string", __builtin_FILE (), __builtin_LINE (), __extension__
__PRETTY_FUNCTION__))
;
105
106 // strerror isn't necessarily thread-safe. strerror_r would be preferrable,
107 // but GNU libc uses a nonstandard strerror_r by default, which returns a
108 // char* (rather than an int success indicator) and doesn't necessarily
109 // use the supplied buffer.
110 error_string->assign(strerror(errno(*__errno_location ())));
111 return errno(*__errno_location ());
112}
113
114} // namespace google_breakpad