X-Git-Url: https://git.ti.com/gitweb?p=ipc%2Fipcdev.git;a=blobdiff_plain;f=packages%2Fti%2Fsdo%2Fipc%2Fnsremote%2FNameServerMessageQ.c;h=1f0b3a61483db4e5130f76a1d3d4cd403b5c7898;hp=b4007658110dc2e7ab932736a7d75be08bc27179;hb=ac762823ddd75d46ef32bace6d2a66732fb245e5;hpb=04a32bd396e5d4b2fec0d9e01d3188cfc06c93a9 diff --git a/packages/ti/sdo/ipc/nsremote/NameServerMessageQ.c b/packages/ti/sdo/ipc/nsremote/NameServerMessageQ.c index b400765..1f0b3a6 100644 --- a/packages/ti/sdo/ipc/nsremote/NameServerMessageQ.c +++ b/packages/ti/sdo/ipc/nsremote/NameServerMessageQ.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012-2013, Texas Instruments Incorporated + * Copyright (c) 2012-2015 Texas Instruments Incorporated - http://www.ti.com * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -61,7 +61,7 @@ */ #define MAXNAMEINCHAR (NameServerMessageQ_maxNameLen / \ (xdc_target__bitsPerChar / 8)) -#define NAMEARRAYSZIE (((MAXNAMEINCHAR - 1) / sizeof(Bits32)) + 1) +#define NAMEARRAYSIZE (((MAXNAMEINCHAR - 1) / sizeof(Bits32)) + 1) #define MESSAGEQ_INDEX 0 @@ -73,9 +73,9 @@ typedef struct NameServerMsg { Bits32 requestStatus; /* status of request */ Bits32 reserved; /* reserved field */ /* name of NameServer instance */ - Bits32 instanceName[NAMEARRAYSZIE]; + Bits32 instanceName[NAMEARRAYSIZE]; /* name of NameServer entry */ - Bits32 name[NAMEARRAYSZIE]; + Bits32 name[NAMEARRAYSIZE]; } NameServerMsg; /* @@ -120,6 +120,7 @@ Void NameServerMessageQ_Instance_finalize(NameServerMessageQ_Object *obj) Int NameServerMessageQ_Module_startup(Int phase) { MessageQ_Params2 messageQParams; + MessageQ_QueueId queueId; /* Ensure MessageQ and SyncSwi Module_startup() have completed */ if ((ti_sdo_ipc_MessageQ_Module_startupDone() == FALSE) || @@ -137,11 +138,20 @@ Int NameServerMessageQ_Module_startup(Int phase) /* assert msgHandle is not null */ Assert_isTrue(NameServerMessageQ_module->msgHandle != NULL, Ipc_A_nullPointer); + /* Additonal check for case with assert disabled */ + if(NameServerMessageQ_module->msgHandle == NULL) { + return Startup_NOTDONE; + } + queueId = MessageQ_getQueueId((MessageQ_Handle) + NameServerMessageQ_module->msgHandle); /* assert this is the first MessageQ created */ - Assert_isTrue((MessageQ_getQueueId((MessageQ_Handle) - NameServerMessageQ_module->msgHandle) & 0xffff) == MESSAGEQ_INDEX, + Assert_isTrue( (queueId & 0xffff) == MESSAGEQ_INDEX, NameServerMessageQ_A_reservedMsgQueueId); + /* Additonal check for case with assert disabled */ + if ((queueId & 0xffff) != MESSAGEQ_INDEX) { + return Startup_NOTDONE; + } return (Startup_DONE); } @@ -210,7 +220,6 @@ Int NameServerMessageQ_get(NameServerMessageQ_Object *obj, ISync_Handle syncHandle, Error_Block *eb) { - Int len; Int status; IArg key; MessageQ_QueueId queueId; @@ -236,23 +245,21 @@ Int NameServerMessageQ_get(NameServerMessageQ_Object *obj, msg->request = NameServerMessageQ_REQUEST; msg->requestStatus = 0; - /* get the length of instanceName */ - len = strlen(instanceName); - /* assert length is smaller than max (must have room for null character) */ - Assert_isTrue(len < MAXNAMEINCHAR, NameServerMessageQ_A_nameIsTooLong); + Assert_isTrue(strlen(instanceName) < MAXNAMEINCHAR, + NameServerMessageQ_A_nameIsTooLong); /* copy the name of instance into putMsg */ - strncpy((Char *)msg->instanceName, instanceName, len); - - /* get the length of name */ - len = strlen(name); + strncpy((Char *)msg->instanceName, instanceName, MAXNAMEINCHAR - 1); + ((Char *)msg->instanceName) [MAXNAMEINCHAR - 1] = '0'; /* assert length is smaller than max (must have room for null character) */ - Assert_isTrue(len < MAXNAMEINCHAR, NameServerMessageQ_A_nameIsTooLong); + Assert_isTrue(strlen(name) < MAXNAMEINCHAR, + NameServerMessageQ_A_nameIsTooLong); /* copy the name of nameserver entry into putMsg */ - strncpy((Char *)msg->name, name, len); + strncpy((Char *)msg->name, name, MAXNAMEINCHAR - 1); + ((Char *)msg->name) [MAXNAMEINCHAR - 1] = '0'; /* determine the queueId based upon the processor */ queueId = MessageQ_openQueueId(MESSAGEQ_INDEX, obj->remoteProcId);