Bug Summary

File:daq/storage/modules/src/PartialSeqRootReader.cc
Warning:line 75, column 5
Value stored to 'ret' is never read

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 PartialSeqRootReader.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/storage/modules/src/PartialSeqRootReader.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/storage/modules/PartialSeqRootReader.h>
10
11#include <iostream>
12#include <cstdio>
13#include <fcntl.h>
14#include <unistd.h>
15
16using namespace Belle2;
17
18//-----------------------------------------------------------------
19// Register the Module
20//-----------------------------------------------------------------
21REG_MODULE(PartialSeqRootReader)namespace { struct ModuleProxyPartialSeqRootReader: public ModuleProxyBase
{ ModuleProxyPartialSeqRootReader(): ModuleProxyBase("PartialSeqRootReader"
, "" "daq") {} virtual ::Belle2::Module* createInstance() const
override final { return new PartialSeqRootReaderModule(); } }
proxyPartialSeqRootReaderModule; }
;
22
23//-----------------------------------------------------------------
24// Implementation
25//-----------------------------------------------------------------
26
27PartialSeqRootReaderModule::PartialSeqRootReaderModule() : Module()
28{
29 m_buf = new char[1024 * 1024 * 100];//100MB
30 setDescription("Partial sroot file reader");
31
32 addParam("FilePath", m_path, "File path ", std::string(""));
33 addParam("FileNoMin", m_filemin, "Minimum filenumber ", 0);
34 addParam("FileNoMax", m_filemax, "Maximum filenumber ", -1);
35 m_fd = -1;
36 m_fileno = -1;
37 B2INFO("PartialSeqRootReader: Constructor done.")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "PartialSeqRootReader: Constructor done."
; Belle2::LogSystem::Instance().sendMessage(Belle2::LogMessage
(Belle2::LogConfig::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__
, "daq/storage/modules/src/PartialSeqRootReader.cc", 37, 0));
}; } } while(false)
;
38}
39
40
41PartialSeqRootReaderModule::~PartialSeqRootReaderModule()
42{
43 close(m_fd);
44 delete [] m_buf;
45}
46
47int PartialSeqRootReaderModule::openFile(int fileno)
48{
49 if (m_fd > 0) close(m_fd);
50 if (fileno > m_filemax) return -1;
51 char filename[200];
52 if (fileno > 0) {
53 sprintf(filename, "%s-%d", m_path.c_str(), fileno);
54 } else if (fileno == 0) {
55 sprintf(filename, "%s", m_path.c_str());
56 }
57 int fd = ::open(filename, O_RDONLY00);
58 if (fd < 0) {
59 B2ERROR("file open error (" << strerror(errno) << "): " << filename)do { { LogVariableStream varStream; varStream << "file open error ("
<< strerror((*__errno_location ())) << "): " <<
filename; Belle2::LogSystem::Instance().sendMessage(Belle2::
LogMessage(Belle2::LogConfig::c_Error, std::move(varStream), "daq"
, __PRETTY_FUNCTION__, "daq/storage/modules/src/PartialSeqRootReader.cc"
, 59, 0)); } } while(false)
;
60 return -1;
61 }
62 std::cout << "SeqFile: " << filename << " opened (fd=" << m_fd << ")" << std::endl;
63 B2INFO("SeqFile: " << filename << " opened (fd=" << m_fd << ")")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "SeqFile: " << filename << " opened (fd="
<< m_fd << ")"; Belle2::LogSystem::Instance().sendMessage
(Belle2::LogMessage(Belle2::LogConfig::c_Info, std::move(varStream
), "daq", __PRETTY_FUNCTION__, "daq/storage/modules/src/PartialSeqRootReader.cc"
, 63, 0)); }; } } while(false)
;
64 return fd;
65}
66
67int PartialSeqRootReaderModule::readFile()
68{
69 int ret = ::read(m_fd, m_buf, sizeof(int));
70 if (ret < 0) {
71 return ret;
72 } else if (ret == 0) {
73 m_fd = openFile(m_fileno++);
74 if (m_fd <= 0) return -1;
75 ret = ::read(m_fd, m_buf, sizeof(int));
Value stored to 'ret' is never read
76 }
77 int size = *(int*)m_buf;
78 ret = ::read(m_fd, (char*)(m_buf + sizeof(int)), size - sizeof(int));
79 if (ret <= 0) {
80 return -1;
81 }
82 return size;
83}
84
85void PartialSeqRootReaderModule::initialize()
86{
87 B2INFO("PartialSeqRootReader: initialize() started.")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "PartialSeqRootReader: initialize() started."
; Belle2::LogSystem::Instance().sendMessage(Belle2::LogMessage
(Belle2::LogConfig::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__
, "daq/storage/modules/src/PartialSeqRootReader.cc", 87, 0));
}; } } while(false)
;
88 m_streamer = new DataStoreStreamer();
89 m_fd = openFile(0);
90 m_fileno = m_filemin;
91 while (true) {
92 if (readFile() < 0) return;
93 EvtMessage* evtmsg = new EvtMessage(m_buf);
94 m_streamer->restoreDataStore(evtmsg);
95 if (evtmsg->type() == MSG_STREAMERINFO) {
96 B2INFO("Reading StreamerInfo")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "Reading StreamerInfo"; Belle2::LogSystem
::Instance().sendMessage(Belle2::LogMessage(Belle2::LogConfig
::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__, "daq/storage/modules/src/PartialSeqRootReader.cc"
, 96, 0)); }; } } while(false)
;
97 delete evtmsg;
98 } else {
99 delete evtmsg;
100 break;
101 }
102 }
103 if (m_fileno > 0) {
104 m_fd = openFile(m_fileno++);
105 } else {
106 m_fileno++;
107 }
108 while (true) {
109 if (readFile() < 0) return;
110 EvtMessage* evtmsg = new EvtMessage(m_buf);
111 m_streamer->restoreDataStore(evtmsg);
112 if (evtmsg->type() == MSG_STREAMERINFO) {
113 B2INFO("Reading StreamerInfo")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "Reading StreamerInfo"; Belle2::LogSystem
::Instance().sendMessage(Belle2::LogMessage(Belle2::LogConfig
::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__, "daq/storage/modules/src/PartialSeqRootReader.cc"
, 113, 0)); }; } } while(false)
;
114 delete evtmsg;
115 } else {
116 delete evtmsg;
117 break;
118 }
119 }
120
121 B2INFO("PartialSeqRootReader: initialize() done.")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "PartialSeqRootReader: initialize() done."
; Belle2::LogSystem::Instance().sendMessage(Belle2::LogMessage
(Belle2::LogConfig::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__
, "daq/storage/modules/src/PartialSeqRootReader.cc", 121, 0))
; }; } } while(false)
;
122}
123
124void PartialSeqRootReaderModule::event()
125{
126 while (true) {
127 if (readFile() < 0) return;
128 EvtMessage* evtmsg = new EvtMessage(m_buf);
129 m_streamer->restoreDataStore(evtmsg);
130 if (evtmsg->type() == MSG_STREAMERINFO) {
131 B2INFO("Reading StreamerInfo")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "Reading StreamerInfo"; Belle2::LogSystem
::Instance().sendMessage(Belle2::LogMessage(Belle2::LogConfig
::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__, "daq/storage/modules/src/PartialSeqRootReader.cc"
, 131, 0)); }; } } while(false)
;
132 delete evtmsg;
133 } else {
134 delete evtmsg;
135 break;
136 }
137 }
138}
139
140void PartialSeqRootReaderModule::beginRun()
141{
142 B2INFO("PartialSeqRootReader: beginRun called.")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "PartialSeqRootReader: beginRun called."
; Belle2::LogSystem::Instance().sendMessage(Belle2::LogMessage
(Belle2::LogConfig::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__
, "daq/storage/modules/src/PartialSeqRootReader.cc", 142, 0))
; }; } } while(false)
;
143}
144
145void PartialSeqRootReaderModule::endRun()
146{
147 B2INFO("PartialSeqRootReader: endRun done.")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "PartialSeqRootReader: endRun done."; Belle2
::LogSystem::Instance().sendMessage(Belle2::LogMessage(Belle2
::LogConfig::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__
, "daq/storage/modules/src/PartialSeqRootReader.cc", 147, 0))
; }; } } while(false)
;
148}
149
150
151void PartialSeqRootReaderModule::terminate()
152{
153 B2INFO("PartialSeqRootReader: terminate called")do { if (Belle2::LogSystem::Instance().isLevelEnabled(Belle2::
LogConfig::c_Info, 0, "daq")) { { LogVariableStream varStream
; varStream << "PartialSeqRootReader: terminate called"
; Belle2::LogSystem::Instance().sendMessage(Belle2::LogMessage
(Belle2::LogConfig::c_Info, std::move(varStream), "daq", __PRETTY_FUNCTION__
, "daq/storage/modules/src/PartialSeqRootReader.cc", 153, 0))
; }; } } while(false)
;
154}
155
156