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 HistoServer.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/dqm/src/HistoServer.cc
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | #include <daq/dqm/HistoServer.h> |
| 9 | |
| 10 | #include <framework/pcore/MsgHandler.h> |
| 11 | #include <ctime> |
| 12 | #include <unistd.h> |
| 13 | |
| 14 | using namespace Belle2; |
| 15 | using namespace std; |
| 16 | |
| 17 | |
| 18 | HistoServer::HistoServer(int port, const string& filename) |
| 19 | { |
| 20 | m_port = port; |
| 21 | m_force_exit = 0; |
| 22 | m_filename = filename; |
| 23 | } |
| 24 | |
| 25 | HistoServer::~HistoServer() |
| 26 | { |
| 27 | delete m_sock; |
| 28 | } |
| 29 | |
| 30 | |
| 31 | |
| 32 | int HistoServer:: init() |
| 33 | { |
| 34 | m_sock = new EvtSocketRecv(m_port, false); |
| 35 | m_man = new EvtSocketManager(m_sock); |
| 36 | |
| 37 | m_memfile = new DqmMemFile(m_filename, "write", DqmMemFile::c_memFileSize); |
| 38 | m_hman = new HistoManager(m_memfile); |
| 39 | |
| 40 | |
| 41 | |
| 42 | |
| 43 | return 0; |
| 44 | |
| 45 | } |
| 46 | |
| 47 | |
| 48 | int HistoServer::server() |
| 49 | { |
| 50 | SocketIO sio; |
| 51 | MsgHandler msghdl(0); |
| 52 | char mbstr[100]; |
| 53 | time_t now; |
| 54 | char* buffer = new char[c_maxBufSize]; |
| |
| 55 | |
| 56 | int loop_counter = 0; |
| 57 | bool updated = false; |
| 58 | while (m_force_exit == 0) { |
| 2 | | Assuming field 'm_force_exit' is not equal to 0 | |
|
| 3 | | Loop condition is false. Execution jumps to the end of the function | |
|
| 59 | fflush(stdout); |
| 60 | int exam_stat = m_man->examine(); |
| 61 | if (exam_stat == 0) { |
| 62 | } else if (exam_stat == 1) { |
| 63 | |
| 64 | vector<int>& recvsock = m_man->connected_socket_list(); |
| 65 | for (vector<int>::iterator it = recvsock.begin(); |
| 66 | it != recvsock.end(); ++it) { |
| 67 | int fd = *it; |
| 68 | if (m_man->connected(fd)) { |
| 69 | int is = sio.get(fd, buffer, c_maxBufSize); |
| 70 | if (is <= 0) { |
| 71 | now = time(0); |
| 72 | strftime(mbstr, sizeof(mbstr), "%c", localtime(&now)); |
| 73 | printf("[%s] HistoServer: fd %d disconnected\n", mbstr, fd); |
| 74 | m_man->remove(fd); |
| 75 | break; |
| 76 | } |
| 77 | updated = true; |
| 78 | |
| 79 | |
| 80 | EvtMessage* hmsg = new EvtMessage(buffer); |
| 81 | vector<TObject*> objlist; |
| 82 | vector<string> strlist; |
| 83 | msghdl.decode_msg(hmsg, objlist, strlist); |
| 84 | int nobjs = (hmsg->header())->reserved[1]; |
| 85 | |
| 86 | string subdir = ""; |
| 87 | now = time(0); |
| 88 | strftime(mbstr, sizeof(mbstr), "%c", localtime(&now)); |
| 89 | printf("[%s] HistoServer : received nobjs = %d\n", mbstr, nobjs); |
| 90 | for (int i = 0; i < nobjs; i++) { |
| 91 | |
| 92 | |
| 93 | string objname = strlist.at(i); |
| 94 | if (objname == string("DQMRC:CLEAR")) { |
| 95 | m_hman->clear(); |
| 96 | m_hman->merge(); |
| 97 | now = time(0); |
| 98 | strftime(mbstr, sizeof(mbstr), "%c", localtime(&now)); |
| 99 | printf("[%s] HistoServer: CLEAR\n", mbstr); |
| 100 | updated = false; |
| 101 | continue; |
| 102 | } |
| 103 | if (objname == string("DQMRC:MERGE")) { |
| 104 | m_hman->merge(); |
| 105 | now = time(0); |
| 106 | strftime(mbstr, sizeof(mbstr), "%c", localtime(&now)); |
| 107 | printf("[%s] HistoServer: MERGE\n", mbstr); |
| 108 | updated = false; |
| 109 | continue; |
| 110 | } |
| 111 | auto lpos = objname.find("DQMRC:SAVE:"); |
| 112 | if (lpos != string::npos) { |
| 113 | auto filename = objname.substr(11); |
| 114 | m_hman->filedump(filename); |
| 115 | continue; |
| 116 | } |
| 117 | lpos = objname.find("SUBDIR:"); |
| 118 | if (lpos != string::npos) { |
| 119 | subdir = objname.substr(7); |
| 120 | if (subdir == "EXIT") subdir = ""; |
| 121 | |
| 122 | } else { |
| 123 | m_hman->update(subdir, strlist.at(i), fd, (TH1*)objlist.at(i)); |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | } |
| 129 | usleep(1000); |
| 130 | loop_counter++; |
| 131 | if (loop_counter % c_mergeIntervall == 0 && updated) { |
| 132 | now = time(0); |
| 133 | strftime(mbstr, sizeof(mbstr), "%c", localtime(&now)); |
| 134 | printf("[%s] HistoServer: merging histograms\n", mbstr); |
| 135 | |
| 136 | m_hman->merge(); |
| 137 | |
| 138 | updated = false; |
| 139 | } |
| 140 | } |
| 141 | return 0; |
| 4 | | Potential leak of memory pointed to by 'buffer' |
|
| 142 | } |
| 143 | |
| 144 | |