Bug Summary

File:daq/rfarm/event/modules/src/Rbuf2DsModule.cc
Warning:line 85, column 11
Although the value stored to 'size' is used in the enclosing expression, the value is never actually read from 'size'

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 Rbuf2DsModule.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/event/modules/src/Rbuf2DsModule.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/event/modules/Rbuf2DsModule.h>
10#include <TSystem.h>
11#include <stdlib.h>
12#include <signal.h>
13
14#include "framework/core/Environment.h"
15
16//extern int basf2SignalReceived;
17
18
19namespace {
20// Signal Handler
21 static int signalled = 0;
22 static void signalHandler(int sig)
23 {
24 signalled = sig;
25 printf("Rbuf2Ds : Signal received\n");
26 }
27}
28
29using namespace std;
30using namespace Belle2;
31
32
33//-----------------------------------------------------------------
34// Register the Module
35//-----------------------------------------------------------------
36REG_MODULE(Rbuf2Ds)namespace { struct ModuleProxyRbuf2Ds: public ModuleProxyBase
{ ModuleProxyRbuf2Ds(): ModuleProxyBase("Rbuf2Ds", "" "daq")
{} virtual ::Belle2::Module* createInstance() const override
final { return new Rbuf2DsModule(); } } proxyRbuf2DsModule; }
;
37
38//-----------------------------------------------------------------
39// Implementation
40//-----------------------------------------------------------------
41
42Rbuf2DsModule::Rbuf2DsModule() : Module()
43{
44 //Set module properties
45 setDescription("Encode DataStore into RingBuffer");
46 // setPropertyFlags(c_Input | c_ParallelProcessingCertified);
47
48 addParam("RingBufferName", m_rbufname, "Name of RingBuffer",
49 string("InputRbuf"));
50 addParam("CompressionLevel", m_compressionLevel, "Compression level",
51 0);
52
53 m_rbuf = NULL__null;
54 m_nrecv = 0;
55 m_compressionLevel = 0;
56
57
58 //Parameter definition
59 B2INFO("Rx: Constructor done.")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "Rx: Constructor done."; Belle2::LogSystem
::Instance().sendMessage(Belle2::LogMessage(Belle2::LogConfig
::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__, "daq/rfarm/event/modules/src/Rbuf2DsModule.cc"
, 59, 0)); }; } } while(false)
;
60}
61
62
63Rbuf2DsModule::~Rbuf2DsModule()
64{
65}
66
67void Rbuf2DsModule::initialize()
68{
69 gSystem->Load("libdataobjects");
70
71 // m_rbuf = new RingBuffer(m_rbufname.c_str(), RBUFSIZE);
72 m_rbuf = new RingBuffer(m_rbufname.c_str());
73
74 // Initialize DataStoreStreamer
75 m_streamer = new DataStoreStreamer(m_compressionLevel);
76
77
78 // Read the first event in RingBuffer and restore in DataStore.
79 // This is necessary to create object tables before TTree initialization
80 // if used together with SimpleOutput.
81
82 // Prefetch the first record in Ring Buffer
83 int size;
84 char* evtbuf = new char[MAXEVTSIZE400000000];
85 while ((size = m_rbuf->remq((int*)evtbuf)) == 0) {
Although the value stored to 'size' is used in the enclosing expression, the value is never actually read from 'size'
86 // printf ( "Rx : evtbuf is not available yet....\n" );
87 // usleep(100);
88 if (signalled != 0) break;
89 usleep(20);
90 }
91
92 // Restore objects in DataStore
93 EvtMessage* evtmsg = new EvtMessage(evtbuf);
94 m_streamer->restoreDataStore(evtmsg);
95
96 // Delete buffers
97 delete evtmsg;
98 delete[] evtbuf;
99
100 m_nrecv = -1;
101
102 B2INFO("Rx initialized.")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "Rx initialized."; Belle2::LogSystem::Instance
().sendMessage(Belle2::LogMessage(Belle2::LogConfig::c_Info, std
::move(varStream), "daq", __PRETTY_FUNCTION__, "daq/rfarm/event/modules/src/Rbuf2DsModule.cc"
, 102, 0)); }; } } while(false)
;
103}
104
105
106void Rbuf2DsModule::beginRun()
107{
108 if (Environment::Instance().getNumberProcesses() != 0) {
109 struct sigaction s;
110 memset(&s, '\0', sizeof(s));
111 s.sa_handler__sigaction_handler.sa_handler = signalHandler;
112 sigemptyset(&s.sa_mask);
113 if (sigaction(SIGINT2, &s, NULL__null) != 0) {
114 B2FATAL("Rbuf2Ds: Error to connect signal handler")do { { LogVariableStream varStream; varStream << "Rbuf2Ds: Error to connect signal handler"
; Belle2::LogSystem::Instance().sendMessage(Belle2::LogMessage
(Belle2::LogConfig::c_Fatal, std::move(varStream), "daq", __PRETTY_FUNCTION__
, "daq/rfarm/event/modules/src/Rbuf2DsModule.cc", 114, 0)); }
; exit(1); } while(false)
;
115 }
116 printf("Ds2Rbuf : Signal Handler installed.\n");
117 }
118 B2INFO("beginRun called.")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "beginRun called."; Belle2::LogSystem::Instance
().sendMessage(Belle2::LogMessage(Belle2::LogConfig::c_Info, std
::move(varStream), "daq", __PRETTY_FUNCTION__, "daq/rfarm/event/modules/src/Rbuf2DsModule.cc"
, 118, 0)); }; } } while(false)
;
119}
120
121
122void Rbuf2DsModule::event()
123{
124 m_nrecv++;
125 // First event is already loaded
126 if (m_nrecv == 0) return;
127
128 // Get a record from ringbuf
129 int size;
130
131 char* evtbuf = new char[MAXEVTSIZE400000000];
132 while ((size = m_rbuf->remq((int*)evtbuf)) == 0) {
133 // printf ( "Signal Status = %d\n", globalSignalReceived );
134 if (signalled != 0) break;
135 usleep(100);
136 // usleep(20);
137 }
138
139 B2INFO("Rbuf2Ds: got an event from RingBuffer, size=" << size <<do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "Rbuf2Ds: got an event from RingBuffer, size="
<< size << " (proc= " << (int)getpid() <<
")"; Belle2::LogSystem::Instance().sendMessage(Belle2::LogMessage
(Belle2::LogConfig::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__
, "daq/rfarm/event/modules/src/Rbuf2DsModule.cc", 140, 0)); }
; } } while(false)
140 " (proc= " << (int)getpid() << ")")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "Rbuf2Ds: got an event from RingBuffer, size="
<< size << " (proc= " << (int)getpid() <<
")"; Belle2::LogSystem::Instance().sendMessage(Belle2::LogMessage
(Belle2::LogConfig::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__
, "daq/rfarm/event/modules/src/Rbuf2DsModule.cc", 140, 0)); }
; } } while(false)
;
141
142 // Build EvtMessage and decompose it
143 EvtMessage* msg = new EvtMessage(evtbuf); // Have EvtMessage by ptr cpy
144 if (msg->type() == MSG_TERMINATE) {
145 B2INFO("Rx: got termination message. Exitting....")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "Rx: got termination message. Exitting...."
; Belle2::LogSystem::Instance().sendMessage(Belle2::LogMessage
(Belle2::LogConfig::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__
, "daq/rfarm/event/modules/src/Rbuf2DsModule.cc", 145, 0)); }
; } } while(false)
;
146 return;
147 // Flag End Of File !!!!!
148 // return msg->type(); // EOF
149 }
150
151 // Restore DataStore
152 // Restore DataStore
153 m_streamer->restoreDataStore(msg);
154
155 /*
156 // Dummy event header for debugging
157 // Event Meta Data
158 StoreObjPtr<EventMetaData> evtm;
159 evtm.create();
160 evtm->setExperiment(1);
161 evtm->setRun(1);
162 evtm->setEvent(m_nrecv);
163 */
164
165
166 delete[] evtbuf;
167 delete msg;
168
169 B2INFO("Rbuf2Ds: DataStore Restored!!")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "Rbuf2Ds: DataStore Restored!!"; Belle2::
LogSystem::Instance().sendMessage(Belle2::LogMessage(Belle2::
LogConfig::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__
, "daq/rfarm/event/modules/src/Rbuf2DsModule.cc", 169, 0)); }
; } } while(false)
;
170 return;
171 // return type;
172}
173
174void Rbuf2DsModule::endRun()
175{
176 //fill Run data
177
178 B2INFO("Rbuf2Ds: endRun done.")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "Rbuf2Ds: endRun done."; Belle2::LogSystem
::Instance().sendMessage(Belle2::LogMessage(Belle2::LogConfig
::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__, "daq/rfarm/event/modules/src/Rbuf2DsModule.cc"
, 178, 0)); }; } } while(false)
;
179}
180
181
182void Rbuf2DsModule::terminate()
183{
184 B2INFO("Rbuf2Ds: terminate called")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "Rbuf2Ds: terminate called"; Belle2::LogSystem
::Instance().sendMessage(Belle2::LogMessage(Belle2::LogConfig
::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__, "daq/rfarm/event/modules/src/Rbuf2DsModule.cc"
, 184, 0)); }; } } while(false)
;
185}
186