Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/toolkit/components/antitracking/./../../../../toolkit/components/antitracking/URLDecorationStripper.cpp
Warning:line 25, column 12
Value stored to 'rv' 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_antitracking0.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/components/antitracking -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/toolkit/components/antitracking -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_HAS_MOZGLUE -D MOZILLA_INTERNAL_API -D IMPL_LIBXUL -D MOZ_SUPPORT_LEAKCHECKING -D STATIC_EXPORTABLE_JS_API -I /root/firefox-clang/toolkit/components/antitracking -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/toolkit/components/antitracking -I /root/firefox-clang/netwerk/base -I /root/firefox-clang/netwerk/protocol/http -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/ipc/ipdl/_ipdlheaders -I /root/firefox-clang/ipc/chromium/src -I /root/firefox-clang/third_party/abseil-cpp -I /root/firefox-clang/toolkit/components/telemetry -I /root/firefox-clang/xpcom/base -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 -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_antitracking0.cpp
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5#include "URLDecorationStripper.h"
6
7#include "mozilla/Components.h"
8#include "mozilla/Preferences.h"
9#include "nsCharSeparatedTokenizer.h"
10#include "nsIEffectiveTLDService.h"
11#include "nsIURI.h"
12#include "nsIURIMutator.h"
13#include "nsURLHelper.h"
14
15namespace {
16static const char* kPrefName =
17 "privacy.restrict3rdpartystorage.url_decorations";
18} // namespace
19
20namespace mozilla {
21
22nsresult URLDecorationStripper::StripTrackingIdentifiers(nsIURI* aURI,
23 nsACString& aOutSpec) {
24 nsAutoCString tokenList;
25 nsresult rv = Preferences::GetCString(kPrefName, tokenList);
Value stored to 'rv' during its initialization is never read
26 ToLowerCase(tokenList);
27
28 nsAutoCString path;
29 rv = aURI->GetPathQueryRef(path);
30 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../../toolkit/components/antitracking/URLDecorationStripper.cpp"
, 30); return rv; } } while (false)
;
31 ToLowerCase(path);
32
33 int32_t queryBegins = path.FindChar('?');
34 // Only positive values are valid since the path must begin with a '/'.
35 if (queryBegins > 0) {
36 for (const nsACString& token : tokenList.Split(' ')) {
37 if (token.IsEmpty()) {
38 continue;
39 }
40
41 nsAutoCString value;
42 if (URLParams::Extract(Substring(path, queryBegins + 1), token, value) &&
43 !value.IsVoid()) {
44 // Tracking identifier found in the URL!
45 return StripToRegistrableDomain(aURI, aOutSpec);
46 }
47 }
48 }
49
50 return aURI->GetSpec(aOutSpec);
51}
52
53nsresult URLDecorationStripper::StripToRegistrableDomain(nsIURI* aURI,
54 nsACString& aOutSpec) {
55 NS_MutateURI mutator(aURI);
56 mutator.SetPathQueryRef(""_ns).SetUserPass(""_ns);
57
58 nsCOMPtr<nsIEffectiveTLDService> etldService =
59 mozilla::components::EffectiveTLD::Service();
60 NS_ENSURE_TRUE(etldService, NS_ERROR_FAILURE)do { if ((__builtin_expect(!!(!(etldService)), 0))) { NS_DebugBreak
(NS_DEBUG_WARNING, "NS_ENSURE_TRUE(" "etldService" ") failed"
, nullptr, "./../../../../toolkit/components/antitracking/URLDecorationStripper.cpp"
, 60); return NS_ERROR_FAILURE; } } while (false)
;
61 nsAutoCString baseDomain;
62 nsresult rv = etldService->GetBaseDomain(aURI, 0, baseDomain);
63 if (NS_SUCCEEDED(rv)((bool)(__builtin_expect(!!(!NS_FAILED_impl(rv)), 1)))) {
64 mutator.SetHost(baseDomain);
65 } else {
66 // If this is an IP address or something like "localhost", ignore the error.
67 if (rv != NS_ERROR_HOST_IS_IP_ADDRESS &&
68 rv != NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS) {
69 return rv;
70 }
71 }
72
73 nsCOMPtr<nsIURI> uri;
74 rv = mutator.Finalize(uri);
75 NS_ENSURE_SUCCESS(rv, rv)do { nsresult __rv = rv; if (((bool)(__builtin_expect(!!(NS_FAILED_impl
(__rv)), 0)))) { const char* name = mozilla::GetStaticErrorName
(__rv); mozilla::SmprintfPointer msg = mozilla::Smprintf( "NS_ENSURE_SUCCESS(%s, %s) failed with "
"result 0x%" "X" "%s%s%s", "rv", "rv", static_cast<uint32_t
>(__rv), name ? " (" : "", name ? name : "", name ? ")" : ""
); NS_DebugBreak(NS_DEBUG_WARNING, msg.get(), nullptr, "./../../../../toolkit/components/antitracking/URLDecorationStripper.cpp"
, 75); return rv; } } while (false)
;
76 return uri->GetSpec(aOutSpec);
77}
78
79} // namespace mozilla