Bug Summary

File:var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dom/bindings/WebIDLSerializable.cpp
Warning:line 17, column 8
Excessive padding in 'struct mozilla::dom::WebIDLSerializableEntry' (10 padding bytes, where 2 is optimal). Optimal fields order: mDeserialize, mTag, mExposedGlobals, consider reordering the fields or adding explicit padding members

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 WebIDLSerializable.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/dom/bindings -fcoverage-compilation-dir=/var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dom/bindings -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 GOOGLE_PROTOBUF_NO_RTTI -D GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER -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/dom/bindings -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dom/bindings -I /var/lib/jenkins/workspace/firefox-scan-build/obj-x86_64-pc-linux-gnu/dist/include/mozilla/dom -I /var/lib/jenkins/workspace/firefox-scan-build/dom/base -I /var/lib/jenkins/workspace/firefox-scan-build/dom/battery -I /var/lib/jenkins/workspace/firefox-scan-build/dom/canvas -I /var/lib/jenkins/workspace/firefox-scan-build/dom/geolocation -I /var/lib/jenkins/workspace/firefox-scan-build/dom/html -I /var/lib/jenkins/workspace/firefox-scan-build/dom/indexedDB -I /var/lib/jenkins/workspace/firefox-scan-build/dom/media/webaudio -I /var/lib/jenkins/workspace/firefox-scan-build/dom/media/webrtc -I /var/lib/jenkins/workspace/firefox-scan-build/dom/media/webrtc/common/time_profiling -I /var/lib/jenkins/workspace/firefox-scan-build/dom/media/webrtc/jsapi -I /var/lib/jenkins/workspace/firefox-scan-build/dom/media/webrtc/libwebrtcglue -I /var/lib/jenkins/workspace/firefox-scan-build/dom/media/webrtc/transport -I /var/lib/jenkins/workspace/firefox-scan-build/dom/media/webspeech/recognition -I /var/lib/jenkins/workspace/firefox-scan-build/dom/svg -I /var/lib/jenkins/workspace/firefox-scan-build/dom/xml -I /var/lib/jenkins/workspace/firefox-scan-build/dom/xslt/base -I /var/lib/jenkins/workspace/firefox-scan-build/dom/xslt/xpath -I /var/lib/jenkins/workspace/firefox-scan-build/dom/xul -I /var/lib/jenkins/workspace/firefox-scan-build/js/xpconnect/src -I /var/lib/jenkins/workspace/firefox-scan-build/js/xpconnect/wrappers -I /var/lib/jenkins/workspace/firefox-scan-build/layout/generic -I /var/lib/jenkins/workspace/firefox-scan-build/layout/style -I /var/lib/jenkins/workspace/firefox-scan-build/layout/xul/tree -I /var/lib/jenkins/workspace/firefox-scan-build/media/webrtc -I /var/lib/jenkins/workspace/firefox-scan-build/netwerk/base -I /var/lib/jenkins/workspace/firefox-scan-build/third_party/libwebrtc -I /var/lib/jenkins/workspace/firefox-scan-build/third_party/libwebrtc/third_party/abseil-cpp -I /var/lib/jenkins/workspace/firefox-scan-build/third_party/msgpack/include -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 -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++ WebIDLSerializable.cpp
1#include "DOMExceptionBinding.h"
2#include "DOMMatrixBinding.h"
3#include "DOMPointBinding.h"
4#include "DOMQuadBinding.h"
5#include "DOMRectBinding.h"
6#include "FileSystemDirectoryHandleBinding.h"
7#include "FileSystemFileHandleBinding.h"
8#include "FileSystemHandleBinding.h"
9#include "ImageDataBinding.h"
10#include "RTCCertificateBinding.h"
11#include "StructuredCloneTesterBinding.h"
12#include "SubtleCryptoBinding.h"
13#include "mozilla/PerfectHash.h"
14#include "mozilla/dom/WebIDLSerializable.h"
15
16namespace mozilla::dom {
17struct WebIDLSerializableEntry {
Excessive padding in 'struct mozilla::dom::WebIDLSerializableEntry' (10 padding bytes, where 2 is optimal). Optimal fields order: mDeserialize, mTag, mExposedGlobals, consider reordering the fields or adding explicit padding members
18 StructuredCloneTags mTag;
19 WebIDLDeserializer mDeserialize;
20 uint16_t mExposedGlobals;
21};
22
23static const WebIDLSerializableEntry sEntries[] = {
24 {
25 /* mTag */ SCTAG_DOM_CRYPTOKEY,
26 /* mDeserialize */ CryptoKey_Binding::Deserialize,
27 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
28 },
29 {
30 /* mTag */ SCTAG_DOM_DOMEXCEPTION,
31 /* mDeserialize */ DOMException_Binding::Deserialize,
32 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
33 },
34 {
35 /* mTag */ SCTAG_DOM_DOMMATRIX,
36 /* mDeserialize */ DOMMatrix_Binding::Deserialize,
37 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
38 },
39 {
40 /* mTag */ SCTAG_DOM_DOMMATRIXREADONLY,
41 /* mDeserialize */ DOMMatrixReadOnly_Binding::Deserialize,
42 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
43 },
44 {
45 /* mTag */ SCTAG_DOM_DOMPOINT,
46 /* mDeserialize */ DOMPoint_Binding::Deserialize,
47 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
48 },
49 {
50 /* mTag */ SCTAG_DOM_DOMPOINTREADONLY,
51 /* mDeserialize */ DOMPointReadOnly_Binding::Deserialize,
52 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
53 },
54 {
55 /* mTag */ SCTAG_DOM_DOMQUAD,
56 /* mDeserialize */ DOMQuad_Binding::Deserialize,
57 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
58 },
59 {
60 /* mTag */ SCTAG_DOM_DOMRECT,
61 /* mDeserialize */ DOMRect_Binding::Deserialize,
62 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
63 },
64 {
65 /* mTag */ SCTAG_DOM_DOMRECTREADONLY,
66 /* mDeserialize */ DOMRectReadOnly_Binding::Deserialize,
67 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
68 },
69 {
70 /* mTag */ SCTAG_DOM_FILESYSTEMDIRECTORYHANDLE,
71 /* mDeserialize */ FileSystemDirectoryHandle_Binding::Deserialize,
72 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
73 },
74 {
75 /* mTag */ SCTAG_DOM_FILESYSTEMFILEHANDLE,
76 /* mDeserialize */ FileSystemFileHandle_Binding::Deserialize,
77 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
78 },
79 {
80 /* mTag */ SCTAG_DOM_FILESYSTEMHANDLE,
81 /* mDeserialize */ FileSystemHandle_Binding::Deserialize,
82 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
83 },
84 {
85 /* mTag */ SCTAG_DOM_IMAGEDATA,
86 /* mDeserialize */ ImageData_Binding::Deserialize,
87 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
88 },
89 {
90 /* mTag */ SCTAG_DOM_RTCCERTIFICATE,
91 /* mDeserialize */ RTCCertificate_Binding::Deserialize,
92 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
93 },
94 {
95 /* mTag */ SCTAG_DOM_STRUCTUREDCLONETESTER,
96 /* mDeserialize */ StructuredCloneTester_Binding::Deserialize,
97 /* mExposedGlobals */ GlobalNames::DedicatedWorkerGlobalScope | GlobalNames::ServiceWorkerGlobalScope | GlobalNames::SharedWorkerGlobalScope | GlobalNames::Window,
98 }
99};
100
101Maybe<std::pair<uint16_t, WebIDLDeserializer>> LookupDeserializer(StructuredCloneTags aTag) {
102 for (auto& entry : sEntries) {
103 if (entry.mTag == aTag) {
104 return Some(std::pair(entry.mExposedGlobals, entry.mDeserialize));
105 }
106 }
107 return Nothing();
108}
109} // namespace mozilla::dom
110