Removed Dead FormOCResponse Code
authorErich Keane <erich.keane@intel.com>
Tue, 17 Mar 2015 21:05:51 +0000 (14:05 -0700)
committerSashi Penta <sashi.kumar.penta@intel.com>
Wed, 18 Mar 2015 20:50:50 +0000 (20:50 +0000)
The function FormOCResponse was previously only used in one place,
and had no side effects other than allocating memory and filling an
object with a bunch of different values.

The calling site (OCProcessPresence) only refers to the OCResponse
object in this single call, then leaks it immediately after.

This changeset removes the function, the variable, and the call to
this function.

Change-Id: Ic40440fce04343149528fb4d33f42f73da908171
Signed-off-by: Erich Keane <erich.keane@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/494
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sachin Agrawal <sachin.agrawal@intel.com>
Reviewed-by: Sudarshan Prasad <sudarshan.prasad@intel.com>
Reviewed-by: Sashi Penta <sashi.kumar.penta@intel.com>
resource/csdk/stack/src/ocstack.c

index 47eafdd..f8fb72a 100644 (file)
@@ -106,32 +106,6 @@ static uint32_t GetTime(float afterSeconds)
     return now + (uint32_t)(afterSeconds * COAP_TICKS_PER_SECOND);
 }
 
-static OCStackResult FormOCResponse(OCResponse * * responseLoc,
-                                    ClientCB * cbNode,
-                                    uint32_t maxAge,
-                                    char * fullUri,
-                                    char * rcvdUri,
-                                    CAToken_t * rcvdToken,
-                                    OCClientResponse * clientResponse,
-                                    char * bufRes)
-{
-    OCResponse * response = (OCResponse *) OCMalloc(sizeof(OCResponse));
-    if (!response)
-    {
-        return OC_STACK_NO_MEMORY;
-    }
-    response->cbNode = cbNode;
-    response->maxAge = maxAge;
-    response->fullUri = fullUri;
-    response->rcvdUri = rcvdUri;
-    response->rcvdToken = rcvdToken;
-    response->clientResponse = clientResponse;
-    response->bufRes = bufRes;
-
-    *responseLoc = response;
-    return OC_STACK_OK;
-}
-
 /// This method is used to create the IPv4 dev_addr structure.
 /// TODO: Remove in future. Temporary helper function.
 /// Builds a socket interface address using IP address and port number
@@ -1689,7 +1663,6 @@ OCStackResult OCProcessPresence()
     ClientCB* cbNode = NULL;
     OCDevAddr dst = {};
     OCClientResponse clientResponse ={};
-    OCResponse * response = NULL;
     OCStackApplicationResult cbResult = OC_STACK_DELETE_TRANSACTION;
 
     LL_FOREACH(cbList, cbNode)
@@ -1728,13 +1701,6 @@ OCStackResult OCProcessPresence()
                         clientResponse.addr = (OCDevAddr *) &dst;
                         clientResponse.resJSONPayload = NULL;
 
-                        result = FormOCResponse(&response, cbNode, 0, NULL, NULL,
-                                &cbNode->token, &clientResponse, NULL);
-                        if(result != OC_STACK_OK)
-                        {
-                            goto exit;
-                        }
-
                         // Increment the TTLLevel (going to a next state), so we don't keep
                         // sending presence notification to client.
                         cbNode->presence->TTLlevel++;