Commit 28360f5e authored by jw1103.kim's avatar jw1103.kim Committed by Erich Keane

prevent defects resolved (removed not useful code)

dereferencing freed pointer, comparing an array to null

Change-Id: I9b9e49d39df8d4220c183bec0f8617b198a484a7
Signed-off-by: default avatarjw1103.kim <jw1103.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1038Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarErich Keane <erich.keane@intel.com>
parent 14986aad
......@@ -703,14 +703,9 @@ CAResult_t CAIPGetInterfaceSubnetMask(const char *ipAddress, char **subnetMask)
if (strncmp(info->ipAddress, ipAddress, strlen(ipAddress)) == 0)
{
if (!info->subnetMask)
{
OIC_LOG(ERROR, IP_MONITOR_TAG,
"CAIPGetInterfaceSubnetMask subnetmask is null");
}
OIC_LOG_V(DEBUG, IP_MONITOR_TAG,
"CAIPGetInterfaceSubnetMask subnetmask is %s", info->subnetMask);
*subnetMask = info->subnetMask ? OICStrdup(info->subnetMask) : NULL;
*subnetMask = OICStrdup(info->subnetMask);
break;
}
}
......
......@@ -421,7 +421,7 @@ CAResult_t CAStartIP()
for (listIndex = 0; listIndex < listLength; listIndex++)
{
CANetInfo_t *netInfo = (CANetInfo_t *) u_arraylist_get(netInterfaceList, listIndex);
if (!netInfo || !netInfo->ipAddress)
if (!netInfo)
{
continue;
}
......@@ -479,7 +479,7 @@ CAResult_t CAStartIPListeningServer()
{
CANetInfo_t *netInfo = (CANetInfo_t *) u_arraylist_get(netInterfaceList, listIndex);
if (!netInfo || !netInfo->ipAddress)
if (!netInfo)
{
continue;
}
......@@ -617,7 +617,7 @@ CAResult_t CAGetIPInterfaceInformation(CALocalConnectivity_t **info, uint32_t *s
for (listIndex = 0; listIndex < listLength; listIndex++)
{
CANetInfo_t *netInfo = (CANetInfo_t *) u_arraylist_get(netInterfaceList, listIndex);
if (!netInfo || !netInfo->ipAddress)
if (!netInfo)
{
continue;
}
......
......@@ -347,10 +347,6 @@ static CAResult_t CACreateSocket(int *socketFD, const char *localIp, uint16_t *p
{
sockAddr.sin_addr.s_addr = inet_addr(localIp);
}
else
{
sockAddr.sin_addr.s_addr = htonl(INADDR_ANY);
}
int16_t i = 0;
bool isBound = false;
......@@ -810,8 +806,7 @@ CAResult_t CAIPStopServer(const char *interfaceAddress)
}
CACloseSocket(info->socketFd);
OICFree(info);
OIC_LOG_V(DEBUG, IP_SERVER_TAG,
"Multicast server is stopped successfully on IF [%s]", info->ifAddr);
OIC_LOG(DEBUG, IP_SERVER_TAG, "Multicast server is stopped successfully.");
// Reduce list length by 1 as we removed one element.
listLength--;
}
......@@ -828,8 +823,7 @@ CAResult_t CAIPStopServer(const char *interfaceAddress)
{
CACloseSocket(info->socketFd);
OICFree(info);
OIC_LOG_V(DEBUG, IP_SERVER_TAG,
"Unicast server is stopped successfully on IF [%s]", info->ifAddr);
OIC_LOG(DEBUG, IP_SERVER_TAG, "Unicast server is stopped successfully.");
// Reduce list length by 1 as we removed one element.
listLength--;
}
......
......@@ -611,14 +611,9 @@ CAResult_t CAIPGetInterfaceSubnetMask(const char *ipAddress, char **subnetMask)
if (strncmp(info->ipAddress, ipAddress, strlen(ipAddress)) == 0)
{
if (!info->subnetMask)
{
OIC_LOG(ERROR, IP_MONITOR_TAG,
"CAIPGetInterfaceSubnetMask subnetmask is null");
}
OIC_LOG_V(DEBUG, IP_MONITOR_TAG,
"CAIPGetInterfaceSubnetMask subnetmask is %s", info->subnetMask);
*subnetMask = info->subnetMask ? OICStrdup(info->subnetMask) : NULL;
*subnetMask = OICStrdup(info->subnetMask);
break;
}
}
......
......@@ -593,14 +593,9 @@ CAResult_t CAIPGetInterfaceSubnetMask(const char *ipAddress, char **subnetMask)
if (strncmp(info->ipAddress, ipAddress, strlen(ipAddress)) == 0)
{
if (!info->subnetMask)
{
OIC_LOG(ERROR, IP_MONITOR_TAG,
"CAIPGetInterfaceSubnetMask subnetmask is null");
}
OIC_LOG_V(DEBUG, IP_MONITOR_TAG,
"CAIPGetInterfaceSubnetMask subnetmask is %s", info->subnetMask);
*subnetMask = info->subnetMask ? OICStrdup(info->subnetMask) : NULL;
*subnetMask = OICStrdup(info->subnetMask);
break;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment