Bug Summary

File:root/firefox-clang/obj-x86_64-pc-linux-gnu/config/external/nspr/pr/./../../../../../nsprpub/pr/src/md/unix/uxrng.c
Warning:line 112, column 9
Value stored to 'size' 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_c_external_nspr_pr1.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -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/config/external/nspr/pr -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/config/external/nspr/pr -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/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D DEBUG=1 -D _NSPR_BUILD_ -D LINUX -D HAVE_FCNTL_FILE_LOCKING -D HAVE_POINTER_LOCALTIME_R -D _GNU_SOURCE -D _PR_PTHREADS -I /root/firefox-clang/config/external/nspr/pr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/config/external/nspr/pr -I /root/firefox-clang/config/external/nspr -I /root/firefox-clang/nsprpub/pr/include -I /root/firefox-clang/nsprpub/pr/include/private -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/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=tautological-type-limit-compare -Wno-range-loop-analysis -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-unknown-warning-option -Wno-character-conversion -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -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_c_external_nspr_pr1.c
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
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5#include "primpl.h"
6
7#include <string.h>
8#include <unistd.h>
9#include <errno(*__errno_location ()).h>
10#include <sys/time.h>
11
12#if defined(SOLARIS)
13
14static size_t
15GetHighResClock(void* buf, size_t maxbytes)
16{
17 hrtime_t t;
18 t = gethrtime();
19 if (t) {
20 return _pr_CopyLowBits(buf, maxbytes, &t, sizeof(t));
21 }
22 return 0;
23}
24
25#elif defined(AIX)
26
27static size_t
28GetHighResClock(void* buf, size_t maxbytes)
29{
30 return 0;
31}
32
33#elif (defined(LINUX1) || defined(FREEBSD) || defined(__FreeBSD_kernel__) || \
34 defined(NETBSD) || defined(__NetBSD_kernel__) || defined(OPENBSD) || \
35 defined(__GNU__))
36#include <sys/types.h>
37#include <sys/stat.h>
38#include <fcntl.h>
39
40static int fdDevURandom;
41static PRCallOnceType coOpenDevURandom;
42
43static PRStatus
44OpenDevURandom(void)
45{
46 fdDevURandom = open("/dev/urandom", O_RDONLY00);
47 return ((-1 == fdDevURandom) ? PR_FAILURE : PR_SUCCESS);
48} /* end OpenDevURandom() */
49
50static size_t
51GetDevURandom(void* buf, size_t size)
52{
53 int bytesIn;
54 int rc;
55
56 rc = PR_CallOnce(&coOpenDevURandom, OpenDevURandom);
57 if (PR_FAILURE == rc) {
58 _PR_MD_MAP_OPEN_ERROR_MD_unix_map_open_error(errno(*__errno_location ()));
59 return (0);
60 }
61
62 bytesIn = read(fdDevURandom, buf, size);
63 if (-1 == bytesIn) {
64 _PR_MD_MAP_READ_ERROR_MD_unix_map_read_error(errno(*__errno_location ()));
65 return (0);
66 }
67
68 return (bytesIn);
69} /* end GetDevURandom() */
70
71static size_t
72GetHighResClock(void* buf, size_t maxbytes)
73{
74 return (GetDevURandom(buf, maxbytes));
75}
76
77#elif defined(NTO) || defined(QNX) || defined(DARWIN) || defined(RISCOS)
78#include <sys/times.h>
79
80static size_t
81GetHighResClock(void* buf, size_t maxbytes)
82{
83 int ticks;
84 struct tms buffer;
85
86 ticks = times(&buffer);
87 return _pr_CopyLowBits(buf, maxbytes, &ticks, sizeof(ticks));
88}
89#else
90#error ! Platform undefined
91#endif /* defined(SOLARIS) */
92
93extern PRSize
94_PR_MD_GetRandomNoise(void* buf, PRSize size)
95{
96 struct timeval tv;
97 int n = 0;
98 int s;
99
100 n += GetHighResClock(buf, size);
101 size -= n;
102
103 GETTIMEOFDAY(&tv)gettimeofday((&tv), ((void*)0));
104
105 if (size > 0) {
106 s = _pr_CopyLowBits((char*)buf + n, size, &tv.tv_usec, sizeof(tv.tv_usec));
107 size -= s;
108 n += s;
109 }
110 if (size > 0) {
111 s = _pr_CopyLowBits((char*)buf + n, size, &tv.tv_sec, sizeof(tv.tv_usec));
112 size -= s;
Value stored to 'size' is never read
113 n += s;
114 }
115
116 return n;
117} /* end _PR_MD_GetRandomNoise() */