csdk: Fixes cppcheck issue in security dir.
authorRavi Nanjundappa <nravi.n@samsung.com>
Wed, 1 Jul 2015 13:41:29 +0000 (19:11 +0530)
committerErich Keane <erich.keane@intel.com>
Fri, 10 Jul 2015 19:13:37 +0000 (19:13 +0000)
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 <nravi.n@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1508
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sachin Agrawal <sachin.agrawal@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/security/src/doxmresource.c
resource/csdk/security/unittest/aclresourcetest.cpp

index 405ccc6..a9a9696 100755 (executable)
@@ -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])
index 0e6f5b7..5608e16 100644 (file)
@@ -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);