Change OICFree to NSOICFree in notification 99/20899/6
authorjake <jaehong2.lee@samsung.com>
Tue, 28 Mar 2017 05:53:21 +0000 (14:53 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 27 Oct 2017 01:56:13 +0000 (01:56 +0000)
 - Be used OICFree without NULL checking.

[Philippe Coval]

Conflicts:
service/notification/src/provider/NSProviderSubscription.c

Change-Id: I1ce65d0e41a3b9f276a2b517d7b3d1c06faa92e6
Signed-off-by: jake <jaehong2.lee@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/18239
Reviewed-by: JungYong KIM <jyong2.kim@samsung.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Phil Coval <philippe.coval@osg.samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
(cherry picked from commit acbf9ffd474b3151a1fc5ea6337b4ad53cc1a081)

service/notification/src/provider/NSProviderCallbackResponse.c
service/notification/src/provider/NSProviderDiscovery.c
service/notification/src/provider/NSProviderInterface.c
service/notification/src/provider/NSProviderListener.c
service/notification/src/provider/NSProviderMemoryCache.c
service/notification/src/provider/NSProviderNotification.c
service/notification/src/provider/NSProviderScheduler.c
service/notification/src/provider/NSProviderSubscription.c
service/notification/src/provider/NSProviderSystem.c
service/notification/src/provider/NSProviderTopic.c

index 6c60c04..e702bab 100644 (file)
@@ -99,7 +99,7 @@ void * NSCallbackResponseSchedule(void * ptr)
                         NSSubscribeRequestCb(consumer);\r
                     }\r
 \r
-                    OICFree(copyQuery);\r
+                    NSOICFree(copyQuery);\r
                     NSFreeConsumer(consumer);\r
                     NSFreeOCEntityHandlerRequest(request);\r
 \r
@@ -117,7 +117,7 @@ void * NSCallbackResponseSchedule(void * ptr)
                     NS_LOG(DEBUG, "No Task Type");\r
                     break;\r
             }\r
-            OICFree(node);\r
+            NSOICFree(node);\r
         }\r
 \r
         pthread_mutex_unlock(&NSMutex[CALLBACK_RESPONSE_SCHEDULER]);\r
index f59ba77..9452103 100644 (file)
@@ -89,7 +89,7 @@ void * NSDiscoverySchedule(void * ptr)
                     break;\r
             }\r
 \r
-            OICFree(node);\r
+            NSOICFree(node);\r
         }\r
 \r
         pthread_mutex_unlock(&NSMutex[DISCOVERY_SCHEDULER]);\r
index 0c8ab81..a670fe1 100644 (file)
@@ -343,7 +343,7 @@ NSTopicLL * NSProviderGetConsumerTopics(const char * consumerId)
 
     NSPushQueue(TOPIC_SCHEDULER, TAST_GET_CONSUMER_TOPICS, &topicSync);
     pthread_cond_wait(topicSync.condition, &nsInitMutex);
-    OICFree(topicSync.consumerId);
+    NSOICFree(topicSync.consumerId);
 
     pthread_mutex_unlock(&nsInitMutex);
     NS_LOG(DEBUG, "NSProviderGetConsumerTopics - OUT");
@@ -432,7 +432,7 @@ NSResult NSProviderUnregisterTopic(const char * topicName)
         pthread_mutex_unlock(&nsInitMutex);
         return NS_FAIL;
     }
-    OICFree(topicSyncResult.topicData);
+    NSOICFree(topicSyncResult.topicData);
 
     pthread_mutex_unlock(&nsInitMutex);
     NS_LOG(DEBUG, "NSProviderDeleteTopics - OUT");
index 72bb081..b6e7872 100644 (file)
@@ -56,11 +56,11 @@ OCEntityHandlerResult NSEntityHandlerNotificationCb(OCEntityHandlerFlag flag,
                     && strcmp(reqInterface, NS_INTERFACE_READ) != 0)\r
             {\r
                 NS_LOG(ERROR, "Invalid interface");\r
-                OICFree(copyQuery);\r
+                NSOICFree(copyQuery);\r
                 return ehResult;\r
             }\r
 \r
-            OICFree(copyQuery);\r
+            NSOICFree(copyQuery);\r
             NSPushQueue(SUBSCRIPTION_SCHEDULER, TASK_SEND_POLICY,\r
                     NSCopyOCEntityHandlerRequest(entityHandlerRequest));\r
 \r
@@ -104,7 +104,7 @@ OCEntityHandlerResult NSEntityHandlerMessageCb(OCEntityHandlerFlag flag,
 \r
             char * copyQuery = OICStrdup(entityHandlerRequest->query);\r
             reqInterface = OICStrdup(NSGetValueFromQuery(copyQuery, NS_QUERY_INTERFACE));\r
-            OICFree(copyQuery);\r
+            NSOICFree(copyQuery);\r
 \r
             if (reqInterface && strcmp(reqInterface, NS_INTERFACE_BASELINE) != 0\r
                     && strcmp(reqInterface, NS_INTERFACE_READ) != 0)\r
@@ -150,7 +150,7 @@ OCEntityHandlerResult NSEntityHandlerMessageCb(OCEntityHandlerFlag flag,
 \r
     ehResult = NSProviderSendResponse(entityHandlerRequest, payload, reqInterface, ehResult,\r
             NS_INTERFACE_TYPE_READ, NS_RESOURCE_MESSAGE);\r
-    OICFree(reqInterface);\r
+    NSOICFree(reqInterface);\r
     NS_LOG(DEBUG, "NSEntityHandlerMessageCb - OUT");\r
     return ehResult;\r
 }\r
@@ -180,7 +180,7 @@ OCEntityHandlerResult NSEntityHandlerSyncCb(OCEntityHandlerFlag flag,
 \r
             char * copyQuery = OICStrdup(entityHandlerRequest->query);\r
             reqInterface = OICStrdup(NSGetValueFromQuery(copyQuery, NS_QUERY_INTERFACE));\r
-            OICFree(copyQuery);\r
+            NSOICFree(copyQuery);\r
 \r
             if (reqInterface && strcmp(reqInterface, NS_INTERFACE_BASELINE) != 0\r
                     && strcmp(reqInterface, NS_INTERFACE_READWRITE) != 0)\r
@@ -244,7 +244,7 @@ OCEntityHandlerResult NSEntityHandlerSyncCb(OCEntityHandlerFlag flag,
 \r
     ehResult = NSProviderSendResponse(entityHandlerRequest, payload, reqInterface, ehResult,\r
             NS_INTERFACE_TYPE_READ, NS_RESOURCE_MESSAGE);\r
-    OICFree(reqInterface);\r
+    NSOICFree(reqInterface);\r
 \r
     return ehResult;\r
 }\r
@@ -275,7 +275,7 @@ OCEntityHandlerResult NSEntityHandlerTopicCb(OCEntityHandlerFlag flag,
 \r
             char * copyReq = OICStrdup(entityHandlerRequest->query);\r
             reqInterface = OICStrdup(NSGetValueFromQuery(copyReq, NS_QUERY_INTERFACE));\r
-            OICFree(copyReq);\r
+            NSOICFree(copyReq);\r
 \r
             if (reqInterface && strcmp(reqInterface, NS_INTERFACE_BASELINE) != 0\r
                     && strcmp(reqInterface, NS_INTERFACE_READWRITE) != 0)\r
@@ -319,7 +319,7 @@ OCEntityHandlerResult NSEntityHandlerTopicCb(OCEntityHandlerFlag flag,
     NS_LOG(DEBUG, "NSEntityHandlerTopicCb - OUT");\r
     ehResult = NSProviderSendResponse(entityHandlerRequest, payload, reqInterface, ehResult,\r
             NS_INTERFACE_TYPE_READWRITE, NS_RESOURCE_TOPIC);\r
-    OICFree(reqInterface);\r
+    NSOICFree(reqInterface);\r
     return ehResult;\r
 }\r
 \r
@@ -372,7 +372,7 @@ OCStackApplicationResult NSProviderMQListener(void * ctx, OCDoHandle handle,
             NSSyncInfo * syncInfo = (NSSyncInfo *)OICMalloc(sizeof(NSSyncInfo));\r
             syncInfo->state = (type == NS_MESSAGE_READ) ? NS_SYNC_READ : NS_SYNC_DELETED;\r
             OICStrcpy(syncInfo->providerId, NS_UUID_STRING_SIZE, pId);\r
-            OICFree(pId);\r
+            NSOICFree(pId);\r
             NSPushQueue(NOTIFICATION_SCHEDULER, TASK_RECV_READ, (void*) syncInfo);\r
         }\r
     }\r
index fc7f5f6..950dcdf 100644 (file)
@@ -26,9 +26,9 @@
         if (it) \\r
         { \\r
             NS_LOG(DEBUG, "already registered for topic name"); \\r
-            OICFree(topicData->topicName); \\r
-            OICFree(topicData); \\r
-            OICFree(newObj); \\r
+            NSOICFree(topicData->topicName); \\r
+            NSOICFree(topicData); \\r
+            NSOICFree(newObj); \\r
             pthread_mutex_unlock(&NSCacheMutex); \\r
             return NS_FAIL; \\r
         } \\r
@@ -183,8 +183,8 @@ NSResult NSProviderStorageWrite(NSCacheList * list, NSCacheElement * newObj)
                 }\r
 \r
                 NS_LOG(DEBUG, "Update Data - OUT");\r
-                OICFree(subData);\r
-                OICFree(newObj);\r
+                NSOICFree(subData);\r
+                NSOICFree(newObj);\r
                 pthread_mutex_unlock(&NSCacheMutex);\r
                 return NS_OK;\r
             }\r
@@ -243,11 +243,11 @@ NSResult NSProviderStorageDestroy(NSCacheList * list)
     {\r
         next = (NSCacheElement *) iter->next;\r
         NSProviderDeleteCacheData(type, iter->data);\r
-        OICFree(iter);\r
+        NSOICFree(iter);\r
         iter = next;\r
     }\r
 \r
-    OICFree(list);\r
+    NSOICFree(list);\r
     return NS_OK;\r
 }\r
 \r
@@ -362,7 +362,7 @@ NSResult NSProviderDeleteCacheData(NSCacheType type, void * data)
         NSCacheSubData * subData = (NSCacheSubData *) data;\r
 \r
         (subData->id)[0] = '\0';\r
-        OICFree(subData);\r
+        NSOICFree(subData);\r
         return NS_OK;\r
     }\r
     else if (type == NS_PROVIDER_CACHE_REGISTER_TOPIC)\r
@@ -372,15 +372,15 @@ NSResult NSProviderDeleteCacheData(NSCacheType type, void * data)
         NS_LOG_V(DEBUG, "topicData->topicName = %s, topicData->state = %d", topicData->topicName,\r
                 (int)topicData->state);\r
 \r
-        OICFree(topicData->topicName);\r
-        OICFree(topicData);\r
+        NSOICFree(topicData->topicName);\r
+        NSOICFree(topicData);\r
     }\r
     else if (type == NS_PROVIDER_CACHE_CONSUMER_TOPIC_NAME ||\r
             type == NS_PROVIDER_CACHE_CONSUMER_TOPIC_CID)\r
     {\r
         NSCacheTopicSubData * topicData = (NSCacheTopicSubData *) data;\r
-        OICFree(topicData->topicName);\r
-        OICFree(topicData);\r
+        NSOICFree(topicData->topicName);\r
+        NSOICFree(topicData);\r
     }\r
 \r
     return NS_OK;\r
@@ -412,7 +412,7 @@ NSResult NSProviderStorageDelete(NSCacheList * list, const char * delId)
 \r
             list->head = del->next;\r
             NSProviderDeleteCacheData(type, del->data);\r
-            OICFree(del);\r
+            NSOICFree(del);\r
             pthread_mutex_unlock(&NSCacheMutex);\r
             return NS_OK;\r
         }\r
@@ -431,7 +431,7 @@ NSResult NSProviderStorageDelete(NSCacheList * list, const char * delId)
 \r
             prev->next = del->next;\r
             NSProviderDeleteCacheData(type, del->data);\r
-            OICFree(del);\r
+            NSOICFree(del);\r
             pthread_mutex_unlock(&NSCacheMutex);\r
             return NS_OK;\r
         }\r
@@ -617,7 +617,7 @@ NSResult NSProviderDeleteConsumerTopic(NSCacheList * conTopicList,
 \r
             conTopicList->head = del->next;\r
             NSProviderDeleteCacheData(type, del->data);\r
-            OICFree(del);\r
+            NSOICFree(del);\r
             pthread_mutex_unlock(&NSCacheMutex);\r
             return NS_OK;\r
         }\r
@@ -639,7 +639,7 @@ NSResult NSProviderDeleteConsumerTopic(NSCacheList * conTopicList,
 \r
             prev->next = del->next;\r
             NSProviderDeleteCacheData(type, del->data);\r
-            OICFree(del);\r
+            NSOICFree(del);\r
             pthread_mutex_unlock(&NSCacheMutex);\r
             return NS_OK;\r
         }\r
index 648f0a6..36770d0 100644 (file)
@@ -339,7 +339,7 @@ void * NSNotificationSchedule(void *ptr)
                     break;
 
             }
-            OICFree(node);
+            NSOICFree(node);
         }
 
         pthread_mutex_unlock(&NSMutex[NOTIFICATION_SCHEDULER]);
index 7803938..5495b78 100644 (file)
@@ -133,7 +133,7 @@ bool NSStopScheduler()
             NSTask* temp = NSHeadMsg[i];\r
             NSHeadMsg[i] = NSHeadMsg[i]->nextTask;\r
             NSFreeData(i, temp);\r
-            OICFree(temp);\r
+            NSOICFree(temp);\r
         }\r
 \r
         NSTailMsg[i] = NSHeadMsg[i] = NULL;\r
@@ -277,14 +277,14 @@ void NSFreeData(NSSchedulerType type, NSTask * task)
             case TASK_UNSUBSCRIBE_TOPIC:\r
             {\r
                 NSCacheTopicSubData * data = task->taskData;\r
-                OICFree(data->topicName);\r
-                OICFree(data);\r
+                NSOICFree(data->topicName);\r
+                NSOICFree(data);\r
             }\r
                 break;\r
             case TASK_REGISTER_TOPIC:\r
             case TASK_UNREGISTER_TOPIC:\r
             {\r
-                OICFree(task->taskData);\r
+                NSOICFree(task->taskData);\r
             }\r
                 break;\r
             case TASK_SEND_TOPICS:\r
index 87d6e14..b186599 100644 (file)
@@ -91,7 +91,7 @@ NSResult NSSendAccessPolicyResponse(OCEntityHandlerRequest *entityHandlerRequest
         OCResourcePayloadAddStringLL(&payload->types, NS_ROOT_TYPE);\r
     }\r
 \r
-    OICFree(copyReq);\r
+    NSOICFree(copyReq);\r
     OCRepPayloadSetUri(payload, NS_ROOT_URI);\r
     OCRepPayloadSetPropString(payload, NS_ATTRIBUTE_PROVIDER_ID, NSGetProviderInfo()->providerId);\r
     OCRepPayloadSetPropString(payload, NS_ATTRIBUTE_VERSION, VERSION);\r
@@ -129,7 +129,7 @@ void NSHandleSubscription(OCEntityHandlerRequest *entityHandlerRequest, NSResour
 \r
     if (!id)\r
     {\r
-        OICFree(copyReq);\r
+        NSOICFree(copyReq);\r
         NSFreeOCEntityHandlerRequest(entityHandlerRequest);\r
         NS_LOG(ERROR, "Invalid ConsumerID");\r
         return;\r
@@ -214,7 +214,7 @@ void NSHandleSubscription(OCEntityHandlerRequest *entityHandlerRequest, NSResour
 \r
         NSFreeOCEntityHandlerRequest(entityHandlerRequest);\r
     }\r
-    OICFree(copyReq);\r
+    NSOICFree(copyReq);\r
 \r
     NS_LOG(DEBUG, "NSHandleSubscription - OUT");\r
 }\r
@@ -306,7 +306,7 @@ NSResult NSSendConsumerSubResponse(OCEntityHandlerRequest * entityHandlerRequest
 \r
     if (!id)\r
     {\r
-        OICFree(copyReq);\r
+        NSOICFree(copyReq);\r
         NSFreeOCEntityHandlerRequest(entityHandlerRequest);\r
         NS_LOG(ERROR, "Invalid ConsumerID");\r
         return NS_ERROR;\r
@@ -314,7 +314,7 @@ NSResult NSSendConsumerSubResponse(OCEntityHandlerRequest * entityHandlerRequest
 \r
     NSCacheUpdateSubScriptionState(consumerSubList, id, true);\r
     NSSendResponse(id, true);\r
-    OICFree(copyReq);\r
+    NSOICFree(copyReq);\r
     NSFreeOCEntityHandlerRequest(entityHandlerRequest);\r
     NS_LOG(DEBUG, "NSSendSubscriptionResponse - OUT");\r
     return NS_OK;\r
@@ -332,7 +332,6 @@ void NSProviderMQSubscription(NSMQTopicAddress * topicAddr)
     OCCallbackData cbdata = { NULL, NULL, NULL };\r
     cbdata.cb = NSProviderGetMQResponseCB;\r
     cbdata.context = OICStrdup(topicName);\r
-\r
     char requestUri[100] = "coap+tcp://";\r
 \r
     NS_LOG_V(DEBUG, "requestUri1 = %s", requestUri);\r
@@ -345,9 +344,9 @@ void NSProviderMQSubscription(NSMQTopicAddress * topicAddr)
 \r
     NSOCResultToSuccess(ret);\r
 \r
-    OICFree(topicAddr->serverAddr);\r
-    OICFree(topicAddr->topicName);\r
-    OICFree(topicAddr);\r
+    NSOICFree(topicAddr->serverAddr);\r
+    NSOICFree(topicAddr->topicName);\r
+    NSOICFree(topicAddr);\r
 }\r
 #endif\r
 \r
@@ -393,7 +392,7 @@ void * NSSubScriptionSchedule(void *ptr)
 \r
                     NSCacheUpdateSubScriptionState(consumerSubList, consumerId, true);\r
                     NSSendResponse(consumerId, true);\r
-                    OICFree(consumerId);\r
+                    NSOICFree(consumerId);\r
                     break;\r
                 }\r
                 case TASK_SEND_DENY:\r
@@ -403,7 +402,7 @@ void * NSSubScriptionSchedule(void *ptr)
 \r
                     NSCacheUpdateSubScriptionState(consumerSubList, consumerId, false);\r
                     NSSendResponse(consumerId, false);\r
-                    OICFree(consumerId);\r
+                    NSOICFree(consumerId);\r
 \r
                     break;\r
                 }\r
@@ -422,7 +421,7 @@ void * NSSubScriptionSchedule(void *ptr)
                     break;\r
 \r
             }\r
-            OICFree(node);\r
+            NSOICFree(node);\r
         }\r
 \r
         pthread_mutex_unlock(&NSMutex[SUBSCRIPTION_SCHEDULER]);\r
index b47f445..f2bb213 100644 (file)
@@ -73,17 +73,17 @@ void NSDeinitProviderInfo()
 \r
     if (providerInfo->providerName)\r
     {\r
-        OICFree(providerInfo->providerName);\r
+        NSOICFree(providerInfo->providerName);\r
         providerInfo->providerName = NULL;\r
     }\r
 \r
     if (providerInfo->userInfo)\r
     {\r
-        OICFree(providerInfo->userInfo);\r
+        NSOICFree(providerInfo->userInfo);\r
         providerInfo->userInfo = NULL;\r
     }\r
 \r
-    OICFree(providerInfo);\r
+    NSOICFree(providerInfo);\r
     providerInfo = NULL;\r
 }\r
 \r
index c3d0797..a32f7d7 100644 (file)
@@ -73,8 +73,8 @@ NSResult NSRegisterTopic(const char * topicName)
     NSCacheElement * element = (NSCacheElement *) OICMalloc(sizeof(NSCacheElement));
     if (!element)
     {
-        OICFree(data->topicName);
-        OICFree(data);
+        NSOICFree(data->topicName);
+        NSOICFree(data);
         return NS_FAIL;
     }
 
@@ -265,7 +265,7 @@ NSResult NSSendTopicList(OCEntityHandlerRequest * entityHandlerRequest)
     if (!payload)
     {
         NS_LOG(ERROR, "payload is NULL");
-        OICFree(copyReq);
+        NSOICFree(copyReq);
         return NS_ERROR;
     }
 
@@ -275,7 +275,7 @@ NSResult NSSendTopicList(OCEntityHandlerRequest * entityHandlerRequest)
         OCRepPayloadSetPropString(payload, NS_ATTRIBUTE_CONSUMER_ID, id);
     }
     OCRepPayloadSetPropString(payload, NS_ATTRIBUTE_PROVIDER_ID, NSGetProviderInfo()->providerId);
-    OICFree(copyReq);
+    NSOICFree(copyReq);
 
     if (topics)
     {
@@ -307,8 +307,8 @@ NSResult NSSendTopicList(OCEntityHandlerRequest * entityHandlerRequest)
                     (int) topics->state);
 
             NSTopicLL * next = topics->next;
-            OICFree(topics->topicName);
-            OICFree(topics);
+            NSOICFree(topics->topicName);
+            NSOICFree(topics);
             topics = next;
         }
 
@@ -318,7 +318,7 @@ NSResult NSSendTopicList(OCEntityHandlerRequest * entityHandlerRequest)
         {
             OCRepPayloadDestroy(payloadTopicArray[i]);
         }
-        OICFree(payloadTopicArray);
+        NSOICFree(payloadTopicArray);
     }
     else
     {
@@ -338,7 +338,7 @@ NSResult NSSendTopicList(OCEntityHandlerRequest * entityHandlerRequest)
         OCResourcePayloadAddStringLL(&payload->types, NS_ROOT_TYPE);
     }
 
-    OICFree(copyReq);
+    NSOICFree(copyReq);
     response.requestHandle = entityHandlerRequest->requestHandle;
     response.resourceHandle = entityHandlerRequest->resource;
     response.persistentBufferFlag = 0;
@@ -409,9 +409,9 @@ NSResult NSPostConsumerTopics(OCEntityHandlerRequest * entityHandlerRequest)
 
             if (!newObj)
             {
-                OICFree(topicSubData->topicName);
-                OICFree(topicSubData);
-                OICFree(consumerId);
+                NSOICFree(topicSubData->topicName);
+                NSOICFree(topicSubData);
+                NSOICFree(consumerId);
                 return NS_FAIL;
             }
 
@@ -422,7 +422,7 @@ NSResult NSPostConsumerTopics(OCEntityHandlerRequest * entityHandlerRequest)
         }
     }
     NSSendTopicUpdationToConsumer(consumerId);
-    OICFree(consumerId);
+    NSOICFree(consumerId);
     NS_LOG(DEBUG, "NSPostConsumerTopics() - OUT");
     return NS_OK;
 }
@@ -461,8 +461,8 @@ void * NSTopicSchedule(void * ptr)
                             (NSCacheTopicSubData *) topicSyncResult->topicData;
                     if (!newObj)
                     {
-                        OICFree(subData->topicName);
-                        OICFree(subData);
+                        NSOICFree(subData->topicName);
+                        NSOICFree(subData);
                         pthread_cond_signal(topicSyncResult->condition);
                         pthread_mutex_unlock(topicSyncResult->mutex);
                     }
@@ -481,9 +481,9 @@ void * NSTopicSchedule(void * ptr)
                         }
                         else
                         {
-                            OICFree(subData->topicName);
-                            OICFree(subData);
-                            OICFree(newObj);
+                            NSOICFree(subData->topicName);
+                            NSOICFree(subData);
+                            NSOICFree(newObj);
                         }
                     }
                     pthread_cond_signal(topicSyncResult->condition);
@@ -504,8 +504,8 @@ void * NSTopicSchedule(void * ptr)
                         topicSyncResult->result = NS_OK;
                     }
 
-                    OICFree(topicSubData->topicName);
-                    OICFree(topicSubData);
+                    NSOICFree(topicSubData->topicName);
+                    NSOICFree(topicSubData);
                     pthread_cond_signal(topicSyncResult->condition);
                     pthread_mutex_unlock(topicSyncResult->mutex);
 
@@ -569,7 +569,7 @@ void * NSTopicSchedule(void * ptr)
                     break;
             }
 
-            OICFree(node);
+            NSOICFree(node);
         }
 
         pthread_mutex_unlock(&NSMutex[TOPIC_SCHEDULER]);