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 RFRoiSender.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/RFRoiSender.cc
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | #include <daq/rfarm/manager/RFRoiSender.h> |
| 10 | |
| 11 | #include <sys/stat.h> |
| 12 | #include <sys/types.h> |
| 13 | #include <sys/wait.h> |
| 14 | |
| 15 | #include <unistd.h> |
| 16 | |
| 17 | #include <csignal> |
| 18 | #include <cstring> |
| 19 | #include <string> |
| 20 | |
| 21 | using namespace Belle2; |
| 22 | using namespace std; |
| 23 | |
| 24 | RFRoiSender::RFRoiSender(string conffile) |
| 25 | { |
| 26 | |
| 27 | m_conf = new RFConf(conffile.c_str()); |
| 28 | char* nodename = m_conf->getconf("roisender", "nodename"); |
| 29 | printf("RoiSender : nodename = %s\n", nodename); |
| 30 | fflush(stdout); |
| 31 | |
| 32 | |
| 33 | |
| 34 | |
| 35 | string execdir = string(m_conf->getconf("system", "execdir_base")) + "/roisender"; |
| 36 | |
| 37 | mkdir(execdir.c_str(), 0755); |
| 38 | chdir(execdir.c_str()); |
| 39 | |
| 40 | |
| 41 | string shmname = string(m_conf->getconf("system", "unitname")) + ":" + |
| 42 | string(nodename); |
| 43 | m_shm = new RFSharedMem((char*)shmname.c_str()); |
| 44 | printf("RoiSender : shmname = %s\n", shmname.c_str()); |
| 45 | |
| 46 | |
| 47 | m_proc = new RFProcessManager(nodename); |
| 48 | |
| 49 | |
| 50 | m_log = new RFLogManager(nodename, m_conf->getconf("system", "lognode")); |
| 51 | |
| 52 | |
| 53 | m_flow = new RFFlowStat((char*)shmname.c_str()); |
| 54 | |
| 55 | |
| 56 | m_pid_sender = 0; |
| 57 | m_pid_merger = 0; |
| 58 | |
| 59 | } |
| 60 | |
| 61 | RFRoiSender::~RFRoiSender() |
| 62 | { |
| 63 | delete m_log; |
| 64 | delete m_proc; |
| 65 | delete m_conf; |
| 66 | } |
| 67 | |
| 68 | |
| 69 | |
| 70 | int RFRoiSender::Configure(NSMmsg* nsmm, NSMcontext* ) |
| 71 | { |
| 72 | |
| 73 | char* roisw = m_conf->getconf("roisender", "enabled"); |
| 74 | if (nsmm->len > 0) { |
| 4 | | Access to field 'len' results in a dereference of a null pointer (loaded from variable 'nsmm') |
|
| 75 | roisw = (char*) nsmm->datap; |
| 76 | printf("Configure: roisender enable flag is overridden : %s\n", roisw); |
| 77 | } |
| 78 | if (strstr(roisw, "yes") == 0) return 0; |
| 79 | |
| 80 | |
| 81 | char* merger = m_conf->getconf("roisender", "merger"); |
| 82 | char* mergerport = m_conf->getconf("roisender", "mergerport"); |
| 83 | char* mergerhost = m_conf->getconf("roisender", "mergerhost"); |
| 84 | char* onsenhost = m_conf->getconf("roisender", "onsenhost"); |
| 85 | char* onsenport = m_conf->getconf("roisender", "onsenport"); |
| 86 | |
| 87 | string shmname = string(m_conf->getconf("system", "unitname")) + ":" + |
| 88 | string(m_conf->getconf("roisender", "nodename")); |
| 89 | |
| 90 | |
| 91 | if (strstr(merger, "none") == 0) { |
| 92 | char idbuf[3]; |
| 93 | sprintf(idbuf, "%2.2d", RF_ROI_ID); |
| 94 | m_pid_merger = m_proc->Execute(merger, (char*)shmname.c_str(), idbuf, onsenhost, onsenport, mergerport); |
| 95 | sleep(2); |
| 96 | } |
| 97 | |
| 98 | |
| 99 | char* sender = m_conf->getconf("roisender", "sender"); |
| 100 | int nqueue = m_conf->getconfi("roisender", "nqueues"); |
| 101 | |
| 102 | |
| 103 | char* arglist[20]; |
| 104 | arglist[0] = mergerhost; |
| 105 | arglist[1] = mergerport; |
| 106 | int nargs = 2; |
| 107 | char roiqs[10][256]; |
| 108 | for (int i = 0; i < nqueue; i++) { |
| 109 | sprintf(roiqs[i], "/roi%d", i); |
| 110 | arglist[i + 2] = roiqs[i]; |
| 111 | nargs++; |
| 112 | } |
| 113 | |
| 114 | m_pid_sender = m_proc->Execute(sender, nargs, arglist); |
| 115 | |
| 116 | return 0; |
| 117 | |
| 118 | } |
| 119 | |
| 120 | int RFRoiSender::UnConfigure(NSMmsg*, NSMcontext*) |
| 121 | { |
| 122 | |
| 123 | int statx; |
| 124 | if (m_pid_sender != 0) { |
| 125 | kill(m_pid_sender, SIGINT); |
| 126 | waitpid(m_pid_sender, &statx, 0); |
| 127 | m_pid_sender = 0; |
| 128 | } |
| 129 | if (m_pid_merger != 0) { |
| 130 | kill(m_pid_merger, SIGINT); |
| 131 | waitpid(m_pid_merger, &statx, 0); |
| 132 | m_pid_merger = 0; |
| 133 | } |
| 134 | printf("UnConfigure : done\n"); |
| 135 | return 0; |
| 136 | } |
| 137 | |
| 138 | int RFRoiSender::Start(NSMmsg*, NSMcontext*) |
| 139 | { |
| 140 | return 0; |
| 141 | } |
| 142 | |
| 143 | int RFRoiSender::Stop(NSMmsg*, NSMcontext*) |
| 144 | { |
| 145 | return 0; |
| 146 | } |
| 147 | |
| 148 | |
| 149 | int RFRoiSender::Restart(NSMmsg*, NSMcontext*) |
| 150 | { |
| 151 | printf("RFRoiSender : Restarted!!!!!\n"); |
| 152 | |
| 153 | |
| 154 | |
| 155 | |
| 156 | |
| 157 | |
| 158 | |
| 159 | NSMmsg* nsmmsg = NULL; |
| 1 | 'nsmmsg' initialized to a null pointer value | |
|
| 160 | NSMcontext* nsmcontext = NULL; |
| 161 | RFRoiSender::UnConfigure(nsmmsg, nsmcontext); |
| 162 | sleep(2); |
| 163 | RFRoiSender::Configure(nsmmsg, nsmcontext); |
| 2 | | Passing null pointer value via 1st parameter 'nsmm' | |
|
| 3 | | Calling 'RFRoiSender::Configure' | |
|
| 164 | return 0; |
| 165 | } |
| 166 | |
| 167 | |
| 168 | |
| 169 | void RFRoiSender::server() |
| 170 | { |
| 171 | while (true) { |
| 172 | pid_t pid = m_proc->CheckProcess(); |
| 173 | if (pid > 0) { |
| 174 | printf("RFRoiSender : process dead. pid=%d\n", pid); |
| 175 | if (pid == m_pid_sender) { |
| 176 | m_log->Fatal("RFRoiSender : hltout2merger dead. pid = %d\n", pid); |
| 177 | |
| 178 | } else if (pid == m_pid_merger) { |
| 179 | m_log->Fatal("RFRoiSender : merger2merge dead. pid = %d\n", pid); |
| 180 | |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | int st = m_proc->CheckOutput(); |
| 185 | if (st < 0) { |
| 186 | perror("RFRoiSender::server"); |
| 187 | |
| 188 | } else if (st > 0) { |
| 189 | m_log->ProcessLog(m_proc->GetFd()); |
| 190 | } |
| 191 | m_flow->fillNodeInfo(RF_ROI_ID, GetNodeInfo(), true); |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | void RFRoiSender::cleanup() |
| 196 | { |
| 197 | printf("RFRoiSender : cleaning up\n"); |
| 198 | UnConfigure(NULL, NULL); |
| 199 | printf("RFRoiSender: Done. Exitting\n"); |
| 200 | exit(-1); |
| 201 | } |