Coverity bug fixes
authorJustin Sobota <jsobota@ti.com>
Fri, 6 Jun 2014 19:15:10 +0000 (15:15 -0400)
committerJustin Sobota <jsobota@ti.com>
Fri, 6 Jun 2014 19:15:10 +0000 (15:15 -0400)
docs/ReleaseNotes_RM.doc
docs/ReleaseNotes_RM.pdf
include/rm_internal.h
src/rm.c
src/rm_allocator.c
src/rm_dtb_util.c
src/rm_nameserver.c
src/rm_policy.c
src/rm_services.c
src/rm_transport.c
src/rm_tree.c

index 0845b1d343b290a9358cf0da9e3e7689c463a82d..daca40fb121435e6c9ed946d6f5a1b212783ec7a 100644 (file)
Binary files a/docs/ReleaseNotes_RM.doc and b/docs/ReleaseNotes_RM.doc differ
index 2b24ed219460cb832a9548c491ab6b2b88a1cd3d..9b77d3b48406b840b5d20adf5e608f033b4cbb3d 100644 (file)
Binary files a/docs/ReleaseNotes_RM.pdf and b/docs/ReleaseNotes_RM.pdf differ
index ca7ca2a1e6802b779f61b896d35714c1eed6adf8..73eb7f8a8151812c56d1c3fbf22d164238eabec5 100644 (file)
@@ -44,6 +44,9 @@
 extern "C" {
 #endif
 
+/* Standard includes */
+#include <string.h>
+
 /* RM external includes */
 #include <ti/drv/rm/rm.h>
 
@@ -111,6 +114,13 @@ typedef struct {
     char     nameServerName[RM_NAME_MAX_CHARS];
 } Rm_ResourceInfo;
 
+/* wrapper to strncpy to avoid covery overrun warning */
+static inline void rm_strncpy (char *dst, const char *src, size_t len)
+{
+    strncpy (dst, src, len);
+    dst[len - 1] = 0;
+}
+
 #ifdef __cplusplus
 }
 #endif
index 8e0b191b8f8155015234631622f42dcf2eac546f..d58550f2bbf97611c980b53cc0c08ed1578579ff 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -41,7 +41,6 @@
 
 /* Standard includes */
 #include <stdint.h>
-#include <string.h>
 
 /* RM external includes */
 #include <ti/drv/rm/rm.h>
@@ -132,8 +131,8 @@ void createResourceReqPkt(Rm_Packet *rmPkt, char *localInstName, Rm_Transaction
     else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {
         resourceReqPkt->resourceReqType = Rm_resReqPktType_GET_NAMED;
     }
-    strncpy(resourceReqPkt->pktSrcInstName, localInstName, RM_NAME_MAX_CHARS);
-    strncpy(resourceReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);
+    rm_strncpy(resourceReqPkt->pktSrcInstName, localInstName, RM_NAME_MAX_CHARS);
+    rm_strncpy(resourceReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);
     memcpy ((void *)&(resourceReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),
             sizeof(Rm_ResourceInfo));
 }
@@ -179,8 +178,8 @@ void createNsRequestPkt(Rm_Packet *rmPkt, char *localInstName, Rm_Transaction *t
     else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {
         nsReqPkt->nsRequestType = Rm_nsReqPktType_UNMAP_RESOURCE;
     }
-    strncpy(nsReqPkt->pktSrcInstName, localInstName, RM_NAME_MAX_CHARS);
-    strncpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);
+    rm_strncpy(nsReqPkt->pktSrcInstName, localInstName, RM_NAME_MAX_CHARS);
+    rm_strncpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);
     memcpy ((void *)&(nsReqPkt->resourceInfo), (void *)&(transaction->resourceInfo),
             sizeof(Rm_ResourceInfo));
 }
@@ -233,7 +232,7 @@ static void serviceResponder (Rm_Inst *rmInst, Rm_Transaction *transaction)
          (transaction->type == Rm_service_RESOURCE_STATUS) ||
          (transaction->type == Rm_service_RESOURCE_GET_BY_NAME)))
     {
-        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;
     }
@@ -433,9 +432,9 @@ static int32_t cdRequestServerResources(Rm_Inst *rmInst, Rm_Transaction *transac
         if (allocSize = rmPolicyGetResourceCdAllocSize(policy, resourceOffsetInPolicy)) {
             if (newTrans = rmTransactionQueueAdd(rmInst)) {
                 newTrans->type = transaction->type;
-                strncpy(newTrans->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS);
+                rm_strncpy(newTrans->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS);
                 newTrans->state = RM_SERVICE_PROCESSING;       
-                strncpy(newTrans->resourceInfo.name, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
+                rm_strncpy(newTrans->resourceInfo.name, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
                 newTrans->resourceInfo.base = RM_RESOURCE_BASE_UNSPECIFIED;
                 /* Make sure request length will satisfy transaction length */
                 newTrans->resourceInfo.length = allocSize;
@@ -485,9 +484,9 @@ static int32_t cdFreeResourcesToServer(Rm_Inst *rmInst, Rm_Transaction *transact
                                        &baseToFree, &lenToFree)) {
         if (newTrans = rmTransactionQueueAdd(rmInst)) {
             newTrans->type = transaction->type;
-            strncpy(newTrans->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS);
+            rm_strncpy(newTrans->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS);
             newTrans->state = RM_SERVICE_PROCESSING;       
-            strncpy(newTrans->resourceInfo.name, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
+            rm_strncpy(newTrans->resourceInfo.name, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
             newTrans->resourceInfo.base = baseToFree;
             newTrans->resourceInfo.length = lenToFree;
             newTrans->pendingTransactionId = transaction->localId;
@@ -620,7 +619,7 @@ static void allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
             nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
             nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
             if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
-                strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
+                rm_strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
                 transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
                 transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
             }
@@ -714,7 +713,7 @@ static void statusHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
             nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
             nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
             if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
-                strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
+                rm_strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
                 transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
                 transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
             }
@@ -789,7 +788,7 @@ static void freeHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
             nameServerObjCfg.nameServerTree = rmInst->u.server.nameServer;
             nameServerObjCfg.nodeCfg.objName = transaction->resourceInfo.nameServerName;
             if ((retVal = rmNameServerFindObject(&nameServerObjCfg)) == RM_SERVICE_PROCESSING) {
-                strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
+                rm_strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
                 transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
                 transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
             }
@@ -880,7 +879,7 @@ static void cdProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
             if (transaction->state == RM_SERVICE_APPROVED) {
                 if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {
                     /* Transfer resource data tied to name to pending transaction */
-                    strncpy(pendingTrans->resourceInfo.name, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
+                    rm_strncpy(pendingTrans->resourceInfo.name, transaction->resourceInfo.name, RM_NAME_MAX_CHARS);
                     pendingTrans->resourceInfo.base = transaction->resourceInfo.base;
                     pendingTrans->resourceInfo.length = transaction->resourceInfo.length;
                     /* Delete NS name from pending transaction so Server isn't queried again */
@@ -963,9 +962,9 @@ static void cdProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
                  * retrieve resource data mapped to name */
                 if (newTrans = rmTransactionQueueAdd(rmInst)) {
                     newTrans->type = Rm_service_RESOURCE_GET_BY_NAME;
-                    strncpy(newTrans->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS);
+                    rm_strncpy(newTrans->serviceSrcInstName, rmInst->instName, RM_NAME_MAX_CHARS);
                     newTrans->state = RM_SERVICE_PROCESSING;       
-                    strncpy(newTrans->resourceInfo.nameServerName, transaction->resourceInfo.nameServerName, 
+                    rm_strncpy(newTrans->resourceInfo.nameServerName, transaction->resourceInfo.nameServerName, 
                             RM_NAME_MAX_CHARS);
                     newTrans->pendingTransactionId = transaction->localId;
                     transactionForwarder(rmInst, newTrans);
@@ -1070,7 +1069,7 @@ static void serverProcess (Rm_Inst *rmInst, Rm_Transaction *transaction)
                 else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {
                     if ((transaction->state = rmNameServerFindObject(&nameServerObjCfg)) ==
                         RM_SERVICE_PROCESSING) {
-                        strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
+                        rm_strncpy(transaction->resourceInfo.name, nameServerObjCfg.nodeCfg.resourceName, RM_NAME_MAX_CHARS);
                         transaction->resourceInfo.base = nameServerObjCfg.nodeCfg.resourceBase;
                         transaction->resourceInfo.length = nameServerObjCfg.nodeCfg.resourceLength;
                         transaction->state = RM_SERVICE_APPROVED;
@@ -1452,7 +1451,7 @@ Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
     rmInst->transactionSeqNum = transactionInitSequenceNum();
 
     rmInst->instType = initCfg->instType;    
-    strncpy (rmInst->instName, initCfg->instName, RM_NAME_MAX_CHARS);
+    rm_strncpy (rmInst->instName, initCfg->instName, RM_NAME_MAX_CHARS);
 
     if ((rmInst->instType == Rm_instType_SERVER) ||
         (rmInst->instType == Rm_instType_SHARED_SERVER)) {
index c18b64502b7888f432a9c2ebaba34bc7989ef140..d4cb1acd634c1c72c43da79ebe119d7afedfb68d 100644 (file)
@@ -43,6 +43,7 @@
 #include <ti/drv/rm/rm.h>
 
 /* RM internal includes */
+#include <ti/drv/rm/include/rm_internal.h>
 #include <ti/drv/rm/include/rm_loc.h>
 #include <ti/drv/rm/include/rm_allocatorloc.h>
 #include <ti/drv/rm/include/rm_dtb_utilloc.h>
@@ -78,7 +79,7 @@ static Rm_Allocator *allocatorAdd(Rm_Handle rmHandle, const char *resourceName)
 
     if (newAllocator) {
         memset((void *)newAllocator, 0, sizeof(*newAllocator));
-        strncpy(newAllocator->resourceName, resourceName, RM_NAME_MAX_CHARS);
+        rm_strncpy(newAllocator->resourceName, resourceName, RM_NAME_MAX_CHARS);
         newAllocator->allocatorRootEntry = NULL;
         newAllocator->nextAllocator = NULL;  
 
@@ -237,10 +238,13 @@ static void allocatorResNodeOwnerAdd(Rm_Handle rmHandle, Rm_ResourceNode *node,
  */
 static int allocatorResNodeBoundaryCompare(Rm_ResourceNode *node1, Rm_ResourceNode *node2)
 {
-    uint32_t node1End = node1->base + node1->length - 1;
-    uint32_t node2End = node2->base + node2->length - 1;
+    uint32_t node1End;
+    uint32_t node2End;
 
     if (node1 && node2) {
+        node1End = node1->base + node1->length - 1;
+        node2End = node2->base + node2->length - 1;
+        
         if (node1->base < node2->base) {
             if (node1End == (node2->base - 1)) {
                 return(RM_TRUE);
@@ -504,11 +508,7 @@ static int32_t allocatorPreAllocate(Rm_Handle rmHandle, Rm_Allocator *allocator,
     if (opInfo->resourceInfo->alignment == RM_RESOURCE_ALIGNMENT_UNSPECIFIED) {  
         /* Get alignment from policy */
         opInfo->resourceInfo->alignment = rmPolicyGetResourceAlignment(opInfo->policy, resourcePolicy);
-    }
-    
-    if (opInfo->resourceInfo->alignment == 0) {
-        opInfo->resourceInfo->alignment = 1;
-    }    
+    } 
 
     memset((void *)&findNode, 0, sizeof(findNode));
     findNode.base = opInfo->resourceInfo->base;
@@ -1235,7 +1235,7 @@ static int32_t allocatorFindLinuxResource(Rm_Handle rmHandle, const char *resour
     memset((void *)&opInfo, 0, sizeof(opInfo));
     memset((void *)&resourceInfo, 0, sizeof(resourceInfo));
 
-    strncpy(resourceInfo.name, resourceName, RM_NAME_MAX_CHARS);
+    rm_strncpy(resourceInfo.name, resourceName, RM_NAME_MAX_CHARS);
     opInfo.policy = rmInst->u.server.globalPolicy;
     opInfo.serviceSrcInstNode = rmPolicyGetLinuxInstNode(rmHandle);
     opInfo.operation = Rm_allocatorOp_ALLOCATE_INIT;
index 03de3624b5d3a4c9c4725264b1a3bda19bf150aa..92b4e6ac01d47f6969b7b25456b9bb8f9fb1596c 100644 (file)
  *  \par
 */
 
-/* Standard includes */
-#include <string.h>
-
 /* RM external API includes */
 #include <ti/drv/rm/rm.h>
 
 /* RM internal API includes */
+#include <ti/drv/rm/include/rm_internal.h>
 #include <ti/drv/rm/include/rm_dtb_utilloc.h>
 
 /* RM OSAL layer */
@@ -300,7 +298,7 @@ Rm_LinuxAlias *rmDtbUtilResExtractLinuxAlias(const void *dtbDataPtr, int32_t dtb
         
         pathLenBytes = strlen((char *) &dtbAliasData[i]) + 1;
         newAlias->path = (char *) Rm_osalMalloc(pathLenBytes);
-        strncpy(newAlias->path, ((char *) &dtbAliasData[i]), pathLenBytes);
+        rm_strncpy(newAlias->path, ((char *) &dtbAliasData[i]), pathLenBytes);
         
         /* Extract 32-bit value specifying number of offsets that follow */
         i += pathLenBytes;
@@ -417,7 +415,7 @@ Rm_NsAssignment *rmDtbUtilResExtractNsAssignment(const void *dtbDataPtr, int32_t
             *result = RM_ERROR_GRL_NS_ASSIGNMENT_NAME_TOO_LONG;
             return(NULL);
         }        
-        strncpy(newAssignment->nsName, ((char *) &dtbNsAssignmentData[i]), RM_NAME_MAX_CHARS);
+        rm_strncpy(newAssignment->nsName, ((char *) &dtbNsAssignmentData[i]), RM_NAME_MAX_CHARS);
         
         /* Extract 32-bit base value and flip endian */
         i += nameLenBytes;
@@ -540,7 +538,7 @@ Rm_PolicyAssignment *rmDtbUtilPolicyExtractAssignments(const void *dtbDataPtr, i
 
         permissionsLenBytes = strlen((char *) &dtbAssignmentData[i]) + 1;
         newAssignment->permissionsList = (char *) Rm_osalMalloc(permissionsLenBytes);
-        strncpy(newAssignment->permissionsList, ((char *) &dtbAssignmentData[i]), permissionsLenBytes);
+        rm_strncpy(newAssignment->permissionsList, ((char *) &dtbAssignmentData[i]), permissionsLenBytes);
         i += permissionsLenBytes;
 
         newAssignment->nextAssignment = NULL;
@@ -666,7 +664,7 @@ Rm_PolicyValidInst *rmDtbUtilPolicyExtractValidInstances(const void *dtbDataPtr,
             *result = RM_ERROR_VALID_INST_NAME_TOO_LONG;
             return(NULL);
         }
-        strncpy(newInst->instName, ((char *) &dtbValidInstData[i]), instLenBytes);
+        rm_strncpy(newInst->instName, ((char *) &dtbValidInstData[i]), instLenBytes);
         
         i += instLenBytes;
 
index 16b8fa8539ac19fe60e113fddcb6ea193f1ab34d..411db89886827d460bb9f084145207a7edf429c6 100644 (file)
@@ -39,9 +39,6 @@
  *  \par
 */
 
-/* Standard includes */
-#include <string.h>
-
 /* RM external API includes */
 #include <ti/drv/rm/rm.h>
 
@@ -98,7 +95,7 @@ int32_t rmNameServerFindObject(Rm_NameServerObjCfg *objCfg)
     int32_t            retVal = RM_ERROR_NAMESERVER_NAME_DOES_NOT_EXIST;
 
     memset((void *)&findNode, 0, sizeof(Rm_NameServerNode));
-    strncpy(findNode.objName, objCfg->nodeCfg.objName, RM_NAME_MAX_CHARS);
+    rm_strncpy(findNode.objName, objCfg->nodeCfg.objName, RM_NAME_MAX_CHARS);
     
     if (matchingNode = RB_FIND(_Rm_NameServerTree, objCfg->nameServerTree, &findNode)) {
         /* Found in NameServer */
@@ -124,7 +121,7 @@ int32_t rmNameServerDeleteObject(Rm_NameServerObjCfg *objCfg)
     int32_t            retVal = RM_ERROR_NAMESERVER_NAME_DOES_NOT_EXIST;    
 
     memset((void *)&findNode, 0, sizeof(Rm_NameServerNode));
-    strncpy(findNode.objName, objCfg->nodeCfg.objName, RM_NAME_MAX_CHARS);
+    rm_strncpy(findNode.objName, objCfg->nodeCfg.objName, RM_NAME_MAX_CHARS);
     
     if (matchingNode = RB_FIND(_Rm_NameServerTree, objCfg->nameServerTree, &findNode)) {
         /* Remove from NameServer */
index ca62fce38bf6085ac11137203b88d0a5e29f4040..19df033fb98808fe269d8b0eea5903472aad484e 100644 (file)
@@ -143,7 +143,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
 
     /* Create a local copy of the sub-permission string */
     permStrPtr = Rm_osalMalloc(permStrLen);
-    strncpy(permStrPtr, permStrStart, permStrLen);
+    rm_strncpy(permStrPtr, permStrStart, permStrLen);
     /* Make sure the last character in the copied sub-permission string is null */
     permStrPtr[permStrLen - 1] = '\0';
 
@@ -197,7 +197,7 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart, char *p
             newPerm = (Rm_PolicyPermission *) Rm_osalMalloc(sizeof(Rm_PolicyPermission));
             memset((void *)newPerm, 0, sizeof(Rm_PolicyPermission));
 
-            strncpy(newPerm->instName, instNameTemp, RM_NAME_MAX_CHARS);
+            rm_strncpy(newPerm->instName, instNameTemp, RM_NAME_MAX_CHARS);
             newPerm->nextPermission = NULL;
 
             if (prevPerm == NULL) {
@@ -536,7 +536,7 @@ Rm_PolicyValidInstNode *rmPolicyGetValidInstNode(Rm_Handle rmHandle, char *instN
     }
 
     memset((void *)&findNode, 0, sizeof(Rm_PolicyValidInstNode));
-    strncpy(findNode.name, instName, RM_NAME_MAX_CHARS);
+    rm_strncpy(findNode.name, instName, RM_NAME_MAX_CHARS);
     
     return (RB_FIND(_Rm_PolicyValidInstTree, treeRoot, &findNode));
 }
@@ -736,12 +736,12 @@ uint32_t rmPolicyGetResourceBase(void *policyDtb, Rm_PolicyValidInstNode *validI
  */
 uint32_t rmPolicyGetResourceAlignment(void *policyDtb, int32_t resourceOffset)
 {
-    int32_t            propertyOffset;
-    const char        *propertyName;
-    int32_t            propertyLen;
-    const void        *propertyData;
-    Rm_ResourceValue  *alignmentList;
-    uint32_t           resourceAlignment = 0;
+    int32_t           propertyOffset;
+    const char       *propertyName;
+    int32_t           propertyLen;
+    const void       *propertyData;
+    Rm_ResourceValue *alignmentList;
+    uint32_t          resourceAlignment = 0;
 
     propertyOffset = fdt_first_property_offset(policyDtb, resourceOffset);
     if (propertyOffset > RM_DTB_UTIL_STARTING_NODE_OFFSET) {
@@ -755,6 +755,10 @@ uint32_t rmPolicyGetResourceAlignment(void *policyDtb, int32_t resourceOffset)
             propertyOffset = fdt_next_property_offset(policyDtb, propertyOffset);
         }
     }
+
+    if (resourceAlignment == 0) {
+        resourceAlignment = 1;
+    }
     return(resourceAlignment);
 }
 
@@ -765,12 +769,12 @@ uint32_t rmPolicyGetResourceAlignment(void *policyDtb, int32_t resourceOffset)
  */
 uint32_t rmPolicyGetResourceCdAllocSize(void *policyDtb, int32_t resourceOffset)
 {
-    int32_t            propertyOffset;
-    const char        *propertyName;
-    int32_t            propertyLen;
-    const void        *propertyData;
-    Rm_ResourceValue  *allocSizeList;
-    uint32_t           resourceAllocSize = 0;
+    int32_t           propertyOffset;
+    const char       *propertyName;
+    int32_t           propertyLen;
+    const void       *propertyData;
+    Rm_ResourceValue *allocSizeList;
+    uint32_t          resourceAllocSize = 0;
 
     propertyOffset = fdt_first_property_offset(policyDtb, resourceOffset);
     if (propertyOffset > RM_DTB_UTIL_STARTING_NODE_OFFSET) {
@@ -784,6 +788,10 @@ uint32_t rmPolicyGetResourceCdAllocSize(void *policyDtb, int32_t resourceOffset)
             propertyOffset = fdt_next_property_offset(policyDtb, propertyOffset);
         }
     }
+    
+    if (resourceAllocSize == 0) {
+        resourceAllocSize = 1;
+    }
     return(resourceAllocSize);
 }
 
index a2d13e79fd6e013c6892345b388f3d4991c566fb..80585ddfe30dbd40671fd989d8480b54cb6f27bd 100644 (file)
  *  \par
 */
 
-/* Standard includes */
-#include <string.h>
-
 /* RM external API includes */
 #include <ti/drv/rm/rm.h>
 #include <ti/drv/rm/rm_services.h>
 
 /* RM internal API includes */
 #include <ti/drv/rm/include/rm_loc.h>
+#include <ti/drv/rm/include/rm_internal.h>
 
 /* RM OSAL layer */
 #include <rm_osal.h>
@@ -121,11 +119,11 @@ void Rm_serviceHandler (void *rmHandle, const Rm_ServiceReqInfo *serviceRequest,
     transaction = rmTransactionQueueAdd(rmInst);
     if (transaction) {
         transaction->type = serviceRequest->type;
-        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) {
-            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;
@@ -133,7 +131,7 @@ 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) {
-            strncpy(transaction->resourceInfo.nameServerName, serviceRequest->resourceNsName, RM_NAME_MAX_CHARS);
+            rm_strncpy(transaction->resourceInfo.nameServerName, serviceRequest->resourceNsName, RM_NAME_MAX_CHARS);
         }
 
         /* Process received transaction */
@@ -170,7 +168,7 @@ void Rm_serviceHandler (void *rmHandle, const Rm_ServiceReqInfo *serviceRequest,
 
             if ((serviceResponse->serviceState == RM_SERVICE_APPROVED) ||
                 (serviceResponse->serviceState == RM_SERVICE_APPROVED_STATIC)) {
-                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;
             }
index 933f4ffb023685d40af6887dfef0c9de53de065d..7f4ab0a6be5e73e20c2ff8c4eba358fb822728f5 100644 (file)
@@ -39,9 +39,6 @@
  *  \par\r
 */\r
 \r
-/* Standard includes */\r
-#include <string.h>\r
-\r
 /* RM external includes */\r
 #include <ti/drv/rm/rm.h>\r
 #include <ti/drv/rm/rm_transport.h>\r
@@ -185,11 +182,11 @@ int32_t getPktSrcNames(const Rm_Packet *pkt, char *pktSrc, char *serviceSrc, int
                 Rm_ResourceRequestPkt *resourceReqPkt = (Rm_ResourceRequestPkt *)pkt->data;\r
 \r
                 if (pktSrc){\r
-                    strncpy(pktSrc, resourceReqPkt->pktSrcInstName, RM_NAME_MAX_CHARS);\r
+                    rm_strncpy(pktSrc, resourceReqPkt->pktSrcInstName, RM_NAME_MAX_CHARS);\r
                 }\r
 \r
                 if (serviceSrc) {\r
-                    strncpy(serviceSrc, resourceReqPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
+                    rm_strncpy(serviceSrc, resourceReqPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
                 }\r
 \r
                 break;\r
@@ -199,11 +196,11 @@ int32_t getPktSrcNames(const Rm_Packet *pkt, char *pktSrc, char *serviceSrc, int
                 Rm_NsRequestPkt *nsRequestPkt = (Rm_NsRequestPkt *)pkt->data;\r
 \r
                 if (pktSrc){\r
-                    strncpy(pktSrc, nsRequestPkt->pktSrcInstName, RM_NAME_MAX_CHARS);\r
+                    rm_strncpy(pktSrc, nsRequestPkt->pktSrcInstName, RM_NAME_MAX_CHARS);\r
                 }\r
 \r
                 if (serviceSrc) {\r
-                    strncpy(serviceSrc, nsRequestPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
+                    rm_strncpy(serviceSrc, nsRequestPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
                 }\r
 \r
                 break;\r
@@ -424,7 +421,7 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pk
             else if (resourceReqPkt->resourceReqType == Rm_resReqPktType_GET_NAMED) {\r
                 transaction->type = Rm_service_RESOURCE_GET_BY_NAME;\r
             }            \r
-            strncpy(transaction->serviceSrcInstName, resourceReqPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
+            rm_strncpy(transaction->serviceSrcInstName, resourceReqPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
             transaction->state = RM_SERVICE_PROCESSING;\r
             memcpy ((void *)&(transaction->resourceInfo), (void *)&(resourceReqPkt->resourceInfo),\r
                     sizeof(Rm_ResourceInfo));\r
@@ -478,7 +475,7 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle, const Rm_Packet *pk
                 transaction->type = Rm_service_RESOURCE_UNMAP_NAME;\r
             }\r
 \r
-            strncpy(transaction->serviceSrcInstName, nsRequestPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
+            rm_strncpy(transaction->serviceSrcInstName, nsRequestPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
             transaction->state = RM_SERVICE_PROCESSING;\r
             memcpy ((void *)&(transaction->resourceInfo), (void *)&(nsRequestPkt->resourceInfo),\r
                     sizeof(Rm_ResourceInfo));           \r
index 5f56ca10f7eda652a5d0f1224df5454387063bd3..cdcb88e7b586e888a7ee5c02b3b91039b5e19206 100644 (file)
@@ -39,9 +39,6 @@
  *  \par
 */
 
-/* Standard includes */
-#include <string.h>
-
 /* RM external API includes */
 #include <ti/drv/rm/rm.h>
 
@@ -107,8 +104,8 @@ Rm_NameServerNode *rmNameServerNodeNew(Rm_NameServerNodeCfg *nodeCfg)
 
     newNode = Rm_osalMalloc(sizeof(Rm_NameServerNode));
     if (newNode) {
-        strncpy(newNode->objName, nodeCfg->objName, RM_NAME_MAX_CHARS);
-        strncpy(newNode->resourceName, nodeCfg->resourceName, RM_NAME_MAX_CHARS); 
+        rm_strncpy(newNode->objName, nodeCfg->objName, RM_NAME_MAX_CHARS);
+        rm_strncpy(newNode->resourceName, nodeCfg->resourceName, RM_NAME_MAX_CHARS); 
         newNode->resourceBase = nodeCfg->resourceBase;
         newNode->resourceLength = nodeCfg->resourceLength;
     }
@@ -207,7 +204,7 @@ Rm_PolicyValidInstNode *rmPolicyValidInstNodeNew(char *instName)
 
     newNode = Rm_osalMalloc(sizeof(Rm_PolicyValidInstNode));
     
-    strncpy(newNode->name, instName, RM_NAME_MAX_CHARS);
+    rm_strncpy(newNode->name, instName, RM_NAME_MAX_CHARS);
     newNode->allocRefCount = 0;
     newNode->deletePending = RM_FALSE;