Fix mtce-common build error with gcc-8.2.1
gcc-8.2.1 reports "Werror=format-truncation" error due to there is possibility the string be truncated, add return value check could avoid the error. Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com> Signed-off-by: Dongqi Chen <chen.dq@neusoft.com> Change-Id: I8fa08077e47ee3777a50f018af77b3e8fc6191f9 Story: 2007506 Task: 39278
This commit is contained in:
parent
b235d3c111
commit
7423edce9b
|
@ -330,12 +330,17 @@ int msgClassAddr::getAddressFromInterface(const char* interface, char* address,
|
|||
// is the intf hostname
|
||||
char iface_hostname[MAX_CHARS_HOSTNAME];
|
||||
memset(iface_hostname, 0, sizeof(iface_hostname));
|
||||
snprintf(iface_hostname, sizeof(iface_hostname),
|
||||
int ret = snprintf(iface_hostname, sizeof(iface_hostname),
|
||||
"%s%s", hostname,
|
||||
(((interface_type == CLSTR_IFACE)) ? CLUSTER_HOST_SUFFIX : ""));
|
||||
if (ret >= (int)sizeof(iface_hostname))
|
||||
{
|
||||
elog("%s hostname is too long ; truncated. interface_type: %d",
|
||||
hostname, interface_type);
|
||||
}
|
||||
|
||||
struct addrinfo *res = NULL;
|
||||
int ret = getaddrinfo(iface_hostname, NULL, NULL, &res);
|
||||
ret = getaddrinfo(iface_hostname, NULL, NULL, &res);
|
||||
if(ret)
|
||||
{
|
||||
elog("%s ip address resolution failed (err: %s)",
|
||||
|
|
Loading…
Reference in New Issue