Commit 511c683f authored by Jaewook Jung's avatar Jaewook Jung Committed by Uze Choi

Fix a defect detected by static code analyzer

 - remove a unreachable code
 - add a NULL checking before strcmp()

Change-Id: I459e1ab232d10affd0c0e8b1cbea340ca11fb9a2
Signed-off-by: default avatarJaewook Jung <jw0213.jung@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18967Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: default avatarDan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
parent d3af39f0
......@@ -281,7 +281,6 @@ static OCStackResult OCCMFindResource()
{
OIC_LOG_V(INFO, TAG, "%s", __func__);
OCQualityOfService qos = OC_LOW_QOS;
char szQueryUri[MAX_QUERY_LENGTH] = { 0 };
snprintf(szQueryUri, sizeof(szQueryUri) - 1, "%s%c", OC_RSRVD_WELL_KNOWN_URI, '\0');
......@@ -292,8 +291,7 @@ static OCStackResult OCCMFindResource()
OCStackResult ret = OCDoResource(NULL, OC_REST_DISCOVER, szQueryUri,
NULL, 0, CT_DEFAULT | CT_IP_USE_V4,
(qos == OC_HIGH_QOS) ? OC_HIGH_QOS : OC_LOW_QOS,
&cbData, NULL, 0);
OC_LOW_QOS, &cbData, NULL, 0);
if (OC_STACK_OK != ret)
{
OIC_LOG(ERROR, TAG, "OCStack resource error");
......
......@@ -423,7 +423,13 @@ static int64_t OCConvertDiscoveryPayloadCbor(OCDiscoveryPayload *payload,
err |= cbor_encoder_create_array(&rootMap, &linkArray, CborIndefiniteLength);
VERIFY_CBOR_SUCCESS(TAG, err, "Failed setting links array");
bool isSelf = !strcmp(payload->sid, OCGetServerInstanceIDString());
bool isSelf = false;
const char *deviceId = OCGetServerInstanceIDString();
if (NULL != deviceId)
{
isSelf = !strcmp(payload->sid, deviceId);
}
for (size_t i = 0; i < resourceCount; ++i)
{
OCResourcePayload *resource = OCDiscoveryPayloadGetResource(payload, i);
......
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