]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - ipc/ipcdev.git/commitdiff
VirtQueue: Avoid mismatch of types in comparison
authorSam Nelson <sam.nelson@ti.com>
Sat, 5 Oct 2019 03:27:53 +0000 (23:27 -0400)
committerSam Nelson <sam.nelson@ti.com>
Sat, 5 Oct 2019 15:17:45 +0000 (11:17 -0400)
Convert to common unsigned int
Also add error check where needed

Signed-off-by: Sam Nelson <sam.nelson@ti.com>
packages/ti/ipc/family/tci6614/VirtQueue.c
packages/ti/ipc/family/tci6638/VirtQueue.c
packages/ti/ipc/family/vayu/VirtQueue.c

index 286cb5f53fe793be50e1f80f7bae62d482176328..c8e0f5b91c1a4ad2dc5f95ede901da624a968d79 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2011-2015 Texas Instruments Incorporated - http://www.ti.com
+ * Copyright (c) 2011-2019 Texas Instruments Incorporated - http://www.ti.com
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -229,7 +229,7 @@ Int VirtQueue_addUsedBuf(VirtQueue_Handle vq, Int16 head, Int len)
     IArg key;
 
     key = GateAll_enter(vq->gateH);
     IArg key;
 
     key = GateAll_enter(vq->gateH);
-    if ((head > vring->num) || (head < 0)) {
+    if (((unsigned int)head > vring->num) || (head < 0)) {
         Error_raise(NULL, Error_E_generic, 0, 0);
     }
     else {
         Error_raise(NULL, Error_E_generic, 0, 0);
     }
     else {
index d4c9cdf86581e8d1d8c48d1dc52a739e0367641f..804bf48059e1e10d4964ece36726761a8528a72b 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2011-2018 Texas Instruments Incorporated - http://www.ti.com
+ * Copyright (c) 2011-2019 Texas Instruments Incorporated - http://www.ti.com
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -234,7 +234,7 @@ Int VirtQueue_addUsedBuf(VirtQueue_Handle vq, Int16 head, Int len)
     IArg key;
 
     key = GateAll_enter(vq->gateH);
     IArg key;
 
     key = GateAll_enter(vq->gateH);
-    if ((head > vring->num) || (head < 0)) {
+    if (((unsigned int)head > vring->num) || (head < 0)) {
         Error_raise(NULL, Error_E_generic, 0, 0);
     }
     else {
         Error_raise(NULL, Error_E_generic, 0, 0);
     }
     else {
index e36666b9b438c80f68373319d0b9b898b701d815..f4c52a03ba8f449ca70c7949ce31095bf9d5377f 100644 (file)
@@ -1,5 +1,5 @@
 /*
 /*
- * Copyright (c) 2011-2015 Texas Instruments Incorporated - http://www.ti.com
+ * Copyright (c) 2011-2019 Texas Instruments Incorporated - http://www.ti.com
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -228,6 +228,10 @@ static Void _VirtQueue_init()
         /* register with xdc.runtime to get a diags mask */
         result = Registry_addModule(&Registry_CURDESC, MODULE_NAME);
         Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);
         /* register with xdc.runtime to get a diags mask */
         result = Registry_addModule(&Registry_CURDESC, MODULE_NAME);
         Assert_isTrue(result == Registry_SUCCESS, (Assert_Id)NULL);
+        /* Double check , In case Assert is disabled */
+        if (result != Registry_SUCCESS) {
+            return;
+        }
 
         initialized = 1;
     }
 
         initialized = 1;
     }
@@ -265,7 +269,7 @@ Int VirtQueue_addUsedBuf(VirtQueue_Handle vq, Int16 head, Int len)
     IArg key;
 
     key = GateHwi_enter(vq->gateH);
     IArg key;
 
     key = GateHwi_enter(vq->gateH);
-    if ((head > vq->vring.num) || (head < 0)) {
+    if (((unsigned int)head > vq->vring.num) || (head < 0)) {
         GateHwi_leave(vq->gateH, key);
         Error_raise(NULL, Error_E_generic, 0, 0);
     }
         GateHwi_leave(vq->gateH, key);
         Error_raise(NULL, Error_E_generic, 0, 0);
     }
@@ -458,6 +462,9 @@ VirtQueue_Handle VirtQueue_create(UInt16 remoteProcId, VirtQueue_Params *params,
 
             result = Resource_physToVirt(vq->basePa, &(vq->baseVa));
             Assert_isTrue(result == Resource_S_SUCCESS, (Assert_Id)NULL);
 
             result = Resource_physToVirt(vq->basePa, &(vq->baseVa));
             Assert_isTrue(result == Resource_S_SUCCESS, (Assert_Id)NULL);
+            if (result != Resource_S_SUCCESS) {
+                return NULL;
+            }
 
             vringAddr = (Void *)vq->baseVa;
             break;
 
             vringAddr = (Void *)vq->baseVa;
             break;