Prevent %-by-0 in Assert_isTrue() expressions 3.40.00.02_eng
authorRobert Tivy <rtivy@ti.com>
Sat, 27 Jun 2015 00:29:48 +0000 (17:29 -0700)
committerRobert Tivy <rtivy@ti.com>
Tue, 30 Jun 2015 01:02:39 +0000 (18:02 -0700)
A few "assert" expressions were using
    <var> % SharedRegion_getCacheLineSize(obj->regionId)
which will generate a "modulo-by-0" error if
    SharedRegion_getCacheLineSize(obj->regionId)
evaluates to (returns) 0.

Fix this by prefacing that expresssion with
    SharedRegion_getCacheLineSize(obj->regionId) == 0 || <expr>

Addresses SDOCM00117013

packages/ti/sdo/ipc/nsremote/NameServerRemoteNotify.c
packages/ti/sdo/ipc/transports/TransportShm.c

index 7cb60be807d1114a6a7006d421533442a979414a..5abac2cfa0418e8a9fc429da74e01880b0677e60 100644 (file)
@@ -102,12 +102,14 @@ Int NameServerRemoteNotify_Instance_init(NameServerRemoteNotify_Object *obj,
     obj->remoteState = NameServerRemoteNotify_IDLE;
 
     /* assert that sharedAddr is cache aligned */
-    Assert_isTrue(((UInt32)params->sharedAddr %
+    Assert_isTrue(SharedRegion_getCacheLineSize(obj->regionId) == 0 ||
+            ((UInt32)params->sharedAddr %
             SharedRegion_getCacheLineSize(obj->regionId) == 0),
             Ipc_A_addrNotCacheAligned);
 
     /* asset message structure size is cache aligned */
-    Assert_isTrue((sizeof(NameServerRemoteNotify_Message) %
+    Assert_isTrue(SharedRegion_getCacheLineSize(obj->regionId) == 0 ||
+            (sizeof(NameServerRemoteNotify_Message) %
             SharedRegion_getCacheLineSize(obj->regionId)) == 0,
             NameServerRemoteNotify_A_messageSize);
 
index 75d3ad41dc5c4b63d6284ef10cc01eede1871f46..b3475f915a0233246f95bbdcd3d0790e75845384 100644 (file)
@@ -178,7 +178,8 @@ Int TransportShm_Instance_init(TransportShm_Object *obj,
                 ti_sdo_ipc_Ipc_A_addrNotInSharedRegion);
 
         /* Assert that sharedAddr is cache aligned */
-        Assert_isTrue(((UInt32)params->sharedAddr %
+        Assert_isTrue(SharedRegion_getCacheLineSize(obj->regionId) == 0 ||
+                ((UInt32)params->sharedAddr %
                 SharedRegion_getCacheLineSize(obj->regionId) == 0),
                 ti_sdo_ipc_Ipc_A_addrNotCacheAligned);