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 rfcommand.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 -pic-is-pie -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/tools/rfcommand.cc
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | #include <stdio.h> |
| 10 | #include <unistd.h> |
| 11 | |
| 12 | #include <string> |
| 13 | |
| 14 | extern "C" { |
| 15 | #include <nsm2/nsm2.h> |
| 16 | #include <nsm2/belle2nsm.h> |
| 17 | } |
| 18 | |
| 19 | #include "daq/rfarm/manager/RFConf.h" |
| 20 | |
| 21 | using namespace std; |
| 22 | using namespace Belle2; |
| 23 | |
| 24 | static int done_flag; |
| 25 | |
| 26 | void ok_handler(NSMmsg* , NSMcontext*) |
| 27 | { |
| 28 | done_flag = 1; |
| 29 | |
| 30 | } |
| 31 | |
| 32 | void error_handler(NSMmsg* , NSMcontext*) |
| 33 | { |
| 34 | done_flag = -1; |
| 35 | printf("ERROR received\n"); |
| 36 | } |
| 37 | |
| 38 | int main(int argc, const char** argv) |
| 39 | { |
| 40 | |
| 41 | |
| 42 | if (argc < 4) { |
| |
| |
| 43 | printf("Usage : rfcommand nodename command\n"); |
| 44 | exit(-1); |
| 45 | } |
| 46 | |
| 47 | const char* conffile = argv[1]; |
| 48 | const char* nodename = argv[2]; |
| 49 | const char* command = argv[3]; |
| 50 | |
| 51 | char* confdir = getenv("RFARM_CONFDIR"); |
| 3 | | Assuming the environment variable does not exist | |
|
| 4 | | 'confdir' initialized here | |
|
| 52 | string confpath = string(confdir) + "/" + string(conffile) + ".conf"; |
| 5 | | The parameter must not be null |
|
| 53 | |
| 54 | RFConf conf(confpath.c_str()); |
| 55 | int port = conf.getconfi("system", "nsmport"); |
| 56 | |
| 57 | |
| 58 | |
| 59 | if (! b2nsm_init2("COMMANDER", 1, 0, port, 0)) { |
| 60 | printf("rfcommand : initialization error %s\n", b2nsm_strerror()); |
| 61 | return -1; |
| 62 | } |
| 63 | |
| 64 | |
| 65 | |
| 66 | if (b2nsm_callback("OK", ok_handler) < 0) { |
| 67 | printf("rfcommand : error to hook CALLBACK(OK) %s", b2nsm_strerror()); |
| 68 | return -1; |
| 69 | } |
| 70 | if (b2nsm_callback("ERROR", ok_handler) < 0) { |
| 71 | printf("rfcommand : error to hook CALLBACK(ERROR) %s", b2nsm_strerror()); |
| 72 | return -1; |
| 73 | } |
| 74 | |
| 75 | |
| 76 | |
| 77 | int* pars = nullptr; |
| 78 | done_flag = 0; |
| 79 | b2nsm_sendreq(nodename, command, 0, pars); |
| 80 | while (done_flag == 0) usleep(1000); |
| 81 | return done_flag; |
| 82 | } |
| 83 | |