Skip to content

Commit

Permalink
Merge pull request #105 from ggtakec/fix_cppcheck
Browse files Browse the repository at this point in the history
Fixed errors reported by cppcheck 2.9
  • Loading branch information
Takeshi Nakatani authored Sep 22, 2022
2 parents dbf876f + 53ac5dc commit 78736b8
Show file tree
Hide file tree
Showing 23 changed files with 171 additions and 70 deletions.
18 changes: 10 additions & 8 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ CPPCHECK_OPT= --quiet \
-j 4 \
--std=c++03 \
--xml-version=2 \
--enable=warning,style,information,missingInclude
--enable=warning,style,information,missingInclude \
--cppcheck-build-dir=/tmp/cppcheck
CPPCHECK_DEF= -D SO_REUSEPORT
CPPCHECK_IGN=

Expand All @@ -53,18 +54,19 @@ CPPCHECK_IGN=
# If the other will support 1.8x or later versions in the
# future, this skipped process will be unnecessary.
#
CPPCHECK_NGVER= -e 1\\.7 -e 1\\.6
CPPCHECK_NGVER= -e \^1\\.7 -e \^1\\.6

cppcheck:
echo "$(CPPCHECK_CMD) $(CPPCHECK_OPT) $(CPPCHECK_DEF) $(CPPCHECK_IGN) $(SUBDIRS)"
if test "X$$CI" = "Xtrue"; then \
if ($(CPPCHECK_CMD) --version | grep $(CPPCHECK_NGVER)) >/dev/null 2>&1; then \
echo " --> Skip, because this old $(CPPCHECK_CMD) version is very poor performance on VM(CI)"; \
else \
$(CPPCHECK_CMD) $(CPPCHECK_OPT) $(CPPCHECK_DEF) $(CPPCHECK_IGN) $(SUBDIRS); \
fi; \
if ($(CPPCHECK_CMD) --version | sed -e 's|Cppcheck[[:space:]]*||gi' | grep -q $(CPPCHECK_NGVER)); then \
echo " --> Skip, because this old $(CPPCHECK_CMD) version is very poor performance on VM(CI)"; \
else \
if [ -d /tmp/cppcheck ]; then \
rm -rf /tmp/cppcheck; \
fi; \
mkdir /tmp/cppcheck; \
$(CPPCHECK_CMD) $(CPPCHECK_OPT) $(CPPCHECK_DEF) $(CPPCHECK_IGN) $(SUBDIRS); \
rm -rf /tmp/cppcheck; \
fi

#
Expand Down
10 changes: 5 additions & 5 deletions lib/chmconf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -504,17 +504,17 @@ bool CHMConf::Receive(int fd)
// get type
bool is_check_file = false;
bool is_reload = false;
uint type = CheckNotifyEvent();
if(type & IN_CLOSE_WRITE){
uint chktype = CheckNotifyEvent();
if(chktype & IN_CLOSE_WRITE){
is_reload = true;
}
if(type & IN_MODIFY){
if(chktype & IN_MODIFY){
is_reload = true;
}
if(type & IN_DELETE_SELF){
if(chktype & IN_DELETE_SELF){
is_check_file = true;
}
if(type & IN_MOVE_SELF){
if(chktype & IN_MOVE_SELF){
is_check_file = true;
}

Expand Down
12 changes: 6 additions & 6 deletions lib/chmconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ class CHMConf : public ChmEventBase
PCHMCFGINFO pchmcfginfo;

protected:
CHMConf(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, const char* file = NULL, short ctlport = CHM_INVALID_PORT, const char* cuk = NULL, const char* pJson = NULL);
explicit CHMConf(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, const char* file = NULL, short ctlport = CHM_INVALID_PORT, const char* cuk = NULL, const char* pJson = NULL);

virtual bool LoadConfiguration(CHMCFGINFO& chmcfginfo) const = 0;

Expand Down Expand Up @@ -653,7 +653,7 @@ class CHMIniConf : public CHMConf
friend class CHMConf;

protected:
CHMIniConf(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, const char* file = NULL, short ctlport = CHM_INVALID_PORT, const char* cuk = NULL);
explicit CHMIniConf(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, const char* file = NULL, short ctlport = CHM_INVALID_PORT, const char* cuk = NULL);

virtual bool LoadConfiguration(CHMCFGINFO& chmcfginfo) const;
bool LoadConfigurationRaw(CFGRAW& chmcfgraw) const;
Expand All @@ -671,7 +671,7 @@ class CHMYamlBaseConf : public CHMConf
friend class CHMConf;

protected:
CHMYamlBaseConf(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, const char* file = NULL, short ctlport = CHM_INVALID_PORT, const char* cuk = NULL, const char* pJson = NULL);
explicit CHMYamlBaseConf(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, const char* file = NULL, short ctlport = CHM_INVALID_PORT, const char* cuk = NULL, const char* pJson = NULL);

virtual bool LoadConfiguration(CHMCFGINFO& chmcfginfo) const;

Expand All @@ -687,7 +687,7 @@ class CHMJsonConf : public CHMYamlBaseConf
friend class CHMConf;

protected:
CHMJsonConf(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, const char* file = NULL, short ctlport = CHM_INVALID_PORT, const char* cuk = NULL);
explicit CHMJsonConf(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, const char* file = NULL, short ctlport = CHM_INVALID_PORT, const char* cuk = NULL);

public:
virtual ~CHMJsonConf();
Expand All @@ -701,7 +701,7 @@ class CHMJsonStringConf : public CHMYamlBaseConf
friend class CHMConf;

protected:
CHMJsonStringConf(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, const char* pJson = NULL, short ctlport = CHM_INVALID_PORT, const char* cuk = NULL);
explicit CHMJsonStringConf(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, const char* pJson = NULL, short ctlport = CHM_INVALID_PORT, const char* cuk = NULL);

public:
virtual ~CHMJsonStringConf();
Expand All @@ -715,7 +715,7 @@ class CHMYamlConf : public CHMYamlBaseConf
friend class CHMConf;

protected:
CHMYamlConf(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, const char* file = NULL, short ctlport = CHM_INVALID_PORT, const char* cuk = NULL);
explicit CHMYamlConf(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, const char* file = NULL, short ctlport = CHM_INVALID_PORT, const char* cuk = NULL);

public:
virtual ~CHMYamlConf();
Expand Down
2 changes: 1 addition & 1 deletion lib/chmeventbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ChmEventBase
ChmCntrl* pChmCntrl;

public:
ChmEventBase(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL);
explicit ChmEventBase(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL);
virtual ~ChmEventBase();

bool IsEmpty(void) const { return (!pChmCntrl || CHM_INVALID_HANDLE == eqfd); }
Expand Down
4 changes: 4 additions & 0 deletions lib/chmeventmq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ bool ChmEventMq::InitializeMaxMqSystemSize(long maxmsg)
size_t length = 0L;
if(NULL == (pbuff = reinterpret_cast<char*>(chm_read(fd, &length)))){
ERR_CHMPRN("Could not read file %s", PROCFILE_FOR_MQ);
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_CLOSE(fd);
return false;
}
Expand Down Expand Up @@ -209,6 +211,8 @@ bool ChmEventMq::MergeWorkerFunc(void* common_param, chmthparam_t wp_param)
}
// copy param
CHM_MERGE_GETPARAM getparam;
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
getparam.starthash = 0; // must be start position 0
getparam.startts.tv_nsec = pUpdateDataParam->startts.tv_nsec;
getparam.startts.tv_sec = pUpdateDataParam->startts.tv_sec;
Expand Down
2 changes: 1 addition & 1 deletion lib/chmeventmq.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class ChmEventMq : public ChmEventBase
public:
static bool InitializeMaxMqSystemSize(long maxmsg);

ChmEventMq(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, chm_merge_get_cb mgetfp = NULL, chm_merge_set_cb msetfp = NULL, chm_merge_lastts_cb mlastfp = NULL);
explicit ChmEventMq(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, chm_merge_get_cb mgetfp = NULL, chm_merge_set_cb msetfp = NULL, chm_merge_lastts_cb mlastfp = NULL);
virtual ~ChmEventMq();

virtual bool Clean(void);
Expand Down
2 changes: 1 addition & 1 deletion lib/chmeventshm.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ChmEventShm : public ChmEventBase
public:
static bool CheckProcessRunning(void* common_param, chmthparam_t wp_param);

ChmEventShm(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, const char* file = NULL);
explicit ChmEventShm(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, const char* file = NULL);
virtual ~ChmEventShm();

virtual bool Clean(void);
Expand Down
17 changes: 17 additions & 0 deletions lib/chmeventsock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,8 @@ bool ChmEventSock::RawSendCtlPort(const char* hostname, short ctlport, const uns
if(!ChmEventSock::RawSend(ctlsock, NULL, pbydata, length, is_closed, false, retrycnt, waittime)){
ERR_CHMPRN("Could not send to %s:%d(sock:%d).", hostname, ctlport, ctlsock);
if(!is_closed){
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_CLOSESOCK(ctlsock);
}
return false;
Expand All @@ -923,6 +925,8 @@ bool ChmEventSock::RawSendCtlPort(const char* hostname, short ctlport, const uns
if(!ChmEventSock::RawReceiveAny(ctlsock, is_closed, reinterpret_cast<unsigned char*>(szReceive), &RecLength, false, retrycnt * 10, waittime)){ // wait 10 times by normal
ERR_CHMPRN("Failed to receive data from ctlport ctlsock(%d), ctlsock is %s.", ctlsock, is_closed ? "closed" : "not closed");
if(!is_closed){
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_CLOSESOCK(ctlsock);
}
return false;
Expand Down Expand Up @@ -2119,6 +2123,8 @@ bool ChmEventSock::SetEventQueue(void)
eqevent.events = EPOLLIN | EPOLLET | EPOLLRDHUP; // EPOLLRDHUP is set
if(-1 == epoll_ctl(eqfd, EPOLL_CTL_ADD, sock, &eqevent)){
ERR_CHMPRN("Failed to add sock(port %d: sock %d) into epoll event(%d), errno=%d", port, sock, eqfd, errno);
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_CLOSESOCK(sock);
return false;
}
Expand All @@ -2130,6 +2136,8 @@ bool ChmEventSock::SetEventQueue(void)
if(CHM_INVALID_SOCK != sock){
epoll_ctl(eqfd, EPOLL_CTL_DEL, sock, NULL);
}
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_CLOSESOCK(sock);
return false;
}
Expand All @@ -2143,7 +2151,11 @@ bool ChmEventSock::SetEventQueue(void)
if(CHM_INVALID_SOCK != sock){
epoll_ctl(eqfd, EPOLL_CTL_DEL, sock, NULL);
}
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_CLOSESOCK(sock);
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_CLOSESOCK(ctlsock);
return false;
}
Expand Down Expand Up @@ -3567,6 +3579,7 @@ bool ChmEventSock::CloseSSL(int sock, bool with_sock)
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress uselessAssignmentPtrArg
// cppcheck-suppress uselessAssignmentArg
// cppcheck-suppress unreadVariable
CHM_CLOSESOCK(sock);
}
return true;
Expand Down Expand Up @@ -4262,6 +4275,8 @@ bool ChmEventSock::Accept(int sock)
string strhostname;
if(!ChmNetDb::CvtAddrInfoToIpAddress(&from, fromlen, stripaddress)){
ERR_CHMPRN("Failed to convert addrinfo(new sock=%d) to ipaddress.", newsock);
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_CLOSESOCK(newsock);
return false;
}
Expand Down Expand Up @@ -5969,6 +5984,8 @@ bool ChmEventSock::ContinuousAutoMerge(void)
startup_servicein = false;

// re-get status
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
status = pImData->GetSelfStatus();
}else{
// Not [SERVICE OUT] [UP] [NOACT] [NOTHING] status
Expand Down
2 changes: 1 addition & 1 deletion lib/chmeventsock.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class ChmEventSock : public ChmEventBase
static void DenySelfSignedCert(void);
static int WaitForReady(int sock, int type, int retrycnt, bool is_check_so_error = false, suseconds_t waittime = CHMEVENTSOCK_TIMEOUT_DEFAULT);

ChmEventSock(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, bool is_ssl = false);
explicit ChmEventSock(int eventqfd = CHM_INVALID_HANDLE, ChmCntrl* pcntrl = NULL, bool is_ssl = false);
virtual ~ChmEventSock();

bool InitialAllServerStatus(void);
Expand Down
22 changes: 22 additions & 0 deletions lib/chmimdata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,8 @@ bool ChmIMData::InitializeShmEx(const CHMCFGINFO& chmcfg, const CHMNODE_CFGINFO*
// truncate with filling zero
if(!truncate_filling_zero(fd, total_shmsize, ChmIMData::SYSPAGE_SIZE)){
ERR_CHMPRN("Could not truncate file(%s) with filling zero.", shmpath.c_str());
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_CLOSE(fd);
return false;
}
Expand All @@ -698,6 +700,8 @@ bool ChmIMData::InitializeShmEx(const CHMCFGINFO& chmcfg, const CHMNODE_CFGINFO*
void* shmbase;
if(MAP_FAILED == (shmbase = mmap(NULL, total_shmsize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0))){
ERR_CHMPRN("Could not mmap file(%s), errno = %d", shmpath.c_str(), errno);
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_CLOSE(fd);
return false;
}
Expand Down Expand Up @@ -739,6 +743,8 @@ bool ChmIMData::InitializeShmEx(const CHMCFGINFO& chmcfg, const CHMNODE_CFGINFO*
chmpxlistlap tmpchmpxlist(&chmpxlist[cnt], NULL, NULL, NULL, NULL, NULL, shmbase); // absmapptr, chmpx*s are NULL, these can allow only here(calling only Initialize()).
if(!tmpchmpxlist.Initialize(prev, next)){
ERR_CHMPRN("Failed to initialize No.%ld CHMPXLIST.", cnt);
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_MUMMAP(fd, shmbase, total_shmsize);
return false;
}
Expand All @@ -759,6 +765,8 @@ bool ChmIMData::InitializeShmEx(const CHMCFGINFO& chmcfg, const CHMNODE_CFGINFO*
mqmsgheadlistlap tmpmqmsgheadlist(&mqmsglist[cnt], shmbase);
if(!tmpmqmsgheadlist.Initialize(prev, next)){
ERR_CHMPRN("Failed to initialize No.%ld MQMSGHEADLIST.", cnt);
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_MUMMAP(fd, shmbase, total_shmsize);
return false;
}
Expand All @@ -774,6 +782,8 @@ bool ChmIMData::InitializeShmEx(const CHMCFGINFO& chmcfg, const CHMNODE_CFGINFO*
cltproclistlap tmpcltproclist(&cltproclist[cnt], shmbase);
if(!tmpcltproclist.Initialize(prev, next)){
ERR_CHMPRN("Failed to initialize No.%ld PCLTPROCLIST.", cnt);
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_MUMMAP(fd, shmbase, total_shmsize);
return false;
}
Expand All @@ -785,6 +795,8 @@ bool ChmIMData::InitializeShmEx(const CHMCFGINFO& chmcfg, const CHMNODE_CFGINFO*
chmlograwlap tmplograw(&lograw[cnt], shmbase);
if(!tmplograw.Initialize()){
ERR_CHMPRN("Failed to initialize No.%ld CHMLOGRAW.", cnt);
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_MUMMAP(fd, shmbase, total_shmsize);
return false;
}
Expand All @@ -800,6 +812,8 @@ bool ChmIMData::InitializeShmEx(const CHMCFGINFO& chmcfg, const CHMNODE_CFGINFO*
chmsocklistlap tmpchmsocklist(&chmsocklist[cnt], shmbase);
if(!tmpchmsocklist.Initialize(prev, next)){
ERR_CHMPRN("Failed to initialize No.%ld PCHMSOCKLIST.", cnt);
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_MUMMAP(fd, shmbase, total_shmsize);
return false;
}
Expand All @@ -817,6 +831,8 @@ bool ChmIMData::InitializeShmEx(const CHMCFGINFO& chmcfg, const CHMNODE_CFGINFO*
chmloglap tmpchmlog(&pChmBase->chmpxlog, shmbase);
if(!tmpchmlog.Initialize(rel_lograwarea, chmcfg.max_histlog_count)){
ERR_CHMPRN("Failed to initialize CHMLOG.");
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_MUMMAP(fd, shmbase, total_shmsize);
return false;
}
Expand All @@ -825,6 +841,8 @@ bool ChmIMData::InitializeShmEx(const CHMCFGINFO& chmcfg, const CHMNODE_CFGINFO*
chminfolap tmpchminfo(&pChmBase->info, shmbase);
if(!tmpchminfo.Initialize(&chmcfg, rel_chmpxmsgarea, pself, pnormalizedname, rel_chmpxarea, rel_chmpxpidarea, rel_chmsockarea, rel_pchmpxarr_base, rel_pchmpxarr_pend)){
ERR_CHMPRN("Failed to initialize CHMINFO.");
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_MUMMAP(fd, shmbase, total_shmsize);
return false;
}
Expand Down Expand Up @@ -895,6 +913,8 @@ bool ChmIMData::AttachShm(void)
void* shmbase;
if(MAP_FAILED == (shmbase = mmap(NULL, total_shmsize, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0))){
ERR_CHMPRN("Could not mmap file(%s), errno = %d", shmpath.c_str(), errno);
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_CLOSE(fd);
return false;
}
Expand All @@ -903,6 +923,8 @@ bool ChmIMData::AttachShm(void)
PCHMSHM pTmpChmShm = reinterpret_cast<PCHMSHM>(shmbase);
if(!ChmIMData::IsSafeCHMINFO(&(pTmpChmShm->info))){
ERR_CHMPRN("Unsafe CHMINFO file(%s), probably this is created by old CHMPX version", shmpath.c_str());
// cppcheck-suppress unmatchedSuppression
// cppcheck-suppress unreadVariable
CHM_MUMMAP(fd, shmbase, total_shmsize);
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/chmkvp.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ChmBinData
bool is_allocate;

public:
ChmBinData(unsigned char* bydata = NULL, size_t bylength = 0L, bool is_duplicate = false);
explicit ChmBinData(unsigned char* bydata = NULL, size_t bylength = 0L, bool is_duplicate = false);
ChmBinData(PCHMBIN pchmbin, bool is_duplicate);
virtual ~ChmBinData();

Expand Down Expand Up @@ -77,7 +77,7 @@ class ChmKVPair
ChmBinData Value;

public:
ChmKVPair(unsigned char* bykey = NULL, size_t keylen = 0L, unsigned char* byval = NULL, size_t vallen = 0L, bool is_duplicate = false);
explicit ChmKVPair(unsigned char* bykey = NULL, size_t keylen = 0L, unsigned char* byval = NULL, size_t vallen = 0L, bool is_duplicate = false);
ChmKVPair(ChmBinData* pKey, ChmBinData* pValue, bool is_duplicate = false);
ChmKVPair(PCHMKVP pkvp, bool is_duplicate);
virtual ~ChmKVPair();
Expand Down
2 changes: 1 addition & 1 deletion lib/chmlockmap.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class chm_lock_map
chm_lock_map(void) : lockval(FLCK_NOSHARED_MUTEX_VAL_UNLOCKED), pbasefunc(NULL), pbaseparam(NULL) {}

public:
chm_lock_map(const val_type& initval, chm_lock_map_erase_cb pfunc = NULL, void* pparam = NULL) : lockval(FLCK_NOSHARED_MUTEX_VAL_UNLOCKED), pbasefunc(pfunc), pbaseparam(pparam), emptyval(initval) {}
explicit chm_lock_map(const val_type& initval, chm_lock_map_erase_cb pfunc = NULL, void* pparam = NULL) : lockval(FLCK_NOSHARED_MUTEX_VAL_UNLOCKED), pbasefunc(pfunc), pbaseparam(pparam), emptyval(initval) {}
virtual ~chm_lock_map(void) { clear(); }

inline size_t count(void);
Expand Down
4 changes: 2 additions & 2 deletions lib/chmnetdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,7 @@ bool ChmNetDb::InitializeLocalHostnames()
// add cache
if(!is_same_nodename || !fulllocalname.empty()){
memset(&ipaddr, 0, sizeof(ipaddr));
if(0 == (result = getnameinfo(tmpaddrinfo->ai_addr, tmpaddrinfo->ai_addrlen, ipaddr, sizeof(ipaddr), NULL, 0, NI_NUMERICHOST))){
if(0 == getnameinfo(tmpaddrinfo->ai_addr, tmpaddrinfo->ai_addrlen, ipaddr, sizeof(ipaddr), NULL, 0, NI_NUMERICHOST)){
HostnammeAddCache(string(hostname), string(ipaddr), true);

if(is_same_nodename && !fulllocalname.empty()){
Expand Down Expand Up @@ -1328,7 +1328,7 @@ bool ChmNetDb::GetHostAddressInfo(const char* target, CHMNDBCACHE& data)

// add cache
bool is_hostname = false;
if(0 != (result = getnameinfo(tmpaddrinfo->ai_addr, tmpaddrinfo->ai_addrlen, hostname, sizeof(hostname), NULL, 0, NI_NAMEREQD | NI_NUMERICSERV))){
if(0 != getnameinfo(tmpaddrinfo->ai_addr, tmpaddrinfo->ai_addrlen, hostname, sizeof(hostname), NULL, 0, NI_NAMEREQD | NI_NUMERICSERV)){
is_hostname = true;
IpAddressAddCache(string(ipaddr), string(hostname));
}
Expand Down
2 changes: 1 addition & 1 deletion lib/chmopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ChmOpts
std::string sepchars;

public:
ChmOpts(int argc = 0, char** argv = NULL, const char* strsepchars = NULL);
explicit ChmOpts(int argc = 0, char** argv = NULL, const char* strsepchars = NULL);
virtual ~ChmOpts();

bool Initialize(int argc, char** argv);
Expand Down
Loading

0 comments on commit 78736b8

Please sign in to comment.