Bug Summary

File:pr/Linux4.19_x86_64_gcc_glibc_PTH_64_DBG.OBJ/pr/tests/../../../pr/tests/randseed.c
Warning:line 75, column 21
Value stored to 'i' 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 randseed.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 -fmath-errno -ffp-contract=on -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/nss-scan-build/nspr/Linux4.19_x86_64_gcc_glibc_PTH_64_DBG.OBJ/pr/tests -fcoverage-compilation-dir=/var/lib/jenkins/workspace/nss-scan-build/nspr/Linux4.19_x86_64_gcc_glibc_PTH_64_DBG.OBJ/pr/tests -resource-dir /usr/lib/llvm-18/lib/clang/18 -U NDEBUG -D DEBUG_jenkins -D PACKAGE_NAME="" -D PACKAGE_TARNAME="" -D PACKAGE_VERSION="" -D PACKAGE_STRING="" -D PACKAGE_BUGREPORT="" -D PACKAGE_URL="" -D DEBUG=1 -D HAVE_VISIBILITY_HIDDEN_ATTRIBUTE=1 -D HAVE_VISIBILITY_PRAGMA=1 -D XP_UNIX=1 -D _GNU_SOURCE=1 -D HAVE_FCNTL_FILE_LOCKING=1 -D HAVE_POINTER_LOCALTIME_R=1 -D LINUX=1 -D HAVE_DLADDR=1 -D HAVE_GETTID=1 -D HAVE_LCHOWN=1 -D HAVE_SETPRIORITY=1 -D HAVE_STRERROR=1 -D HAVE_SYSCALL=1 -D HAVE_SECURE_GETENV=1 -D _REENTRANT=1 -D FORCE_PR_LOG -D _PR_PTHREADS -U HAVE_CVAR_BUILT_ON_SEM -I /var/lib/jenkins/workspace/nss-scan-build/nss/../dist/Linux4.19_x86_64_gcc_glibc_PTH_64_DBG.OBJ/include -I ../../../pr/include -I ../../../pr/include/private -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 -ferror-limit 19 -fvisibility=hidden -fgnuc-version=4.2.1 -fno-inline -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2024-05-18-082241-28900-1 -x c ../../../pr/tests/randseed.c
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2/* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5
6/*
7** File: rngseed.c
8** Description:
9** Test NSPR's Random Number Seed generator
10**
11** Initial test: Just make sure it outputs some data.
12**
13** ... more? ... check some iterations to ensure it is random (no dupes)
14** ... more? ... histogram distribution of random numbers
15*/
16
17#include "plgetopt.h"
18#include "nspr.h"
19#include "prrng.h"
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23
24/*
25** Test harness infrastructure
26*/
27PRLogModuleInfo *lm;
28PRLogModuleLevel msgLevel = PR_LOG_NONE;
29PRIntn debug = 0;
30PRUint32 failed_already = 0;
31/* end Test harness infrastructure */
32
33PRIntn optRandCount = 30;
34char buf[40];
35PRSize bufSize = sizeof(buf);
36PRSize rSize;
37PRIntn i;
38
39/*
40** Emit help text for this test
41*/
42static void Help( void )
43{
44 printf("Template: Help(): display your help message(s) here");
45 exit(1);
46} /* end Help() */
47
48static void PrintRand( void *buf, PRIntn size )
49{
50 PRUint32 *rp = buf;
51 PRIntn i;
52
53 printf("%4.4d--\n", size );
54 while (size > 0 ) {
55 switch( size ) {
56 case 1 :
57 printf("%2.2X\n", *(rp++) );
58 size -= 4;
59 break;
60 case 2 :
61 printf("%4.4X\n", *(rp++) );
62 size -= 4;
63 break;
64 case 3 :
65 printf("%6.6X\n", *(rp++) );
66 size -= 4;
67 break;
68 default:
69 while ( size >= 4) {
70 PRIntn i = 3;
71 do {
72 printf("%8.8X ", *(rp++) );
73 size -= 4;
74 } while( i-- );
75 i = 3;
Value stored to 'i' is never read
76 printf("\n");
77 }
78 break;
79 } /* end switch() */
80 } /* end while() */
81} /* end PrintRand() */
82
83
84int main(int argc, char **argv)
85{
86 {
87 /*
88 ** Get command line options
89 */
90 PLOptStatus os;
91 PLOptState *opt = PL_CreateOptState(argc, argv, "hdv");
92
93 while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
94 {
95 if (PL_OPT_BAD == os) {
96 continue;
97 }
98 switch (opt->option)
99 {
100 case 'd': /* debug */
101 debug = 1;
102 msgLevel = PR_LOG_ERROR;
103 break;
104 case 'v': /* verbose mode */
105 msgLevel = PR_LOG_DEBUG;
106 break;
107 case 'h': /* help message */
108 Help();
109 break;
110 default:
111 break;
112 }
113 }
114 PL_DestroyOptState(opt);
115 }
116
117 lm = PR_NewLogModule("Test"); /* Initialize logging */
118 for ( i = 0; i < optRandCount ; i++ ) {
119 memset( buf, 0, bufSize );
120 rSize = PR_GetRandomNoise( buf, bufSize );
121 if (!rSize) {
122 fprintf(stderrstderr, "Not implemented\n" );
123 failed_already = PR_TRUE1;
124 break;
125 }
126 if (debug) {
127 PrintRand( buf, rSize );
128 }
129 }
130
131 if (debug) {
132 printf("%s\n", (failed_already)? "FAIL" : "PASS");
133 }
134 return( (failed_already == PR_TRUE1 )? 1 : 0 );
135} /* main() */
136/* end template.c */
137