From 31d384897fe9ac3366f101cb3f40db087de4b4a3 Mon Sep 17 00:00:00 2001 From: Ravi Nanjundappa Date: Wed, 1 Jul 2015 19:11:29 +0530 Subject: [PATCH] csdk: Fixes cppcheck issue in security dir. This patch fixes the the below issue reported by cppcheck tool in security dir: "(error) Possible null pointer dereference: jsonObj - otherwise it is redundant to check if jsonObj is null at line 259 (error) Possible null pointer dereference: jsonStr1 - otherwise it is redundant to check if jsonStr1 is null at line 132" Null value check of jsonObj and jsonStr1 are removed as it in unnecessary here. Change-Id: I6c0676a58780afea3026c3e1332c8ecac7c0dd1e Signed-off-by: Ravi Nanjundappa Reviewed-on: https://gerrit.iotivity.org/gerrit/1508 Tested-by: jenkins-iotivity Reviewed-by: Sachin Agrawal Reviewed-by: Erich Keane --- resource/csdk/security/src/doxmresource.c | 2 +- resource/csdk/security/unittest/aclresourcetest.cpp | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/resource/csdk/security/src/doxmresource.c b/resource/csdk/security/src/doxmresource.c index 405ccc6..a9a9696 100755 --- a/resource/csdk/security/src/doxmresource.c +++ b/resource/csdk/security/src/doxmresource.c @@ -256,7 +256,7 @@ OicSecDoxm_t * JSONToDoxmBin(const char * jsonStr) if(jsonObj) { VERIFY_SUCCESS(TAG, cJSON_String == jsonObj->type, ERROR); - if(jsonObj && cJSON_String == jsonObj->type) + if(cJSON_String == jsonObj->type) { //Check for empty string, in case DeviceId field has not been set yet if (jsonObj->valuestring[0]) diff --git a/resource/csdk/security/unittest/aclresourcetest.cpp b/resource/csdk/security/unittest/aclresourcetest.cpp index 0e6f5b7..5608e16 100644 --- a/resource/csdk/security/unittest/aclresourcetest.cpp +++ b/resource/csdk/security/unittest/aclresourcetest.cpp @@ -129,10 +129,7 @@ TEST(ACLResourceTest, JSONMarshallingTests) char * jsonStr2 = BinToAclJSON(acl); EXPECT_TRUE(NULL != jsonStr2); - if (jsonStr1 && jsonStr2) - { - EXPECT_STREQ(jsonStr1, jsonStr2); - } + EXPECT_STREQ(jsonStr1, jsonStr2); OICFree(jsonStr1); OICFree(jsonStr2); -- 2.7.4