From: Sam Nelson Date: Sat, 5 Oct 2019 03:27:53 +0000 (-0400) Subject: VirtQueue: Avoid mismatch of types in comparison X-Git-Tag: 3.50.04.07A~54 X-Git-Url: https://git.ti.com/gitweb?p=ipc%2Fipcdev.git;a=commitdiff_plain;h=9ed4f4615f2d1b586252e7e1844c42a67104357e;ds=sidebyside VirtQueue: Avoid mismatch of types in comparison Convert to common unsigned int Also add error check where needed Signed-off-by: Sam Nelson --- diff --git a/packages/ti/ipc/family/tci6614/VirtQueue.c b/packages/ti/ipc/family/tci6614/VirtQueue.c index 286cb5f..c8e0f5b 100644 --- a/packages/ti/ipc/family/tci6614/VirtQueue.c +++ b/packages/ti/ipc/family/tci6614/VirtQueue.c @@ -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 @@ -229,7 +229,7 @@ Int VirtQueue_addUsedBuf(VirtQueue_Handle vq, Int16 head, Int len) 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 { diff --git a/packages/ti/ipc/family/tci6638/VirtQueue.c b/packages/ti/ipc/family/tci6638/VirtQueue.c index d4c9cdf..804bf48 100644 --- a/packages/ti/ipc/family/tci6638/VirtQueue.c +++ b/packages/ti/ipc/family/tci6638/VirtQueue.c @@ -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 @@ -234,7 +234,7 @@ Int VirtQueue_addUsedBuf(VirtQueue_Handle vq, Int16 head, Int len) 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 { diff --git a/packages/ti/ipc/family/vayu/VirtQueue.c b/packages/ti/ipc/family/vayu/VirtQueue.c index e36666b..f4c52a0 100644 --- a/packages/ti/ipc/family/vayu/VirtQueue.c +++ b/packages/ti/ipc/family/vayu/VirtQueue.c @@ -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 @@ -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); + /* Double check , In case Assert is disabled */ + if (result != Registry_SUCCESS) { + return; + } initialized = 1; } @@ -265,7 +269,7 @@ Int VirtQueue_addUsedBuf(VirtQueue_Handle vq, Int16 head, Int len) 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); } @@ -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); + if (result != Resource_S_SUCCESS) { + return NULL; + } vringAddr = (Void *)vq->baseVa; break;