Bug Summary

File:daq/rfarm/manager/src/RFConf.cc
Warning:line 123, column 29
Assigned value is uninitialized

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-unknown-linux-gnu -O3 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name RFConf.cc -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 -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -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=/data/b2soft/buildbot/development/build -fcoverage-compilation-dir=/data/b2soft/buildbot/development/build -resource-dir /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/lib/clang/21 -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/c++ -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/c++/x86_64-redhat-linux -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/c++/backward -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/include -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/python3.12 -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/include/CLHEP -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/Geant4 -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/include/root -isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/include/belle_legacy -I include/ -D _PACKAGE_="daq" -D G4UI_USE_TCSH -D RaveDllExport= -D HAS_SQLITE -D HAS_CALLGRIND -I include -I /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/include/libxml2 -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/bin/../lib64/gcc/x86_64-redhat-linux/15.2.0/../../../../include/c++ -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/bin/../lib64/gcc/x86_64-redhat-linux/15.2.0/../../../../include/c++/x86_64-redhat-linux -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/bin/../lib64/gcc/x86_64-redhat-linux/15.2.0/../../../../include/c++/backward -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /cvmfs/belle.cern.ch/el9/externals/v02-04-00/Linux_x86_64/common/bin/../lib64/gcc/x86_64-redhat-linux/15.2.0/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-missing-braces -Wno-unused-command-line-argument -std=c++20 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /scan_build/2026-05-31-004316-385593-1 -x c++ daq/rfarm/manager/src/RFConf.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include "daq/rfarm/manager/RFConf.h"
10
11#include <cctype>
12#include <cstdlib>
13#include <cstring>
14
15using namespace std;
16using namespace Belle2;
17
18RFConf::RFConf(const char* filename)
19{
20 m_fd = fopen(filename, "r");
21 if (m_fd == NULL__null) {
22 fprintf(stderrstderr, "RFConf : config file not found %s\n", filename);
23 exit(-1);
24 }
25}
26
27RFConf::~RFConf()
28{
29 fclose(m_fd);
30}
31
32// Get Configuration
33
34char* RFConf::getconf(const char* key1, const char* key2, const char* key3)
35{
36 char buf[1024], keybuf[256];
37 char* p, *q;
38
39 struct RFConf_t top, *cur;
40 top.key = NULL__null;
41
42 // Encode key2 and key3 in the first key if exist
43 // if (! key2) { key2 = key3; key3 = 0; }
44 // if (! key1) { key1 = key2; key2 = key3; key3 = 0; }
45 if (key3)
2
Assuming 'key3' is non-null
3
Taking true branch
46 sprintf(keybuf, "%s.%s.%s", key1, key2, key3);
47 else if (key2)
48 sprintf(keybuf, "%s.%s", key1, key2);
49 else if (key1)
50 strcpy(keybuf, key1);
51 else
52 return NULL__null;
53
54 // Search for the record in the configuration file
55 rewind(m_fd);
56 if (! top.key
3.1
Field 'key' is null
) { /* the first invokation */
4
Taking true branch
57 int line = 0;
58 cur = &top;
59 while (fgets(buf, sizeof(buf), m_fd)) {
5
Loop condition is false. Execution continues on line 122
60 line++;
61 /* remove '\n' and skip too long line */
62 p = strchr(buf, '\n');
63 if (! p) {
64 fprintf(stderrstderr, "RFConf : line %d too long\n", line);
65 while (fgets(buf, sizeof(buf), m_fd) && !strchr(buf, '\n'))
66 ;
67 continue;
68 }
69 *p = 0;
70 // printf ( "buf = %s\n", buf );
71
72 /* sorry for this very tricky code... */
73 char* keyp = nullptr;
74 char* delp = nullptr;
75 char* valp = nullptr;
76 for (p = buf; *p && *p != '#'; p++) {
77 if (! keyp) {
78 if (! isspace(*p)) keyp = p;
79 } else if (! delp) {
80 if (isspace(*p)) {
81 if (!isspace(*(p + 1)) && *(p + 1) != ':') {
82 fprintf(stderrstderr, "RFConf : invalid key at line %d\n", line);
83 break;
84 }
85 *p = 0;
86 } else if (*p == ':') {
87 *(delp = p) = 0;
88 }
89 } else if (! valp) {
90 if (! isspace(*p)) {
91 valp = q = p;
92 q++;
93 }
94 } else if (! isspace(*p)) {
95 *q++ = *p;
96 } else if (! isspace(*(p + 1))) {
97 *q++ = ' ';
98 }
99 }
100 if (valp) {
101 for (*q-- = 0; isspace(*q); *q-- = 0)
102 ;
103 }
104 if (delp) {
105 cur->next = (RFConf_t*)malloc(sizeof(*cur));
106 cur = cur->next;
107 cur->next = 0;
108 cur->key = (char*)malloc(strlen(keyp) + 1);
109 strcpy(cur->key, keyp);
110 if (valp) {
111 cur->val = (char*)malloc(strlen(valp) + 1);
112 strcpy(cur->val, valp);
113 } else {
114 cur->val = 0;
115 }
116 }
117 }
118 } else if (! top.val) { /* the first invokation must have failed */
119 return NULL__null;
120 }
121
122 int nitem = 0;
123 for (cur = &top; cur; cur = cur->next) {
6
Loop condition is true. Entering loop body
9
Assigned value is uninitialized
124 if (cur->key
6.1
Field 'key' is equal to NULL
== NULL__null) continue;
7
Taking true branch
8
Execution continues on line 123
125 if (strcmp(cur->key, keybuf) == 0) return cur->val;
126 nitem++;
127 }
128 printf("RFConf: Key %s not found\n", keybuf);
129 printf("nitem = %d, keybuf = %s\n", nitem, keybuf);
130 return NULL__null;
131}
132
133int RFConf::getconfi(const char* key1, const char* key2, const char* key3)
134{
135 return atoi(getconf(key1, key2, key3));
1
Calling 'RFConf::getconf'
136}
137
138