Resolved code review comments and -Wall -Wexta warnings
authorJustin Sobota <jsobota@ti.com>
Tue, 30 Jun 2015 20:49:00 +0000 (16:49 -0400)
committerJustin Sobota <jsobota@ti.com>
Tue, 30 Jun 2015 20:49:00 +0000 (16:49 -0400)
22 files changed:
include/rm_internal.h
include/rm_policyloc.h
include/rm_transportloc.h
include/rm_treeloc.h
package.xdc
rm.h
rmver.h
src/rm.c
src/rm_allocator.c
src/rm_dtb_util.c
src/rm_policy.c
src/rm_services.c
src/rm_transport.c
test/armv7/linux/build/makefile
test/armv7/linux/rm_dsp_client_test.c
test/armv7/linux/rm_linux_client_test.c
test/armv7/linux/rm_linux_mt_client_test.c
test/armv7/linux/rm_linux_osal.c
test/armv7/linux/rm_server.c
test/armv7/linux/rm_server_osal.c
test/armv7/linux/sockutils.c
test/armv7/linux/sockutils.h

index 952ab201ab5b042bc27169c1010e41bcb2f5322f..20eb5fce500e6069de22495fc2cd39496b635bb0 100644 (file)
@@ -4,7 +4,7 @@
  *  Data structures used by more than one internal RM module.
  *
  *  ============================================================================
- *      (C) Copyright 2012-2015, Texas Instruments, Inc.
+ *      (C) Copyright 2012-2014, Texas Instruments, Inc.
  * 
  *  Redistribution and use in source and binary forms, with or without 
  *  modification, are permitted provided that the following conditions 
index 9608515a4d042a652cff123249586cced52d6b48..5b27dd4ad199b0602865231e36e057ce6459016f 100644 (file)
@@ -60,57 +60,8 @@ extern "C" {
  * THIS NAME */
 #define RM_ALLOCATED_TO_LINUX "Linux-Kernel"
 
-/* Policy permission bit storage definition for Rm_PolicyPermBits
- * Bit : Description
- *-----------------------------
- *  0  : Init         (i) - RM instance has initialization permission for
- *                          resource
- *  1  : Use          (u) - RM instance has usage permission for resource
- *  2  : Exclusive    (x) - RM instance has exclusive allocation privilege for
- *                          resource i.e. No other RM instance can reserve the
- *                          resource if a RM instance with exclusive privilege
- *                          reserves the resource
- *  3  : Shared Linux (s) - Resource has been reserved by the Linux kernel but
- *                          can be allocated by the specified RM instances
- *  4 - 31 : UNUSED
- */
-
-/* Maximum number of bits used to represent all permissions.  Must be
- * changed as new permissions are added */
-#define RM_POLICY_PERM_MAX_BITS            4
-
-/* Initialization permission characters */
-#define RM_POLICY_PERM_INIT_LOWER         'i'
-#define RM_POLICY_PERM_INIT_UPPER         'I'
-/* Initialization permission bit shift */
-#define RM_POLICY_PERM_INIT_SHIFT          0
-/* Usage permission characters */
-#define RM_POLICY_PERM_USE_LOWER          'u'
-#define RM_POLICY_PERM_USE_UPPER          'U'
-/* Usage permission bit shift */
-#define RM_POLICY_PERM_USE_SHIFT           1
-/* Exclusive permission characters */
-#define RM_POLICY_PERM_EXCLUSIVE_LOWER    'x'
-#define RM_POLICY_PERM_EXCLUSIVE_UPPER    'X'
-/* Exclusive permission bit shift */
-#define RM_POLICY_PERM_EXCLUSIVE_SHIFT     2
-/* Shared Linux permission characters */
-#define RM_POLICY_PERM_SHARED_LINUX_LOWER 's'
-#define RM_POLICY_PERM_SHARED_LINUX_UPPER 'S'
-/* Shared Linux permission bit shift */
-#define RM_POLICY_PERM_SHARED_LINUX_SHIFT  3
-
-/* Permissions subgroup start character */
-#define RM_POLICY_PERM_SUBGROUP_START     '('
-/* Permissions subgroup end character */
-#define RM_POLICY_PERM_SUBGROUP_END       ')'
-/* Permissions subgroup terminator */
-#define RM_POLICY_PERM_TERMINATOR         '&'
-/* Permissions assignment character */
-#define RM_POLICY_PERM_ASSIGNMENT         '='
-
 /* Full permissions bit mask */
-#define RM_policy_PERM_FULL_MASK          ((1 << RM_POLICY_PERM_MAX_BITS) - 1)
+#define RM_policy_PERM_FULL_MASK          ((1u << RM_POLICY_PERM_MAX_BITS) - 1)
 
 /* Calculates number of instance permission sets per permission word */
 #define RM_policy_PERM_INST_PER_WORD \
@@ -125,11 +76,11 @@ extern "C" {
 
 /* Sets a permission for an instance */
 #define RM_policy_PERM_SET(permArray, wordIdx, wordOffset, permOffset, val) \
-    permArray[wordIdx] &= ~(0x1 << (wordOffset + permOffset));              \
-    permArray[wordIdx] |= (val & 0x1) << (wordOffset + permOffset);
+    permArray[wordIdx] &= ~(0x1u << (wordOffset + permOffset));             \
+    permArray[wordIdx] |= (val & 0x1u) << (wordOffset + permOffset);
 /* Gets a permission for an instance */
 #define RM_policy_PERM_GET(permArray, wordIdx, wordOffset, permOffset)  \
-    ((permArray[wordIdx] >> (wordOffset + permOffset)) & 0x1)
+    ((permArray[wordIdx] >> (wordOffset + permOffset)) & 0x1u)
 
 /* Assigned instance permissions linked list node */
 typedef struct Rm_Permission_s {
index 828dae19a7101557cbdad266d3231d93595c9325..6f3a804a2948861c489b2e9301508a7a82432706 100644 (file)
@@ -105,7 +105,9 @@ typedef enum {
     /* Free resource */
     Rm_resReqPktType_FREE,
     /* Get name resource */
-    Rm_resReqPktType_GET_NAMED
+    Rm_resReqPktType_GET_NAMED,
+    /* Invalid request packet type */
+    Rm_resReqPktType_INVALID
 } Rm_ResourceReqPktType;
 
 /* Resource Request Packet - Packet sent to CDs and Servers to request
@@ -147,7 +149,9 @@ typedef enum {
     /* Request to map the specified name to the specified resources */
     Rm_nsReqPktType_MAP_RESOURCE = 0,
     /* Request to unmap the specified name from the specifed resources */
-    Rm_nsReqPktType_UNMAP_RESOURCE
+    Rm_nsReqPktType_UNMAP_RESOURCE,
+    /* Invalide NS request type */
+    Rm_nsReqPktType_INVALID
 } Rm_NsReqPktType;
 
 /* NameServer Request Packet - Packet sent by RM instances containing
index e31250a123cf5151a890cab1e83ff89b18746b9d..488db60cc54657bec257fe779a1874d14ad54e91 100644 (file)
@@ -142,8 +142,55 @@ typedef struct _Rm_ResourceNode {
 /* Resource tree root entry type definition */
 typedef RB_HEAD(_Rm_AllocatorResourceTree, _Rm_ResourceNode) Rm_ResourceTree;
 
-/* Policy permission bit storage type
- * See rm_policyloc.h for bit by bit usage of this type */
+/* Policy permission bit storage definition for Rm_PolicyPermBits
+ * Bit : Description
+ *-----------------------------
+ *  0  : Init         (i) - RM instance has initialization permission for
+ *                          resource
+ *  1  : Use          (u) - RM instance has usage permission for resource
+ *  2  : Exclusive    (x) - RM instance has exclusive allocation privilege for
+ *                          resource i.e. No other RM instance can reserve the
+ *                          resource if a RM instance with exclusive privilege
+ *                          reserves the resource
+ *  3  : Shared Linux (s) - Resource has been reserved by the Linux kernel but
+ *                          can be allocated by the specified RM instances
+ */
+
+/* Maximum number of bits used to represent all permissions.  Must be
+ * changed as new permissions are added */
+#define RM_POLICY_PERM_MAX_BITS            4
+
+/* Initialization permission characters */
+#define RM_POLICY_PERM_INIT_LOWER         'i'
+#define RM_POLICY_PERM_INIT_UPPER         'I'
+/* Initialization permission bit shift */
+#define RM_POLICY_PERM_INIT_SHIFT          0
+/* Usage permission characters */
+#define RM_POLICY_PERM_USE_LOWER          'u'
+#define RM_POLICY_PERM_USE_UPPER          'U'
+/* Usage permission bit shift */
+#define RM_POLICY_PERM_USE_SHIFT           1
+/* Exclusive permission characters */
+#define RM_POLICY_PERM_EXCLUSIVE_LOWER    'x'
+#define RM_POLICY_PERM_EXCLUSIVE_UPPER    'X'
+/* Exclusive permission bit shift */
+#define RM_POLICY_PERM_EXCLUSIVE_SHIFT     2
+/* Shared Linux permission characters */
+#define RM_POLICY_PERM_SHARED_LINUX_LOWER 's'
+#define RM_POLICY_PERM_SHARED_LINUX_UPPER 'S'
+/* Shared Linux permission bit shift */
+#define RM_POLICY_PERM_SHARED_LINUX_SHIFT  3
+
+/* Permissions subgroup start character */
+#define RM_POLICY_PERM_SUBGROUP_START     '('
+/* Permissions subgroup end character */
+#define RM_POLICY_PERM_SUBGROUP_END       ')'
+/* Permissions subgroup terminator */
+#define RM_POLICY_PERM_TERMINATOR         '&'
+/* Permissions assignment character */
+#define RM_POLICY_PERM_ASSIGNMENT         '='
+
+/* Policy permission bit storage type */
 typedef uint32_t Rm_PolicyPermBits;
 
 /* Policy node */
index fd5ca69014633f75f6d6ee126eaf59f627bfe86e..aa520fec616150893eb768f79d7093b0dfa85640 100644 (file)
@@ -9,6 +9,6 @@
  * Copyright (C) 2012-2015, Texas Instruments, Inc.\r
  *****************************************************************************/\r
 \r
-package ti.drv.rm[2, 1, 0, 9] {\r
+package ti.drv.rm[2, 1, 2, 00] {\r
     module Settings;\r
 }\r
diff --git a/rm.h b/rm.h
index 55d3ef0b9112ef81ec3f7e646a2b2ccb31868a04..d5bd177b329f32915fd4eea81abf36004b52e6ab 100644 (file)
--- a/rm.h
+++ b/rm.h
@@ -420,6 +420,8 @@ extern "C" {
 #define RM_ERROR_MALLOC_FAILED_RES_NODE            RM_ERROR_BASE-59
 /** A resource specified in the GRL could not be found in the policy */
 #define RM_ERROR_RES_DOES_NOT_EXIST_IN_POLICY      RM_ERROR_BASE-60
+/** Server's response to CD request has invalid service type */
+#define RM_ERROR_SERVER_RESP_INVALID_SERVICE_TYPE  RM_ERROR_BASE-61
 
 /**
  * @brief Maximum number of characters allowed for RM instance, resource, and
diff --git a/rmver.h b/rmver.h
index 44f939d424fc9255157054272de5fb254848b989..62605819660b5a3d1929493c83159a56b8b49e6c 100644 (file)
--- a/rmver.h
+++ b/rmver.h
@@ -51,13 +51,13 @@ extern "C" {
  * format:
  *  0xAABBCCDD -> Arch (AA); API Changes (BB); Major (CC); Minor (DD)
  */
-#define RM_VERSION_ID                   (0x02010009)
+#define RM_VERSION_ID                   (0x02010200)
 
 /**
  * @brief   This is the version string which describes the RM along with the
  * date and build information.
  */
-#define RM_VERSION_STR                  "RM Revision: 02.01.00.09"
+#define RM_VERSION_STR                  "RM Revision: 2.1.2.00"
 
 
 #ifdef __cplusplus
index 792b945ef1551b0b05b4b9ed299467f74274c91d..c539fe42ecb5cc6462826c353c7cd967abe9819d 100644 (file)
--- a/src/rm.c
+++ b/src/rm.c
@@ -109,32 +109,36 @@ static uint32_t transactionGetSequenceNum(Rm_Inst *rmInst)
  *              is allocated via the rmAllocPkt API using the
  *              appTransport handle provided by the application
  */
-static void createResourceReqPkt(Rm_Packet *rmPkt, char *localInstName,
-                                 Rm_Transaction *transaction)
+static Rm_Packet *createResourceReqPkt(Rm_ResourceReqPktType resReqType,
+                                       Rm_Transport *dstTrans,
+                                       const char *locInstName,
+                                       Rm_Transaction *transaction,
+                                       Rm_PacketHandle *pktHandle)
 {
+    Rm_Packet             *rmPkt = NULL;
     Rm_ResourceRequestPkt *resourceReqPkt = NULL;
 
+    rmPkt = dstTrans->callouts.rmAllocPkt(dstTrans->appTransportHandle,
+                                          sizeof(Rm_Packet), pktHandle);
+    if ((rmPkt == NULL) || (pktHandle == NULL)) {
+        transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;
+        goto errorExit;
+    }
+
     rmPkt->pktType = Rm_pktType_RESOURCE_REQUEST;
     resourceReqPkt = (Rm_ResourceRequestPkt *) rmPkt->data;
-    resourceReqPkt->requestId = transaction->localId;
-    if (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) {
-        resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE_INIT;
-    } else if (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE) {
-        resourceReqPkt->resourceReqType = Rm_resReqPktType_ALLOCATE_USE;
-    } else if (transaction->type == Rm_service_RESOURCE_STATUS) {
-        resourceReqPkt->resourceReqType = Rm_resReqPktType_GET_STATUS;
-    } else if (transaction->type == Rm_service_RESOURCE_FREE) {
-        resourceReqPkt->resourceReqType = Rm_resReqPktType_FREE;
-    } else if (transaction->type == Rm_service_RESOURCE_GET_BY_NAME) {
-        resourceReqPkt->resourceReqType = Rm_resReqPktType_GET_NAMED;
-    }
-    rm_strncpy(resourceReqPkt->pktSrcInstName, localInstName,
+    resourceReqPkt->requestId       = transaction->localId;
+    resourceReqPkt->resourceReqType = resReqType;
+    rm_strncpy(resourceReqPkt->pktSrcInstName, locInstName,
                RM_NAME_MAX_CHARS);
     rm_strncpy(resourceReqPkt->serviceSrcInstName,
                transaction->serviceSrcInstName, RM_NAME_MAX_CHARS);
     memcpy((void *)&(resourceReqPkt->resourceInfo),
            (void *)&(transaction->resourceInfo),
            sizeof(Rm_ResourceInfo));
+
+errorExit:
+    return(rmPkt);
 }
 
 /* FUNCTION PURPOSE: Creates a resource response packet
@@ -167,25 +171,36 @@ static void createResourceResponsePkt(Rm_Packet *rmPkt,
  *              is allocated via the rmAllocPkt API using the
  *              appTransport handle provided by the application
  */
-static void createNsRequestPkt(Rm_Packet *rmPkt, char *localInstName,
-                               Rm_Transaction *transaction)
-{ 
+static Rm_Packet *createNsRequestPkt(Rm_NsReqPktType nsReqType,
+                                     Rm_Transport *dstTrans,
+                                     const char *locInstName,
+                                     Rm_Transaction *transaction,
+                                     Rm_PacketHandle *pktHandle)
+{
+    Rm_Packet       *rmPkt = NULL;
     Rm_NsRequestPkt *nsReqPkt = NULL;
 
+
+    rmPkt = dstTrans->callouts.rmAllocPkt(dstTrans->appTransportHandle,
+                                          sizeof(Rm_Packet), pktHandle);
+    if ((rmPkt == NULL) || (pktHandle == NULL)) {
+        transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;
+        goto errorExit;
+    }
+
     rmPkt->pktType = Rm_pktType_NAMESERVER_REQUEST;
     nsReqPkt = (Rm_NsRequestPkt *)rmPkt->data;
-    nsReqPkt->requestId = transaction->localId;
-    if (transaction->type == Rm_service_RESOURCE_MAP_TO_NAME) {
-        nsReqPkt->nsRequestType = Rm_nsReqPktType_MAP_RESOURCE;
-    } else if (transaction->type == Rm_service_RESOURCE_UNMAP_NAME) {
-        nsReqPkt->nsRequestType = Rm_nsReqPktType_UNMAP_RESOURCE;
-    }
-    rm_strncpy(nsReqPkt->pktSrcInstName, localInstName, RM_NAME_MAX_CHARS);
+    nsReqPkt->requestId     = transaction->localId;
+    nsReqPkt->nsRequestType = nsReqType;
+    rm_strncpy(nsReqPkt->pktSrcInstName, locInstName, RM_NAME_MAX_CHARS);
     rm_strncpy(nsReqPkt->serviceSrcInstName, transaction->serviceSrcInstName,
                RM_NAME_MAX_CHARS);
     memcpy((void *)&(nsReqPkt->resourceInfo),
            (void *)&(transaction->resourceInfo),
            sizeof(Rm_ResourceInfo));
+
+errorExit:
+    return(rmPkt);
 }
 
 /* FUNCTION PURPOSE: Creates a NameServer response packet
@@ -206,6 +221,62 @@ static void createNsResponsePkt(Rm_Packet *rmPkt, Rm_Transaction *transaction)
     nsRespPkt->requestState = transaction->state;
 }
 
+/* FUNCTION PURPOSE: Creates a request packet
+ ***********************************************************************
+ * DESCRIPTION: Returns a RM packet handle that points to a request packet.
+ *              The request packet type is based on the transaction type.
+ */
+static Rm_Packet *createRequestPkt(Rm_Transport *dstTrans,
+                                   const char *locInstName,
+                                   Rm_Transaction *transaction,
+                                   Rm_PacketHandle *pktHandle)
+{
+    Rm_Packet *rmPkt = NULL;
+
+    switch (transaction->type) {
+        case Rm_service_RESOURCE_ALLOCATE_INIT:
+            rmPkt = createResourceReqPkt(Rm_resReqPktType_ALLOCATE_INIT,
+                                         dstTrans, locInstName, transaction,
+                                         pktHandle);
+            break;
+        case Rm_service_RESOURCE_ALLOCATE_USE:
+            rmPkt = createResourceReqPkt(Rm_resReqPktType_ALLOCATE_USE,
+                                         dstTrans, locInstName, transaction,
+                                         pktHandle);
+            break;
+        case Rm_service_RESOURCE_STATUS:
+            rmPkt = createResourceReqPkt(Rm_resReqPktType_GET_STATUS,
+                                         dstTrans, locInstName, transaction,
+                                         pktHandle);
+            break;
+        case Rm_service_RESOURCE_FREE:
+            rmPkt = createResourceReqPkt(Rm_resReqPktType_FREE,
+                                         dstTrans, locInstName, transaction,
+                                         pktHandle);
+            break;
+        case Rm_service_RESOURCE_GET_BY_NAME:
+            rmPkt = createResourceReqPkt(Rm_resReqPktType_GET_NAMED,
+                                         dstTrans, locInstName, transaction,
+                                         pktHandle);
+            break;
+        case Rm_service_RESOURCE_MAP_TO_NAME:
+            rmPkt = createNsRequestPkt(Rm_nsReqPktType_MAP_RESOURCE,
+                                       dstTrans, locInstName, transaction,
+                                       pktHandle);
+            break;
+        case Rm_service_RESOURCE_UNMAP_NAME:
+            rmPkt = createNsRequestPkt(Rm_nsReqPktType_UNMAP_RESOURCE,
+                                       dstTrans, locInstName, transaction,
+                                       pktHandle);
+            break;
+        default:
+            transaction->state = RM_ERROR_INVALID_SERVICE_TYPE;
+            break;
+    }
+
+    return(rmPkt);
+}
+
 /* FUNCTION PURPOSE: Issues a service response to application
  ***********************************************************************
  * DESCRIPTION: Provides a service response back to the application
@@ -313,59 +384,47 @@ errorExit:
  *              The request is sent via the RM transport API which is
  *              plugged with an application created transport path.
  */
-static void transactionForwarder (Rm_Inst *rmInst, Rm_Transaction *transaction)
+static void transactionForwarder(Rm_Inst *rmInst, Rm_Transaction *transaction)
 {
-    Rm_Transport    *dstTransport = NULL;
-    Rm_Packet       *rmPkt = NULL;    
-    Rm_PacketHandle  pktHandle = NULL;
+    Rm_Transport *dstTrans;
 
     if (rmInst->instType == Rm_instType_CLIENT) {
-        dstTransport = rmTransportFindRemoteInstType(rmInst->transports,
-                                                   Rm_instType_CLIENT_DELEGATE);
-
-        if (!dstTransport) {
-            dstTransport = rmTransportFindRemoteInstType(rmInst->transports,
-                                                         Rm_instType_SERVER);
+        dstTrans = rmTransportFindRemoteInstType(rmInst->transports,
+                                                 Rm_instType_CLIENT_DELEGATE);
+        if (dstTrans == NULL) {
+            dstTrans = rmTransportFindRemoteInstType(rmInst->transports,
+                                                     Rm_instType_SERVER);
         }
     } else if (rmInst->instType == Rm_instType_CLIENT_DELEGATE) {
-        dstTransport = rmTransportFindRemoteInstType(rmInst->transports,
-                                                     Rm_instType_SERVER);
+        dstTrans = rmTransportFindRemoteInstType(rmInst->transports,
+                                                 Rm_instType_SERVER);
+    } else {
+        dstTrans = NULL;
     }
 
     /* Just queue transaction if transport hasn't been registered.  Do not
      * return error */
-    if (dstTransport) {
-        rmPkt = dstTransport->callouts.rmAllocPkt(dstTransport->appTransportHandle,
-                                                 sizeof(Rm_Packet), &pktHandle);
-        if (!rmPkt || !pktHandle) {
-            transaction->state = RM_ERROR_TRANSPORT_ALLOC_PKT_ERROR;
+    if (dstTrans) {
+        Rm_Packet       *rmPkt = NULL;
+        Rm_PacketHandle  pktHandle = NULL;
+
+        rmPkt = createRequestPkt(dstTrans, rmInst->instName, transaction,
+                                 &pktHandle);
+        if ((rmPkt == NULL) || (pktHandle == NULL)) {
+            /* Error returned via transaction->state */
             goto errorExit;
         }
 
-        switch (transaction->type) {
-            case Rm_service_RESOURCE_ALLOCATE_INIT:
-            case Rm_service_RESOURCE_ALLOCATE_USE:
-            case Rm_service_RESOURCE_STATUS:
-            case Rm_service_RESOURCE_FREE:
-            case Rm_service_RESOURCE_GET_BY_NAME:
-                createResourceReqPkt(rmPkt, rmInst->instName, transaction);
-                break;
-            case Rm_service_RESOURCE_MAP_TO_NAME:
-            case Rm_service_RESOURCE_UNMAP_NAME:
-                createNsRequestPkt(rmPkt, rmInst->instName, transaction);
-                break;
-            default:
-                transaction->state = RM_ERROR_INVALID_SERVICE_TYPE;
-                goto errorExit;
-        }
-
-        if (dstTransport->callouts.rmSendPkt(dstTransport->appTransportHandle,
-                                             pktHandle) < RM_OK) {
+        if (dstTrans->callouts.rmSendPkt(dstTrans->appTransportHandle,
+                                         pktHandle) < RM_OK) {
             transaction->state = RM_ERROR_TRANSPORT_SEND_ERROR;
             goto errorExit;
         }
         transaction->hasBeenForwarded = RM_TRUE;
-        /* Transaction not deleted.  Waiting for response from RM CD or Server */
+        /* Transaction not deleted.  Waiting for response from RM CD or
+         * Server */
+    } else {
+        transaction->state = RM_ERROR_TRANSPORT_HANDLE_DOES_NOT_EXIST;
     }
 errorExit:
     /* Do not delete transaction on transport error.  Transport error
@@ -391,8 +450,8 @@ static void staticAllocationHandler(Rm_Handle rmHandle,
         allocNode = rmAllocatorFind(rmHandle, transaction->resourceInfo.name);
 
         if (allocNode &&
-            (transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
-            (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE)) {
+            ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
+             (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE))) {
             /* Check request against static policy */
             memset((void *)&privCheckCfg, 0, sizeof(Rm_PolicyCheckCfg));
 
@@ -440,8 +499,8 @@ static int32_t cdRequestServerResources(Rm_Inst *rmInst,
                                 transaction->resourceInfo.name);
 
     if (allocNode) {
-        if (allocSize = rmPolicyGetCdAllocSize(allocNode->policyRoot)) {
-            if (newTrans = rmTransactionQueueAdd(rmInst)) {
+        if ((allocSize = rmPolicyGetCdAllocSize(allocNode->policyRoot))) {
+            if ((newTrans = rmTransactionQueueAdd(rmInst))) {
                 newTrans->type = transaction->type;
                 rm_strncpy(newTrans->serviceSrcInstName, rmInst->instName,
                            RM_NAME_MAX_CHARS);
@@ -619,6 +678,7 @@ static void allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
                         retVal = cdRequestServerResources(rmInst, transaction);
                     }
                 }
+                /* else: fall through to return */
             } else {
                 retVal = cdRequestServerResources(rmInst, transaction);
             }
@@ -668,6 +728,8 @@ static void allocationHandler (Rm_Inst *rmInst, Rm_Transaction *transaction)
             }
             retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
         }
+    } else {
+        retVal = RM_ERROR_INVALID_INST_TYPE;
     }
 errorExit:
     transaction->state = retVal;
@@ -739,6 +801,8 @@ static void statusHandler(Rm_Inst *rmInst, Rm_Transaction *transaction)
             }
         }
         retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+    } else {
+        retVal = RM_ERROR_INVALID_INST_TYPE;
     }
 errorExit:
     transaction->state = retVal;
@@ -792,6 +856,7 @@ static void freeHandler(Rm_Inst *rmInst, Rm_Transaction *transaction)
              * so request is forwarded to Server */
             retVal = RM_SERVICE_PROCESSING;
         }
+        /* else: fall through to exit */
     } else if ((rmInst->instType == Rm_instType_SERVER) ||
              (rmInst->instType == Rm_instType_SHARED_SERVER)) {
         /* Populated NameServer name has precedence over base */
@@ -814,6 +879,8 @@ static void freeHandler(Rm_Inst *rmInst, Rm_Transaction *transaction)
             }
         }
         retVal = rmAllocatorOperation((Rm_Handle)rmInst, &opInfo);
+    } else {
+        retVal = RM_ERROR_INVALID_INST_TYPE;
     }
 errorExit:
     transaction->state = retVal;
@@ -888,16 +955,17 @@ static void cdProcess(Rm_Inst *rmInst, Rm_Transaction *transaction)
         if (transaction->pendingTransactionId) {
             Rm_Transaction *pendingTrans = rmTransactionQueueFind(rmInst,
                                              transaction->pendingTransactionId);
-            
+
             /* Transaction is response from Server for transaction sent to get
              * information in order to complete pending 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 */
+                    /* Transfer resource data tied to name to pending
+                     * transaction */
                     rm_strncpy(pendingTrans->resourceInfo.name,
                                transaction->resourceInfo.name,
                                RM_NAME_MAX_CHARS);
-                    pendingTrans->resourceInfo.base = transaction->resourceInfo.base;
+                    pendingTrans->resourceInfo.base   = transaction->resourceInfo.base;
                     pendingTrans->resourceInfo.length = transaction->resourceInfo.length;
                     /* Delete NS name from pending transaction so Server isn't
                      * queried again */
@@ -942,6 +1010,8 @@ static void cdProcess(Rm_Inst *rmInst, Rm_Transaction *transaction)
 
                     /* Allow original free to complete */
                     pendingTrans->state = RM_SERVICE_APPROVED;
+                } else {
+                    pendingTrans->state = RM_ERROR_SERVER_RESP_INVALID_SERVICE_TYPE;
                 }
             } else {
                 if (transaction->type == Rm_service_RESOURCE_FREE) {
@@ -996,35 +1066,56 @@ static void cdProcess(Rm_Inst *rmInst, Rm_Transaction *transaction)
             }
         }
 
-        if ((transaction->type == Rm_service_RESOURCE_ALLOCATE_INIT) ||
-            (transaction->type == Rm_service_RESOURCE_ALLOCATE_USE)) {
-            if (transaction->state == RM_SERVICE_PROCESSING) {
-                allocationHandler(rmInst, transaction);
-            }
-        } else if (transaction->type == Rm_service_RESOURCE_STATUS) {
-            if (transaction->state == RM_SERVICE_PROCESSING) {
-                statusHandler(rmInst, transaction);
-            }
-        } else if (transaction->type == Rm_service_RESOURCE_FREE) {
-            if (transaction->state == RM_SERVICE_PROCESSING) {
-                freeHandler(rmInst, transaction);
+        if (transaction->state == RM_SERVICE_PROCESSING) {
+            switch(transaction->type) {
+                case Rm_service_RESOURCE_ALLOCATE_INIT:
+                case Rm_service_RESOURCE_ALLOCATE_USE:
+                    allocationHandler(rmInst, transaction);
+                    break;
+                case Rm_service_RESOURCE_FREE:
+                    freeHandler(rmInst, transaction);
+                    break;
+                case Rm_service_RESOURCE_STATUS:
+                    statusHandler(rmInst, transaction);
+                    break;
+                case Rm_service_RESOURCE_MAP_TO_NAME:
+                case Rm_service_RESOURCE_GET_BY_NAME:
+                case Rm_service_RESOURCE_UNMAP_NAME:
+                    /* Forward all NameServer-based transactions */
+                    break;
+                default:
+                    transaction->state = RM_ERROR_INVALID_SERVICE_TYPE;
+                    break;
             }
         }
-        /* Forward all NameServer-based transactions */
 
         if (transaction->state == RM_SERVICE_PROCESSING) {
-            /* CD could not complete transaction.  Forward to Server */
+            uint32_t transId = transaction->localId;
+
+            /* NameServer transaction or CD could not complete alloc/free
+             * transaction.  Forward to Server */
             transactionForwarder(rmInst, transaction);
-        } else if (transaction->state != RM_SERVICE_PENDING_SERVER_RESPONSE) {
-            /* Transaction completed by CD or completed response received from
-             * Server.  Return result */
-            if (strncmp(transaction->serviceSrcInstName, rmInst->instName,
-                RM_NAME_MAX_CHARS)) {
-                /* Transaction did not originate on this instance */
-                transactionResponder(rmInst, transaction);
-            } else {
-                /* Transaction originated on this instance */
-                serviceResponder(rmInst, transaction);
+
+            /* Refresh transaction for reentrancy of cases where mix of Client
+             * CD and Server are running on the same core and connected via
+             * transport implemented over direct function calls instead of
+             * traditional transport that returns after sending the data */
+            transaction = rmTransactionQueueFind(rmInst, transId);
+        }
+
+        if (transaction) {
+            if ((transaction->state != RM_SERVICE_PROCESSING) &&
+                (transaction->state != RM_SERVICE_PENDING_SERVER_RESPONSE)) {
+                /* Transaction completed by CD or completed response received
+                 * from Server.  Return result */
+                if (strncmp(transaction->serviceSrcInstName, rmInst->instName,
+                    RM_NAME_MAX_CHARS)) {
+                    /* Transaction did not originate on this instance */
+                    transactionResponder(rmInst, transaction);
+                } else {
+                    /* Transaction originated on this instance */
+                    serviceResponder(rmInst, transaction);
+                }
             }
         }
 
@@ -1097,6 +1188,8 @@ static void serverProcess(Rm_Inst *rmInst, Rm_Transaction *transaction)
                 } else if (transaction->type ==
                            Rm_service_RESOURCE_UNMAP_NAME) {
                     transaction->state = rmNameServerDeleteObject(&nameServerObjCfg);
+                } else {
+                    transaction->state = RM_ERROR_INVALID_SERVICE_TYPE;
                 }
 
                 if (rmInst->instType == Rm_instType_SHARED_SERVER) {
@@ -1219,7 +1312,7 @@ int32_t rmTransactionQueueDelete(Rm_Inst *rmInst, uint32_t transactionId)
  * DESCRIPTION: Routes a received transaction to the appropriate
  *              instance processing routine
  */
-void rmProcessRouter (Rm_Inst *rmInst, Rm_Transaction *transaction)
+void rmProcessRouter(Rm_Inst *rmInst, Rm_Transaction *transaction)
 {
     if (rmInst->instType == Rm_instType_CLIENT) {
         clientProcess(rmInst, transaction);
@@ -1228,6 +1321,8 @@ void rmProcessRouter (Rm_Inst *rmInst, Rm_Transaction *transaction)
     } else if ((rmInst->instType == Rm_instType_SERVER) ||
                (rmInst->instType == Rm_instType_SHARED_SERVER)) {
         serverProcess(rmInst, transaction);
+    } else {
+        transaction->state = RM_ERROR_INVALID_INST_TYPE;
     }
 }
 
@@ -1273,6 +1368,9 @@ int32_t Rm_resourceStatus(Rm_Handle rmHandle, int printResources)
             Rm_osalLog("Type:   Shared Server\n");
         } else if (rmInst->instType == Rm_instType_SHARED_CLIENT) {
             Rm_osalLog("Type:   Shared Client\n");
+        } else {
+            Rm_osalLog("Type:   UNKNOWN\n");
+            goto errorExit;
         }
 
         Rm_osalLog("\nResource Status:\n\n");
@@ -1349,6 +1447,7 @@ int32_t Rm_resourceStatus(Rm_Handle rmHandle, int printResources)
         totalResOwners = RM_ERROR_INVALID_RES_STATUS_INSTANCE;
     }
 
+errorExit:
     /* Free sem object using originating instance in case the Shared Client to Shared
      * Server instance switch took place */
     if (((Rm_Inst *)rmHandle)->mtSemObj) {
@@ -1397,6 +1496,9 @@ void Rm_instanceStatus(Rm_Handle rmHandle)
         rmInst = rmInst->u.sharedClient.sharedServerHandle;
         Rm_osalLog("Instance name: %s\n", rmInst->instName);
         Rm_osalLog("Handle: 0x%08x\n", rmHandle);
+    } else {
+        Rm_osalLog("Type:   UNKNOWN\n");
+        goto errorExit;
     }
 
     transportList = rmInst->transports;
@@ -1445,6 +1547,7 @@ void Rm_instanceStatus(Rm_Handle rmHandle)
         }
     }
 
+errorExit:
     /* Free sem object using originating instance in case the Shared Client
      * to Shared Server instance switch took place */
     if (((Rm_Inst *)rmHandle)->mtSemObj) {
@@ -1582,6 +1685,9 @@ Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
             *result = RM_ERROR_INVALID_SHARED_SERVER_HANDLE;
             goto errorExit;
         }
+    } else {
+        *result = RM_ERROR_INVALID_INST_TYPE;
+        goto errorExit;
     }
 
     if (initCfg->instType == Rm_instType_SHARED_SERVER) {
@@ -1594,6 +1700,7 @@ Rm_Handle Rm_init(const Rm_InitCfg *initCfg, int32_t *result)
         /* Create the instance's task blocking mechanism */
         rmInst->blockHandle = Rm_osalTaskBlockCreate();
     }
+    /* else: fall through */
 
     return((Rm_Handle)rmInst);
 
@@ -1630,6 +1737,7 @@ int32_t Rm_delete(Rm_Handle rmHandle, int ignorePendingServices)
     } else if (rmInst->transactionQueue && !ignorePendingServices) {
         return(RM_ERROR_CANT_DELETE_PENDING_TRANSACTIONS);
     }
+    /* else: delete instance since no more deletion failure cases */
 
     if (rmInst->instType != Rm_instType_SHARED_CLIENT) {
         rmNameServerDelete(rmHandle);
index 8864f5ed8cfdce19e6bbc616aa728b8de1da95c3..9ffc1feab7a847d68653d157479e48e1f6e528e8 100644 (file)
@@ -211,7 +211,7 @@ static int allocatorResNodeBoundaryCompare(Rm_ResourceNode *node1,
     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);
@@ -221,6 +221,7 @@ static int allocatorResNodeBoundaryCompare(Rm_ResourceNode *node1,
                 return(RM_TRUE);
             }
         }
+        /* else: fall through to return false, not neighbors */
     }
     return(RM_FALSE);
 }
@@ -637,7 +638,7 @@ static int32_t allocatorAllocate(Rm_Handle rmHandle,
     if (matchingNode) {
         findEnd = findNode.base + findNode.length - 1;
         matchingEnd = matchingNode->base + matchingNode->length - 1;
-        
+
         if ((findNode.base >= matchingNode->base) && (findEnd <= matchingEnd)) {
             if (opInfo->serviceInstNode == rmPolicyGetLinuxInstNode(rmHandle)) {
                 /* Bypass policy checks since Linux Kernel has full
@@ -885,7 +886,7 @@ static int32_t allocatorAllocate(Rm_Handle rmHandle,
                         opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle,
                                                     leftNode,
                                                     opInfo->serviceInstNode);
-                    } else if (findEnd == matchingEnd) {
+                    } else /* (findEnd == matchingEnd) */ {
                         /* findNode end and matchingNode end are equivalent.
                          * May be combine possibilities to the right
                          *
@@ -1052,7 +1053,7 @@ static int32_t allocatorFree(Rm_Handle rmHandle, Rm_AllocatorNode *allocator,
                             rmResourceNodeFree(leftNode);
                             if (rightNode) {
                                 RB_INSERT(_Rm_AllocatorResourceTree,
-                                          allocator->resourceRoot, rightNode); 
+                                          allocator->resourceRoot, rightNode);
                             }
                         } else if (combineRight) {
                             /* Combine right and matching nodes.
@@ -1188,7 +1189,7 @@ static int32_t allocatorFree(Rm_Handle rmHandle, Rm_AllocatorNode *allocator,
                             opInfo->resourceInfo->instAllocCount = allocatorResNodeOwnerGetRefCnt(rmHandle,
                                                     leftNode,
                                                     opInfo->serviceInstNode);
-                        } else if (findEnd == matchingEnd) {
+                        } else /* (findEnd == matchingEnd) */ {
                             /* Case 4: Free range is on right boundary of
                              *         matched node. Try to combine free range
                              *         with right node.
@@ -1304,6 +1305,7 @@ static int32_t allocatorReserveLinuxResource(Rm_Handle rmHandle,
             opInfo->resourceInfo->length = linuxValues->value;
             lengthFound = RM_TRUE;
         }
+        /* else: value was not a base or length so skip to next alias value */
 
         linuxValues = (Rm_LinuxValueRange *)linuxValues->nextValue;
         valueIndex++;
@@ -1450,7 +1452,7 @@ static int32_t allocatorPopulateResTree(Rm_ResourceTree *resTree,
     int32_t retVal = RM_OK;
 
     while (range != NULL) {
-        if (resNode = rmResourceNodeNew(range->base, range->length)) {
+        if ((resNode = rmResourceNodeNew(range->base, range->length))) {
             RB_INSERT(_Rm_AllocatorResourceTree, resTree,
                       resNode);
         } else {
@@ -1494,7 +1496,7 @@ static Rm_AllocatorNode *allocatorInitNode(Rm_Inst *rmInst,
             goto errorExit;
         }
 
-        if (resTree = Rm_osalMalloc(sizeof(*resTree))) {
+        if ((resTree = Rm_osalMalloc(sizeof(*resTree)))) {
             RB_INIT(resTree);
             newAllocNode->resourceRoot = resTree;
         } else {
@@ -1502,7 +1504,7 @@ static Rm_AllocatorNode *allocatorInitNode(Rm_Inst *rmInst,
             goto errorExit;
         }
 
-        if (polTree = Rm_osalMalloc(sizeof(*polTree))) {
+        if ((polTree = Rm_osalMalloc(sizeof(*polTree)))) {
             RB_INIT(polTree);
             newAllocNode->policyRoot = polTree;
         } else {
@@ -1708,6 +1710,7 @@ static int32_t allocatorPopulateGrlBased(Rm_Inst *rmInst, void *grlDtb,
                 retVal = propOffset;
                 goto errorExit;
             }
+            /* else: fall through to get next property */
         }
         if (propOffset < -FDT_ERR_NOTFOUND) {
             /* Error returned by LIBFDT */
@@ -1727,7 +1730,7 @@ errorExit:
     return(retVal);
 }
 
-/* FUNCTION PURPOSE: Populate the allocator tree based on the GRL
+/* FUNCTION PURPOSE: Populate the allocator tree based on the Policy DTB
  ***********************************************************************
  * DESCRIPTION: Populates the allocator tree using the policy DTB.  The
  *              resource trees in each allocator will be created on the fly
@@ -1778,6 +1781,8 @@ static int32_t allocatorPopulatePolicyBased(Rm_Inst *rmInst, void *policyDtb)
                 retVal = RM_ERROR_UNKNOWN_POLICY_RESOURCE_PROPERTY;
                 goto errorExit;
             }
+            /* else: fall through to get next property since read property
+             *       wasn't an assignment */
 
             propOffset = fdt_next_property_offset(policyDtb, propOffset);
         }
@@ -1925,7 +1930,7 @@ int32_t rmAllocatorOperation(Rm_Handle rmHandle, Rm_AllocatorOpInfo *opInfo)
     Rm_AllocatorNode *allocator = NULL;
     int32_t           retVal;
 
-    if (allocator = rmAllocatorFind(rmHandle, opInfo->resourceInfo->name)) {
+    if ((allocator = rmAllocatorFind(rmHandle, opInfo->resourceInfo->name))) {
         if (rmInst->instType == Rm_instType_SHARED_SERVER) {
             rmResourceTreeInv(allocator->resourceRoot);
         }
@@ -1940,6 +1945,8 @@ int32_t rmAllocatorOperation(Rm_Handle rmHandle, Rm_AllocatorOpInfo *opInfo)
             retVal = allocatorAllocate(rmHandle, allocator, opInfo);
         } else if (opInfo->operation == Rm_allocatorOp_FREE) {
             retVal = allocatorFree(rmHandle, allocator, opInfo);
+        } else {
+            retVal = RM_ERROR_INVALID_SERVICE_TYPE;
         }
 
         if ((rmInst->instType == Rm_instType_SHARED_SERVER) &&
@@ -1970,14 +1977,14 @@ int32_t rmAllocatorTreeInit(Rm_Handle rmHandle, void *grlDtb,
     }
 
     if (grlDtb && policyDtb &&
-        (rmInst->instType == Rm_instType_SERVER) ||
-        (rmInst->instType == Rm_instType_SHARED_SERVER)) {
+        ((rmInst->instType == Rm_instType_SERVER) ||
+         (rmInst->instType == Rm_instType_SHARED_SERVER))) {
         /* Create an allocator for each resource node in GRL.  Companion
          * policy info will be pulled and placed into policy tree */
         retVal = allocatorPopulateGrlBased(rmInst, grlDtb, policyDtb, linuxDtb);
     } else if (policyDtb &&
-               (rmInst->instType == Rm_instType_CLIENT_DELEGATE) ||
-               (rmInst->instType == Rm_instType_CLIENT)) {
+               ((rmInst->instType == Rm_instType_CLIENT_DELEGATE) ||
+                (rmInst->instType == Rm_instType_CLIENT))) {
         /* Create an allocator for each resource node in the policy.
          * Resource tree portion of the allocator will be NULL.  Resource
          * trees will be added at run time for Client Delegate instances.
@@ -1987,6 +1994,8 @@ int32_t rmAllocatorTreeInit(Rm_Handle rmHandle, void *grlDtb,
     } else if ((rmInst->instType != Rm_instType_CLIENT) &&
                (rmInst->instType != Rm_instType_SHARED_CLIENT)) {
         retVal = RM_ERROR_INVALID_ALLOCATOR_INIT;
+    } else {
+        retVal = RM_ERROR_INVALID_INST_TYPE;
     }
 
 errorExit:
@@ -2009,7 +2018,7 @@ int32_t rmAllocatorAddResNode(Rm_Handle rmHandle, Rm_AllocatorNode *allocator,
         rmResourceTreeInv(allocator->resourceRoot);
     }
 
-    if (resNode = rmResourceNodeNew(resBase, resLen)) {
+    if ((resNode = rmResourceNodeNew(resBase, resLen))) {
         if (RB_INSERT(_Rm_AllocatorResourceTree, allocator->resourceRoot,
                       resNode)) {
             retVal = RM_ERROR_RES_SPECIFIED_MORE_THAN_ONCE;
index 249aeea79a1e6797d6a38e87c15957d7c1fa7049..191f92e0c238961fd6fac0625286d744ed73d80e 100644 (file)
@@ -213,7 +213,7 @@ static void dtbUtilCommonFreeValueList (Rm_ResourceValue *valueList)
  */
 Rm_ResourcePropType rmDtbUtilResGetPropertyType(const char * propertyName)
 {
-    Rm_ResourcePropType propertyType = Rm_resourcePropType_UNKNOWN;
+    Rm_ResourcePropType propertyType;
 
     if(strcmp(dtbUtilResRangeProp, propertyName) == 0) {
         propertyType = Rm_resourcePropType_RESOURCE_RANGE;
@@ -221,8 +221,10 @@ Rm_ResourcePropType rmDtbUtilResGetPropertyType(const char * propertyName)
         propertyType = Rm_resourcePropType_RESOURCE_LINUX_ALIAS;
     } else if(strcmp(dtbUtilResNsAssignmentProp, propertyName) == 0) {
         propertyType = Rm_resourcePropType_NSASSIGNMENT;
+    } else {
+        propertyType = Rm_resourcePropType_UNKNOWN;
     }
-    return (propertyType);
+    return(propertyType);
 }
 
 /* FUNCTION PURPOSE: Extracts a resource range list from a GRL DTB
@@ -472,7 +474,7 @@ void rmDtbUtilResFreeNsAssignmentList (Rm_NsAssignment *nsAssignmentList)
  */
 Rm_PolicyPropType rmDtbUtilPolicyGetPropertyType(const char * propertyName)
 {
-    Rm_PolicyPropType propertyType = Rm_policyPropType_UNKNOWN;
+    Rm_PolicyPropType propertyType;
 
     if(strcmp(dtbUtilPolicyAssignments, propertyName) == 0) {
         propertyType = Rm_policyPropType_ASSIGNMENTS;
@@ -482,6 +484,8 @@ Rm_PolicyPropType rmDtbUtilPolicyGetPropertyType(const char * propertyName)
         propertyType = Rm_policyPropType_ALLOCATION_ALIGNMENT;
     } else if(strcmp(dtbUtilPolicyValidInstances, propertyName) == 0) {
         propertyType = Rm_policyPropType_VALID_INSTANCES;
+    } else {
+        propertyType = Rm_policyPropType_UNKNOWN;
     }
     return(propertyType);
 }
index 01421dcb8fe6718239bb9aece9ec63167f75c6b5..9b9e211d669948bc2ebe19e72de7c63569cab81e 100644 (file)
@@ -171,7 +171,9 @@ static Rm_PolicyPermission *policyParseSubPermission(char *permStrStart,
             instNameComplete = RM_FALSE;
             instNameIndex = 0;
             foundInstName = RM_FALSE;
-        } else if (instNameIndex == RM_NAME_MAX_CHARS) {
+        }
+
+        if (instNameIndex == RM_NAME_MAX_CHARS) {
             /* Instance name is longer than max length */
             *result = RM_ERROR_INST_NAME_IN_ASSIGNMENT_TOO_LONG;
             goto parseError;
@@ -464,8 +466,8 @@ static int32_t policyStorePermissions(Rm_Inst *rmInst, Rm_PolicyNode *polNode,
         if (!strncmp(extractedPerms->instName, Rm_policyGlobalInst,
                      RM_NAME_MAX_CHARS)) {
             instIdx = RM_POLICY_GLOBAL_PERM_INDEX;
-        } else if (vInst = rmPolicyGetValidInstNode((Rm_Handle)rmInst,
-                                                    extractedPerms->instName)) {
+        } else if ((vInst = rmPolicyGetValidInstNode((Rm_Handle)rmInst,
+                                                   extractedPerms->instName))) {
             instIdx = vInst->instIdx;
         } else {
             retVal = RM_ERROR_PERM_STR_INST_NOT_VALID;
@@ -832,7 +834,9 @@ Rm_PolicyValidInstTree *rmPolicyVInstTreeInit(Rm_Handle rmHandle,
     if (validInstOffset < -FDT_ERR_NOTFOUND) {
         *result = validInstOffset;
         return(NULL);
-    } else if (validInstOffset == -FDT_ERR_NOTFOUND) {
+    }
+
+    if (validInstOffset == -FDT_ERR_NOTFOUND) {
         *result = RM_ERROR_NO_VALID_INST_IN_POLICY;
         return(NULL);
     }
index ed3d758adedc46f57dd7aa6adc3539ba1b8b56a6..97c828d728043c76dde2c2505f29c3f9987b5e40 100644 (file)
@@ -134,7 +134,7 @@ void Rm_serviceHandler (void *rmHandle, const Rm_ServiceReqInfo *serviceRequest,
         rmInst = rmInst->u.sharedClient.sharedServerHandle;
     }
 
-    if (transaction = rmTransactionQueueAdd(rmInst)) {
+    if ((transaction = rmTransactionQueueAdd(rmInst))) {
         transaction->type = serviceRequest->type;
         rm_strncpy(transaction->serviceSrcInstName, instanceName,
                    RM_NAME_MAX_CHARS);
index db14c8853bd65a04cbf2b1be6a23aebb9c3f6a54..a84b021fb162a82226d5a3153639da8a29398681 100644 (file)
@@ -285,7 +285,8 @@ Rm_TransportHandle Rm_transportRegister(const Rm_TransportCfg *transportCfg,
     if (!transportCfg->transportCallouts.rmAllocPkt) {\r
         *result = RM_ERROR_TRANSPORT_ALLOC_PKT_NOT_REGD;\r
         goto errorExit;\r
-    } else if (!transportCfg->transportCallouts.rmSendPkt) {\r
+    }\r
+    if (!transportCfg->transportCallouts.rmSendPkt) {\r
         *result = RM_ERROR_TRANSPORT_SEND_NOT_REGD;\r
         goto errorExit;\r
     }\r
@@ -437,6 +438,9 @@ int32_t Rm_receivePacket(Rm_TransportHandle transportHandle,
             } else if (resourceReqPkt->resourceReqType ==\r
                        Rm_resReqPktType_GET_NAMED) {\r
                 transaction->type = Rm_service_RESOURCE_GET_BY_NAME;\r
+            } else {\r
+                retVal = RM_ERROR_RECEIVED_INVALID_PACKET_TYPE;\r
+                goto errorExit;\r
             }\r
             rm_strncpy(transaction->serviceSrcInstName,\r
                        resourceReqPkt->serviceSrcInstName, RM_NAME_MAX_CHARS);\r
index c775345894a942ce53c032f0da274963217ad5ca..d1769ac755160e2982a77515a83b9491ac68808e 100644 (file)
@@ -59,7 +59,7 @@ LIBS     = -Wl,-static $(RM_LIB) -Wl,-Bdynamic $(DAEMON_LIB)
 endif
 
 # Compiler options
-INTERNALDEFS = $(DEBUG_FLAG) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DMAKEFILE_BUILD
+INTERNALDEFS = $(DEBUG_FLAG) -D__ARMv7 -D_VIRTUAL_ADDR_SUPPORT -D__LINUX_USER_SPACE -D_LITTLE_ENDIAN=1 -DMAKEFILE_BUILD -D_GNU_SOURCE
 
 # Linker options
 INTERNALLINKDEFS = -Wl,--start-group -L $(ARMV7LIBDIR) $(LIBS) -lrt -Wl,--end-group -pthread $(LDFLAGS)
index 92253d12e37aa794733cb63f2640d28154cb6ced..8644f2412f9aaa5c5aa04aeb74d60cd1e461b874 100644 (file)
@@ -185,7 +185,7 @@ Int rmServerExchange_execute(UInt16 procId)
             printf("recv RM pkt failed from socket, "
                    "received = %d, expected = %d\n",
                    err, rm_pkt_len);
-            return;
+            return(-1);
         }
 
         /* send back to DSP */
@@ -206,7 +206,7 @@ cleanup:
 exit:
     printf("Leaving rmServerExchange_execute\n\n");
 
-    return 0;
+    return(0);
 }
 
 int main(int argc, char ** argv)
index b3d658867912521ce2e43be5bd4285f3f6bd71e7..6b546ca91abc3a58006333561369d29d5dd4517e 100644 (file)
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  */
+
+ /* 
+  * Shut off: remark #880-D: parameter "appTransport" was never referenced
+  *
+  * This is better than removing the argument since removal would break
+  * backwards compatibility
+  */
+#ifdef _TMS320C6X
+#pragma diag_suppress 880
+#pragma diag_suppress 681
+#elif defined(__GNUC__)
+ /* Same for GCC:
+  * warning: unused parameter \91appTransport\92 [-Wunused-parameter]
+  */
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
  /* Standard includes */
 #include <stdio.h>
 #include <errno.h>
@@ -311,13 +327,9 @@ Rm_Packet *transportAlloc(Rm_AppTransportHandle appTransport, uint32_t pktSize,
 
 void transportFree (Rm_Packet *rm_pkt)
 {
-    uint32_t pkt_size;
-    int32_t  status;
-
     if (rm_pkt) {
-        pkt_size = rm_pkt->pktLenBytes;
-        free (rm_pkt);
-    }         
+        free(rm_pkt);
+    }
 }
 
 int32_t transportSend (Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle)
@@ -337,7 +349,6 @@ void transportReceive (void)
     int32_t             rm_result;
     int                 retval;
     int                 length = 0;
-    sock_name_t         serv_sock_name;
     sock_name_t         server_sock_addr;
     Rm_Packet          *rm_pkt = NULL;
     struct timeval      tv = {0, CLIENT_SOCK_TIMEOUT_USEC};
@@ -353,7 +364,7 @@ void transportReceive (void)
         return;
     }
     
-    if (length < sizeof(*rm_pkt)) {
+    if (length < ((int)sizeof(*rm_pkt))) {
         error_msg("invalid RM message length %d\n", length);
         return;
     }
@@ -375,8 +386,8 @@ void transportReceive (void)
     
     info_msg("received RM pkt of size %d bytes from %s\n", length, server_sock_addr.s.addr->sun_path);
 
-    /* Provide packet to RM Server for processing */       
-    if (rm_result = Rm_receivePacket(rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].transportHandle, rm_pkt)) {
+    /* Provide packet to RM Server for processing */
+    if ((rm_result = Rm_receivePacket(rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].transportHandle, rm_pkt))) {
         printf("RM failed to process received packet: %d\n", rm_result);
     }
 
@@ -826,7 +837,6 @@ void connection_setup(void)
     int32_t         rm_result;
     int             i;
     sock_name_t     sock_name;
-    int32_t         result = 0;
     char            server_sock_name[] = RM_SERVER_SOCKET_NAME;
     
     /* Initialize the transport map */
@@ -834,14 +844,14 @@ void connection_setup(void)
         rmTransportMap[i].transportHandle = NULL;
     }
 
-       sock_name.type = sock_name_e;
-       sock_name.s.name = rmClientSockName;
+    sock_name.type = sock_name_e;
+    sock_name.s.name = rmClientSockName;
 
-       rmClientSocket = sock_open(&sock_name);
-       if (!rmClientSocket) {
-               error_msg("Client socket open failed\n");
-               exit(EXIT_FAILURE);
-       }
+    rmClientSocket = sock_open(&sock_name);
+    if (!rmClientSocket) {
+        error_msg("Client socket open failed\n");
+        exit(EXIT_FAILURE);
+    }
 
     rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock = calloc(1, sizeof(sock_name_t));
     rmTransportMap[SERVER_TO_CLIENT_MAP_ENTRY].remote_sock->type = sock_name_e;    
@@ -861,12 +871,11 @@ int main(int argc, char *argv[])
 {
     int                 fd;
     struct stat         file_stat;
-    char               *static_policy_addr = NULL;    
+    char               *static_policy_addr = NULL;
     Rm_InitCfg          rmInitCfg;
-    int                status;
-    Rm_ServiceReqInfo  requestInfo;
-    Rm_ServiceRespInfo responseInfo;
-    int32_t            result;
+    Rm_ServiceReqInfo   requestInfo;
+    Rm_ServiceRespInfo  responseInfo;
+    int32_t             result;
 
     printf ("*********************************************************\n");
     printf ("*************** RM Linux Client Testing *****************\n");
@@ -880,7 +889,7 @@ int main(int argc, char *argv[])
     if (argc > 2)
     {
         error_msg("Invalid number of input arguments\n");
-        exit(EXIT_FAILURE);        
+        exit(EXIT_FAILURE);
     }
 
     if (argc == 2){
@@ -981,8 +990,8 @@ int main(int argc, char *argv[])
 
     connection_setup();
     client_test();
-    cleanup();    
+    cleanup();
 
-    return (0);    
+    return (0);
 }
 
index 47b34d281132ea8b3f73c7833ad9bb8fa659d4ae..e37be0fcc1bd1b45f6e13c5f3e7e304bb2730a42 100644 (file)
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  */
+
+ /* 
+  * Shut off: remark #880-D: parameter "appTransport" was never referenced
+  *
+  * This is better than removing the argument since removal would break
+  * backwards compatibility
+  */
+#ifdef _TMS320C6X
+#pragma diag_suppress 880
+#pragma diag_suppress 681
+#elif defined(__GNUC__)
+ /* Same for GCC:
+  * warning: unused parameter \91appTransport\92 [-Wunused-parameter]
+  */
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
  /* Standard includes */
 #include <stdio.h>
 #include <errno.h>
@@ -261,7 +277,7 @@ void transportReceive (void)
     int                 length = 0;
     sock_name_t         server_sock_addr;
     Rm_Packet          *rm_pkt = NULL;
-    struct sockaddr_un  server_addr;    
+    struct sockaddr_un  server_addr;
     
     retval = sock_wait(client_sock, &length, NULL, -1);
     if (retval == -2) {
@@ -274,7 +290,7 @@ void transportReceive (void)
         return;
     }
     
-    if (length < sizeof(*rm_pkt)) {
+    if (length < ((int)sizeof(*rm_pkt))) {
         printf("invalid RM message length %d\n", length);
         test_errors++;
         return;
@@ -297,7 +313,7 @@ void transportReceive (void)
     }
 
     /* Provide packet to RM Server for processing */       
-    if (rm_result = Rm_receivePacket(rm_trans_map[MAP_ENTRY_SERVER_TO_CLIENT].transport_handle, rm_pkt)) {
+    if ((rm_result = Rm_receivePacket(rm_trans_map[MAP_ENTRY_SERVER_TO_CLIENT].transport_handle, rm_pkt))) {
         printf("RM failed to process received packet: %d\n", rm_result);
     }
 
@@ -331,7 +347,6 @@ int32_t transportSendRcv(Rm_AppTransportHandle appTransport, Rm_PacketHandle pkt
 void *allocate_test (void *args)
 {
     uint32_t           *thread_num = (uint32_t *)args;
-    int32_t             result;
     Rm_ServiceReqInfo   request;
     Rm_ServiceRespInfo  response;
     uint32_t            i;
@@ -379,7 +394,6 @@ error_exit:
 
 void resource_cleanup(void)
 {
-    int32_t            result;
     Rm_ServiceReqInfo  request;
     Rm_ServiceRespInfo response;
     uint32_t           i;
@@ -415,7 +429,6 @@ void connection_setup(void)
     int32_t         rm_result;
     int             i;
     sock_name_t     sock_name;
-    int32_t         result = 0;
     char            server_sock_name[] = RM_SERVER_SOCKET_NAME;
 
     printf("Setting up socket connection to RM Server\n");
@@ -425,14 +438,14 @@ void connection_setup(void)
         rm_trans_map[i].transport_handle = NULL;
     }
 
-       sock_name.type = sock_name_e;
-       sock_name.s.name = client_sock_name;
+    sock_name.type = sock_name_e;
+    sock_name.s.name = client_sock_name;
 
-       client_sock = sock_open(&sock_name);
-       if (!client_sock) {
-               printf("Client socket open failed\n");
-               exit(EXIT_FAILURE);
-       }
+    client_sock = sock_open(&sock_name);
+    if (!client_sock) {
+        printf("Client socket open failed\n");
+        exit(EXIT_FAILURE);
+    }
 
     rm_trans_map[MAP_ENTRY_SERVER_TO_CLIENT].remote_sock = calloc(1, sizeof(sock_name_t));
     rm_trans_map[MAP_ENTRY_SERVER_TO_CLIENT].remote_sock->type = sock_name_e;    
@@ -445,7 +458,7 @@ void connection_setup(void)
     rm_trans_cfg.remoteInstType = Rm_instType_SERVER;
     rm_trans_cfg.transportCallouts.rmAllocPkt = transportAlloc;
     rm_trans_cfg.transportCallouts.rmSendPkt = transportSendRcv;
-    rm_trans_map[MAP_ENTRY_SERVER_TO_CLIENT].transport_handle = Rm_transportRegister(&rm_trans_cfg, &rm_result);    
+    rm_trans_map[MAP_ENTRY_SERVER_TO_CLIENT].transport_handle = Rm_transportRegister(&rm_trans_cfg, &rm_result);
 }
 
 void connection_close(void)
@@ -466,8 +479,8 @@ int32_t client_init(void)
     int32_t    result;
 
     /* Initialize the pthread mutex */
-    if (pthread_result = pthread_mutex_init(&client_mutex_lock, NULL)) {
-        printf("Error : Failed to init client pthread mutex with error code: \n", pthread_result);
+    if ((pthread_result = pthread_mutex_init(&client_mutex_lock, NULL))) {
+        printf("Error : Failed to init client pthread mutex with error code: %d\n", pthread_result);
         test_errors++;
         goto error_exit;
     }
@@ -503,7 +516,7 @@ void client_cleanup(void)
     printf("Deleting RM Client\n");
 
     if (service_handle) {
-        Rm_serviceCloseHandle(service_handle);
+        result = Rm_serviceCloseHandle(service_handle);
         ERROR_CHECK(RM_OK, result, client_name, "Service handle close failed");
     }
     
@@ -512,15 +525,14 @@ void client_cleanup(void)
         ERROR_CHECK(RM_OK, result, client_name, "Instance delete failed");
     }
     
-    if (pthread_result = pthread_mutex_destroy(&client_mutex_lock)) {
-        printf("Error : Failed to destroy client pthread mutex with error code: \n", pthread_result);
+    if ((pthread_result = pthread_mutex_destroy(&client_mutex_lock))) {
+        printf("Error : Failed to destroy client pthread mutex with error code: %d\n", pthread_result);
         test_errors++;
     }
 }
 
 int main(int argc, char *argv[])
 {
-    int32_t     result;
     int32_t     malloc_free_diff;
     int32_t     byte_free_diff;
     task_handle first_th;
index 6646f28242f528f6558c505f8dc47810c9c29e63..4663a604eb9c6266bde3e552c17bc7e03d590a2c 100644 (file)
@@ -6,7 +6,7 @@
  *
  *  \par
  *  ============================================================================
- *  @n   (C) Copyright 2012-2014, Texas Instruments, Inc.
+ *  @n   (C) Copyright 2012-2015, Texas Instruments, Inc.
  *
  *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions
  *  \par
 */
 
+/* 
+ * Shut off: remark #880-D: parameter "CsHandle, mtSemObj, etc." are function
+ *           input parameters but not referenced if the OSAL function is not
+ *           used.
+ *
+ * The input arguments can't be removed without breaking the OSAL usage
+ */
+#ifdef _TMS320C6X
+#pragma diag_suppress 880
+#pragma diag_suppress 681
+#elif defined(__GNUC__)
+/* Same for GCC:
+ * warning: unused parameter CsHandle, mtSemObj, etc. [-Wunused-parameter]
+ */
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
 /* Standard Includes */
+#include <stdio.h>
 #include <stdint.h>
 #include <stdarg.h>
 #include <stdlib.h>
@@ -73,8 +91,8 @@ void *Osal_rmMalloc (uint32_t num_bytes)
     rmMallocCounter++;
     rmByteAlloc += num_bytes;
 
-       /* Allocate memory. */
-       return calloc(1, num_bytes);
+    /* Allocate memory. */
+    return calloc(1, num_bytes);
 }
 
 /* FUNCTION PURPOSE: Frees memory
@@ -87,7 +105,7 @@ void Osal_rmFree (void *ptr, uint32_t size)
     /* Increment the free counter. */
     rmFreeCounter++;
     rmByteFree += size;
-       free(ptr);
+    free(ptr);
 }
 
 /* FUNCTION PURPOSE: Critical section enter
@@ -101,7 +119,7 @@ void Osal_rmFree (void *ptr, uint32_t size)
  */  
 void *Osal_rmCsEnter(void)
 {
-    return NULL;
+    return(NULL);
 }
 
 /* FUNCTION PURPOSE: Critical section exit
index e1f1f8a1b649eabaa24e8edccc23e539f2a0e1ca..ab7e80f59572bbe012b206f1908e8069346e7fcc 100644 (file)
  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* 
+ * Shut off: remark #880-D: parameter "appTransport" was never referenced
+ *
+ * This is better than removing the argument since removal would break
+ * backwards compatibility
+ */
+#ifdef _TMS320C6X
+#pragma diag_suppress 880
+#pragma diag_suppress 681
+#elif defined(__GNUC__)
+/* Same for GCC:
+ * warning: unused parameter \91appTransport\92 [-Wunused-parameter]
+ */
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
 /* Standard includes */
 #include <stdio.h>
 #include <errno.h>
@@ -65,6 +81,8 @@
         exit(EXIT_FAILURE);                                               \
     }
 
+#define MAX_LOG_LEVEL LOG_DEBUG
+
 /* logging errors */
 #define error_msg(...) rmsrv_log(LOG_ERR, __func__, __FILE__, __LINE__, __VA_ARGS__);
 /* logging warnings */
@@ -130,35 +148,37 @@ void rmsrv_log(const int loglevel, const char* functionName, const char* fileNam
     va_list     args;
     struct stat fbuf;
 
-    snprintf(lineno_a, sizeof(lineno_a), "%d", lineNo);
+    if (loglevel <= MAX_LOG_LEVEL) {
+        snprintf(lineno_a, sizeof(lineno_a), "%d", lineNo);
 
-    rmsrv_log_buf[0] = 0;
+        rmsrv_log_buf[0] = 0;
 
-    LOG_APPEND(fileName);
-    LOG_APPEND(":");
-    LOG_APPEND(lineno_a);
-    LOG_APPEND(":");
-    LOG_APPEND(functionName);
-    LOG_APPEND(":");
+        LOG_APPEND(fileName);
+        LOG_APPEND(":");
+        LOG_APPEND(lineno_a);
+        LOG_APPEND(":");
+        LOG_APPEND(functionName);
+        LOG_APPEND(":");
 
-    len = MAX_PRE_LOG_BUF_LEN - strlen(rmsrv_log_buf);
-    if (len <= 0) {
-        return;
-    }
+        len = MAX_PRE_LOG_BUF_LEN - strlen(rmsrv_log_buf);
+        if (len <= 0) {
+            return;
+        }
 
-    va_start(args, format);
-    vsnprintf(&rmsrv_log_buf[strlen(rmsrv_log_buf)], len, format, args);
-    va_end(args);
+        va_start(args, format);
+        vsnprintf(&rmsrv_log_buf[strlen(rmsrv_log_buf)], len, format, args);
+        va_end(args);
 
-    /* logfile reset if going over max_len */
-    if (fstat(fileno(rmsrv_cfg.logfile_p), &fbuf) == 0) {
-        if ((fbuf.st_size + strlen(rmsrv_log_buf)) > rmsrv_cfg.logfile_max_len) {
-            freopen(RMSERVER_DAEMON_LOG_FILE_NAME, "w+", rmsrv_cfg.logfile_p);
+        /* logfile reset if going over max_len */
+        if (fstat(fileno(rmsrv_cfg.logfile_p), &fbuf) == 0) {
+            if ((fbuf.st_size + ((int)strlen(rmsrv_log_buf))) > rmsrv_cfg.logfile_max_len) {
+                freopen(RMSERVER_DAEMON_LOG_FILE_NAME, "w+", rmsrv_cfg.logfile_p);
+            }
         }
-    }
 
-    fprintf(rmsrv_cfg.logfile_p, "%s", rmsrv_log_buf);
-    fflush(rmsrv_cfg.logfile_p);
+        fprintf(rmsrv_cfg.logfile_p, "%s", rmsrv_log_buf);
+        fflush(rmsrv_cfg.logfile_p);
+    }
 }
 
 Rm_Packet *transportAlloc(Rm_AppTransportHandle appTransport, uint32_t pktSize, Rm_PacketHandle *pktHandle)
@@ -177,13 +197,11 @@ Rm_Packet *transportAlloc(Rm_AppTransportHandle appTransport, uint32_t pktSize,
     return(rm_pkt);
 }
 
-void transportFree (Rm_Packet *rm_pkt)
+void transportFree(Rm_Packet *rm_pkt)
 {
-    int32_t status;
-
     if (rm_pkt) {
-        free (rm_pkt);
-    }         
+        free(rm_pkt);
+    }
 }
 
 int32_t transportSend (Rm_AppTransportHandle appTransport, Rm_PacketHandle pktHandle)
@@ -262,7 +280,7 @@ int rm_server_run(void *grl, void *policy, void *lin_dtb, int is_daemon)
             goto loop_continue;
         }
 
-        if (length < sizeof(rm_pkt)) {
+        if (length < ((int)sizeof(rm_pkt))) {
             error_msg("invalid RM message length %d\n", length);
             goto loop_continue;
         }
@@ -333,7 +351,7 @@ int rm_server_run(void *grl, void *policy, void *lin_dtb, int is_daemon)
         }
 
         /* Provide packet to RM Server for processing */       
-        if (rm_result = Rm_receivePacket(map_index->trans_handle, rm_pkt)) {
+        if ((rm_result = Rm_receivePacket(map_index->trans_handle, rm_pkt))) {
             error_msg("RM failed to process received packet: %d\n", rm_result);
         }
         
@@ -514,7 +532,7 @@ int main(int argc, char *argv[])
             exit(EXIT_FAILURE);
         }
 
-        if (check_and_create_path (get_pid_file_name()) < 0) {
+        if (check_and_create_path(get_pid_file_name()) < 0) {
             printf("Failed to create pid file path: %s\n", get_pid_file_name());
             exit(EXIT_FAILURE);
         }
@@ -559,7 +577,7 @@ int main(int argc, char *argv[])
             }
 
             printf("Daemon returned %i as return value.\n", ret);
-            return ret;
+            return(ret);
         }
 
         /* Close FDs */
@@ -603,6 +621,8 @@ close_n_exit:
         daemon_retval_send(255);
         daemon_signal_done();
         daemon_pid_file_remove();
-    }    
+    }
+
+    return(0);
 }
 
index 8f18f10bf08f5d8fc672e525fdc5396105a6f8df..d411435d53083a1bdedf66bb8677a9f986af1ad3 100644 (file)
  *  \par
 */
 
+/* 
+ * Shut off: remark #880-D: parameter "CsHandle, mtSemObj, etc." are function
+ *           input parameters but not referenced if the OSAL function is not
+ *           used.
+ *
+ * The input arguments can't be removed without breaking the OSAL usage
+ */
+#ifdef _TMS320C6X
+#pragma diag_suppress 880
+#pragma diag_suppress 681
+#elif defined(__GNUC__)
+/* Same for GCC:
+ * warning: unused parameter CsHandle, mtSemObj, etc. [-Wunused-parameter]
+ */
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
 /* Standard Includes */
 #include <stdint.h>
 #include <stdarg.h>
@@ -83,8 +100,8 @@ void *Osal_rmMalloc (uint32_t num_bytes)
     rmMallocCounter++;
     rmByteAlloc += num_bytes;
 
-       /* Allocate memory. */
-       return calloc(1, num_bytes);
+    /* Allocate memory. */
+    return calloc(1, num_bytes);
 }
 
 /* FUNCTION PURPOSE: Frees memory
@@ -97,7 +114,7 @@ void Osal_rmFree (void *ptr, uint32_t size)
     /* Increment the free counter. */
     rmFreeCounter++;
     rmByteFree += size;
-       free(ptr);
+    free(ptr);
 }
 
 /* FUNCTION PURPOSE: Critical section enter
@@ -235,7 +252,7 @@ void Osal_rmLog (char *fmt, ... )
 
     /* logfile reset if going over max_len */
     if (fstat(fileno(rmsrv_cfg.logfile_p), &fbuf) == 0) {
-        if ((fbuf.st_size + strlen(rmsrv_log_buf)) > rmsrv_cfg.logfile_max_len) {
+        if ((fbuf.st_size + ((int)strlen(rmsrv_log_buf))) > rmsrv_cfg.logfile_max_len) {
             freopen(RMSERVER_DAEMON_LOG_FILE_NAME, "w+", rmsrv_cfg.logfile_p);
         }
     }
index 57cdacb60f7462c41422369610d5d03c5ef82628..fafddccdce440e9443e2e0025228e28231e106ed 100644 (file)
@@ -50,13 +50,13 @@ typedef struct sock_data {
        int fd;
 } sock_data_t;
 
-int check_and_create_path (char *path)
+int check_and_create_path(char *path)
 {
        char *d = path;
        if (!d)
                return -1;
 
-       while (d = strchr(d + 1, '/')) {
+       while ((d = strchr(d + 1, '/'))) {
                *d = 0;
                if (mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) < 0) {
                        if (errno != EEXIST) {
@@ -230,8 +230,6 @@ int sock_wait (sock_h handle, int *size, struct timeval *timeout, int extern_fd)
 int sock_recv (sock_h handle, char *data, int length, sock_name_t *from)
 {
        int size;
-       int retval;
-       fd_set fds;
        sock_data_t *sd = (sock_data_t *) handle;
        socklen_t from_length = 0;
 
index dc5d811eef40d85db4807a53fc44cae968a273dc..92d65b375126926b9f87dadb34d6e27420e92b90 100644 (file)
@@ -58,6 +58,8 @@ typedef struct {
 
 #define sock_h void *
 
+int check_and_create_path(char *path);
+
 sock_h sock_open (sock_name_t *sock_name);
 
 int sock_close (sock_h handle);