Fixed SDOCM00115772 plus some formatting changes
authorJustin Sobota <jsobota@ti.com>
Tue, 2 Jun 2015 14:53:48 +0000 (10:53 -0400)
committerJustin Sobota <jsobota@ti.com>
Tue, 2 Jun 2015 14:53:48 +0000 (10:53 -0400)
src/rm_services.c

index 26f1743c6e0bca247a6a98186c4b788d55c7bc3d..6bedf7b861c3da8f331526604d81ad896f2760c5 100644 (file)
@@ -101,47 +101,48 @@ void Rm_serviceHandler (void *rmHandle, const Rm_ServiceReqInfo *serviceRequest,
     if (rmInst->mtSemObj) {
         mtKey = Rm_osalMtCsEnter(rmInst->mtSemObj);
     }
-    
+
     if (rmInst->isLocked) {
         serviceResponse->serviceState = RM_SERVICE_DENIED_RM_INSTANCE_LOCKED;
-        return;
+        goto errorExit;
     }
 
     if (serviceRequest->type >= Rm_service_LAST) {
         serviceResponse->serviceState = RM_ERROR_INVALID_SERVICE_TYPE;
-        return;
+        goto errorExit;
     }
 
     if (serviceRequest->resourceName) {
         if ((strlen(serviceRequest->resourceName) + 1) > RM_NAME_MAX_CHARS) {
             serviceResponse->serviceState = RM_ERROR_RESOURCE_NAME_TOO_LONG;
-            return;
+            goto errorExit;
         }
     }
 
     if (serviceRequest->resourceNsName) {
         if ((strlen(serviceRequest->resourceNsName) + 1) > RM_NAME_MAX_CHARS) {
             serviceResponse->serviceState = RM_ERROR_NAMESERVER_NAME_TOO_LONG;
-            return;
+            goto errorExit;
         }
     }
 
-    /* Copy location of instance name to local variable in case Shared Client needs to
-     * transfer control to a shared server */
+    /* Copy location of instance name to local variable in case Shared Client
+     * needs to transfer control to a shared server */
     instanceName = rmInst->instName;
     if (rmInst->instType == Rm_instType_SHARED_CLIENT) {
         /* Transfer control to shared server instance */
         rmInst = rmInst->u.sharedClient.sharedServerHandle;
-    }       
-    
-    transaction = rmTransactionQueueAdd(rmInst);
-    if (transaction) {
+    }
+
+    if (transaction = rmTransactionQueueAdd(rmInst)) {
         transaction->type = serviceRequest->type;
-        rm_strncpy(transaction->serviceSrcInstName, instanceName, RM_NAME_MAX_CHARS);
+        rm_strncpy(transaction->serviceSrcInstName, instanceName,
+                   RM_NAME_MAX_CHARS);
         transaction->u.callback.serviceCallback = serviceRequest->callback.serviceCallback;
         transaction->state = RM_SERVICE_PROCESSING;
         if (serviceRequest->resourceName) {
-            rm_strncpy(transaction->resourceInfo.name, serviceRequest->resourceName, RM_NAME_MAX_CHARS);
+            rm_strncpy(transaction->resourceInfo.name,
+                       serviceRequest->resourceName, RM_NAME_MAX_CHARS);
         }
         transaction->resourceInfo.base = serviceRequest->resourceBase;
         transaction->resourceInfo.length = serviceRequest->resourceLength;
@@ -149,12 +150,13 @@ void Rm_serviceHandler (void *rmHandle, const Rm_ServiceReqInfo *serviceRequest,
         transaction->resourceInfo.ownerCount = RM_RESOURCE_NUM_OWNERS_INVALID;
         transaction->resourceInfo.instAllocCount = RM_INST_ALLOC_COUNT_INVALID;
         if (serviceRequest->resourceNsName) {
-            rm_strncpy(transaction->resourceInfo.nameServerName, serviceRequest->resourceNsName, RM_NAME_MAX_CHARS);
+            rm_strncpy(transaction->resourceInfo.nameServerName,
+                       serviceRequest->resourceNsName, RM_NAME_MAX_CHARS);
         }
 
         /* Process received transaction */
         rmProcessRouter(rmInst, transaction);
-            
+
         memset((void *)serviceResponse, 0, sizeof(*serviceResponse));
 
         if ((rmInst->instType == Rm_instType_SHARED_SERVER) && 
@@ -162,53 +164,62 @@ void Rm_serviceHandler (void *rmHandle, const Rm_ServiceReqInfo *serviceRequest,
             /* Shared Server should always return a fully processed transaction */
             serviceResponse->serviceState = RM_ERROR_SHARED_INSTANCE_UNFINISHED_REQ;
             rmTransactionQueueDelete(rmInst, transaction->localId);
-        }
-        else {
+        } else {
             if ((transaction->state == RM_SERVICE_PROCESSING) && 
                 (transaction->u.callback.serviceCallback == NULL)) {
-                /* Block until response is received.  Response will be received in transaction. */
+                /* Block until response is received.  Response will be
+                 * received in transaction. */
                 Rm_osalTaskBlock(rmInst->blockHandle);
             }
 
             serviceResponse->rmHandle = rmHandle;
             serviceResponse->serviceState = transaction->state;
-            /* Owner and instance allocation count will only be set within RM under certain circumstances. */
+            /* Owner and instance allocation count will only be set within RM
+             * under certain circumstances. */
             serviceResponse->resourceNumOwners = transaction->resourceInfo.ownerCount;
             serviceResponse->instAllocCount = transaction->resourceInfo.instAllocCount;
             if ((serviceResponse->serviceState == RM_SERVICE_PROCESSING) ||
                 (serviceResponse->serviceState == RM_SERVICE_APPROVED_STATIC) ||
-                (serviceResponse->serviceState == RM_SERVICE_PENDING_SERVER_RESPONSE)) {
-                /* Service still being processed.  Static requests will have their validation responses sent once
-                 * all transports have been established.  Provide transaction ID back to component so it can sort 
-                 * service responses received via callback function */
+                (serviceResponse->serviceState ==
+                 RM_SERVICE_PENDING_SERVER_RESPONSE)) {
+                /* Service still being processed.  Static requests will have
+                 * their validation responses sent once all transports have
+                 * been established.  Provide transaction ID back to component
+                 * so it can sort service responses received via callback
+                 * function */
                 serviceResponse->serviceId = transaction->localId;
             }
 
             if ((serviceResponse->serviceState == RM_SERVICE_APPROVED) ||
                 (serviceResponse->serviceState == RM_SERVICE_APPROVED_STATIC)) {
-                rm_strncpy(serviceResponse->resourceName, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
+                rm_strncpy(serviceResponse->resourceName,
+                           transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
                 serviceResponse->resourceBase = transaction->resourceInfo.base;
                 serviceResponse->resourceLength = transaction->resourceInfo.length;
             }
 
-            /* Transactions still processing not deleted from queue including static transactions which will be 
-             * verified once all transports are up */
+            /* Transactions still processing not deleted from queue including
+             * static transactions which will be verified once all transports
+             * are up */
             if ((serviceResponse->serviceState != RM_SERVICE_PROCESSING) &&
                 (serviceResponse->serviceState != RM_SERVICE_APPROVED_STATIC) &&
-                (serviceResponse->serviceState != RM_SERVICE_PENDING_SERVER_RESPONSE)) {
+                (serviceResponse->serviceState !=
+                 RM_SERVICE_PENDING_SERVER_RESPONSE)) {
                 rmTransactionQueueDelete(rmInst, transaction->localId);
             }
         }
-    }
-    else {
-        serviceResponse->serviceState = RM_ERROR_SERVICE_TRANS_NOT_CREATED;    
+    } else {
+        serviceResponse->serviceState = RM_ERROR_SERVICE_TRANS_NOT_CREATED;
     }
 
-    /* Free sem object using originating instance in case the Shared Client to Shared
-     * Server instance switch took place */
+errorExit:
+    /* Free sem object using originating instance in case the Shared Client to
+     * Shared Server instance switch took place */
     if (((Rm_Inst *)rmHandle)->mtSemObj) {
         Rm_osalMtCsExit(((Rm_Inst *)rmHandle)->mtSemObj, mtKey);
     }
+    /* Shared Client switches to Shared Server instance so only need
+     * SS_EXIT_CS macro */
     RM_SS_INST_WB_EXIT_CS(rmInst, key);
     return;
 }