Bug Summary

File:daq/rfarm/manager/tools/rfcommand.cc
Warning:line 52, column 21
The parameter must not be null

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 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 * 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 <stdio.h>
10#include <unistd.h>
11
12#include <string>
13
14extern "C" {
15#include <nsm2/nsm2.h>
16#include <nsm2/belle2nsm.h>
17}
18
19#include "daq/rfarm/manager/RFConf.h"
20
21using namespace std;
22using namespace Belle2;
23
24static int done_flag;
25
26void ok_handler(NSMmsg* /*msg*/, NSMcontext*)
27{
28 done_flag = 1;
29 // printf ( "OK received\n" );
30}
31
32void error_handler(NSMmsg* /*msg*/, NSMcontext*)
33{
34 done_flag = -1;
35 printf("ERROR received\n");
36}
37
38int main(int argc, const char** argv)
39{
40 // Usage : getconf conffile node
41
42 if (argc < 4) {
1
Assuming 'argc' is >= 4
2
Taking false branch
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 // NSM initialization
58 // if (! b2nsm_init("COMMANDER")) {
59 if (! b2nsm_init2("COMMANDER", 1, 0, port, 0)) {
60 printf("rfcommand : initialization error %s\n", b2nsm_strerror());
61 return -1;
62 }
63 // printf ( "initialization done\n" );
64
65 // handlers
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 // Send NSM request
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