[PATCH 30/50] [avis] Fixed Compiler Warnings


Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@nyx.com>

Moved variable declarations to the beginning of blocks as intermingling
decarations and code is not allowed pre-C99. Also fixed a few other minor
warnings.

Signed-off-by: Mike Schonberg <mschonberg@nyx.com>
---
mama/c_cpp/src/c/bridge/avis/msg.c | 11 +++++------
mama/c_cpp/src/c/bridge/avis/publisher.c | 30 ++++++++++++++++++------------
mama/c_cpp/src/c/bridge/avis/queue.c | 18 ++++++++++--------
mama/c_cpp/src/c/bridge/avis/sub.c | 6 +++---
mama/c_cpp/src/c/bridge/avis/timer.c | 6 +++---
5 files changed, 39 insertions(+), 32 deletions(-)

diff --git a/mama/c_cpp/src/c/bridge/avis/msg.c b/mama/c_cpp/src/c/bridge/avis/msg.c
index 8cc97eb..b422543 100644
--- a/mama/c_cpp/src/c/bridge/avis/msg.c
+++ b/mama/c_cpp/src/c/bridge/avis/msg.c
@@ -53,10 +53,11 @@ typedef struct avisMsgImpl
mama_status
avisBridgeMamaMsg_create (msgBridge* msg, mamaMsg parent)
{
+ avisMsgImpl* impl;
if (avisMsg(msg) == NULL) return MAMA_STATUS_NULL_ARG;
*msg = NULL;

- avisMsgImpl* impl = (avisMsgImpl*) calloc(1, sizeof(avisMsgImpl));
+ impl = (avisMsgImpl*) calloc(1, sizeof(avisMsgImpl));
if (!impl) return MAMA_STATUS_NOMEM;

mamaMsg_getNativeMsg(parent, (void**)&impl->mAvisMsg);
@@ -109,8 +110,8 @@ avisBridgeMamaMsg_getPlatformError (msgBridge msg, void** error)
mama_status
avisBridgeMamaMsgImpl_setReplyHandle (msgBridge msg, void* result)
{
- CHECK_MSG(msg);
mama_status status = MAMA_STATUS_OK;
+ CHECK_MSG(msg);
if (MAMA_STATUS_OK != (status = mamaMsg_updateString(avisMsg(msg)->mParent, INBOX_FIELD_NAME, 0, (const char*) result))) {
return status;
}
@@ -137,10 +138,9 @@ avisBridgeMamaMsg_setSendSubject (msgBridge msg,
const char* symbol,
const char* subject)
{
+ mama_status status = MAMA_STATUS_OK;
CHECK_MSG(msg);

- // TODO -- symbol?
- mama_status status = MAMA_STATUS_OK;
if (MAMA_STATUS_OK != (status = mamaMsg_updateString(avisMsg(msg)->mParent, SUBJECT_FIELD_NAME, 0, subject))) {
return status;
}
@@ -164,10 +164,9 @@ avisBridgeMamaMsg_getNativeHandle (msgBridge msg, void** result)
mama_status
avisBridgeMamaMsg_duplicateReplyHandle (msgBridge msg, void** result)
{
- CHECK_MSG(msg);
-
const char* replyAddr;
mama_status status = MAMA_STATUS_OK;
+ CHECK_MSG(msg);
if (MAMA_STATUS_OK != (status = mamaMsg_getString(avisMsg(msg)->mParent, INBOX_FIELD_NAME, 0, &replyAddr))) {
return status;
}
diff --git a/mama/c_cpp/src/c/bridge/avis/publisher.c b/mama/c_cpp/src/c/bridge/avis/publisher.c
index bc416fa..faaceb7 100644
--- a/mama/c_cpp/src/c/bridge/avis/publisher.c
+++ b/mama/c_cpp/src/c/bridge/avis/publisher.c
@@ -67,12 +67,14 @@ avisBridgeMamaPublisher_createByIndex (publisherBridge* result,
void* nativeQueueHandle,
mamaPublisher parent)
{
- if (!result || !tport) return MAMA_STATUS_NULL_ARG;
Elvin* avis = getAvis(tport);
+ avisPublisherBridge* publisher = NULL;
+
+ if (!result || !tport) return MAMA_STATUS_NULL_ARG;
CHECK_AVIS(avis);

*result = NULL;
- avisPublisherBridge* publisher = (avisPublisherBridge*) calloc (1, sizeof(avisPublisherBridge));
+ publisher = (avisPublisherBridge*) calloc (1, sizeof(avisPublisherBridge));
if (publisher == NULL)
return MAMA_STATUS_NOMEM;
publisher->mTransport = tport;
@@ -145,10 +147,11 @@ avisBridgeMamaPublisherImpl_buildSendSubject (avisPublisherBridge* impl)
mama_status
avisBridgeMamaPublisher_send (publisherBridge publisher, mamaMsg msg)
{
- CHECK_PUBLISHER(publisher);
mama_size_t dataLen;
mama_status status;
- Attributes* attributes;
+ Attributes* attributes = NULL;
+
+ CHECK_PUBLISHER(publisher);

status = mamaMsgImpl_getPayloadBuffer (msg, (const void**)&attributes, &dataLen);
if (attributes == NULL)
@@ -173,18 +176,20 @@ avisBridgeMamaPublisher_sendReplyToInbox (publisherBridge publisher,
mamaMsg request,
mamaMsg reply)
{
- CHECK_PUBLISHER(publisher);
Attributes* requestMsg = NULL;
Attributes* replyMsg = NULL;
+ const char* replyAddr = NULL;
mama_size_t dataLen;
+ mama_status status;
+
+ CHECK_PUBLISHER(publisher);

mamaMsg_getNativeHandle(request, (void**) &requestMsg);
mamaMsgImpl_getPayloadBuffer (reply, (const void**)&replyMsg, &dataLen);

if (!requestMsg || !replyMsg) return MAMA_STATUS_NULL_ARG;

- const char* replyAddr = NULL;
- mama_status status = mamaMsg_getString(request, INBOX_FIELD_NAME, 0, &replyAddr);
+ status = mamaMsg_getString(request, INBOX_FIELD_NAME, 0, &replyAddr);
if ((status != MAMA_STATUS_OK) || (replyAddr == NULL) || (strlen(replyAddr) == 0)) {
mama_log (MAMA_LOG_LEVEL_ERROR, "avisBridgeMamaPublisher_sendReplyToInbox(): "
"No reply address in message.");
@@ -223,6 +228,8 @@ avisBridgeMamaPublisher_sendFromInboxByIndex (publisherBridge publisher,
mamaInbox inbox,
mamaMsg msg)
{
+ const char* replyAddr = NULL;
+ mama_status status;
// CHECK_PUBLISHER(publisher);
if (avisPublisher(publisher) == 0)
return MAMA_STATUS_NULL_ARG;
@@ -231,13 +238,11 @@ avisBridgeMamaPublisher_sendFromInboxByIndex (publisherBridge publisher,
if (!elvin_is_open(avisPublisher(publisher)->mAvis))
return MAMA_STATUS_INVALID_ARG;

-
-
// get reply address from inbox
- const char* replyAddr = avisInboxImpl_getReplySubject(mamaInboxImpl_getInboxBridge(inbox));
+ replyAddr = avisInboxImpl_getReplySubject(mamaInboxImpl_getInboxBridge(inbox));

// set reply address in msg
- mama_status status = mamaMsg_updateString(msg, INBOX_FIELD_NAME, 0, replyAddr);
+ status = mamaMsg_updateString(msg, INBOX_FIELD_NAME, 0, replyAddr);
if (status != MAMA_STATUS_OK)
return status;

@@ -258,9 +263,10 @@ avisBridgeMamaPublisher_sendReplyToInboxHandle (publisherBridge publisher,
void * inbox,
mamaMsg reply)
{
+ mama_status status;
CHECK_PUBLISHER(publisher);

- mama_status status = mamaMsg_updateString(reply, SUBJECT_FIELD_NAME, 0, (const char*) inbox);
+ status = mamaMsg_updateString(reply, SUBJECT_FIELD_NAME, 0, (const char*) inbox);
if (status != MAMA_STATUS_OK)
return status;

diff --git a/mama/c_cpp/src/c/bridge/avis/queue.c b/mama/c_cpp/src/c/bridge/avis/queue.c
index 24ee8d1..fd8c629 100644
--- a/mama/c_cpp/src/c/bridge/avis/queue.c
+++ b/mama/c_cpp/src/c/bridge/avis/queue.c
@@ -51,11 +51,12 @@ mama_status
avisBridgeMamaQueue_create (queueBridge* queue,
mamaQueue parent)
{
+ avisQueueBridge* avisQueue = NULL;
if (queue == NULL)
return MAMA_STATUS_NULL_ARG;
*queue = NULL;

- avisQueueBridge* avisQueue = (avisQueueBridge*)calloc (1, sizeof (avisQueueBridge));
+ avisQueue = (avisQueueBridge*)calloc (1, sizeof (avisQueueBridge));
if (avisQueue == NULL)
return MAMA_STATUS_NOMEM;

@@ -74,11 +75,12 @@ avisBridgeMamaQueue_create_usingNative (queueBridge* queue,
mamaQueue parent,
void* nativeQueue)
{
+ avisQueueBridge* avisQueue = NULL;
if (queue == NULL)
return MAMA_STATUS_NULL_ARG;
*queue = NULL;

- avisQueueBridge* avisQueue = (avisQueueBridge*)calloc (1, sizeof (avisQueueBridge));
+ avisQueue = (avisQueueBridge*)calloc (1, sizeof (avisQueueBridge));
if (avisQueue == NULL)
return MAMA_STATUS_NOMEM;

@@ -104,9 +106,9 @@ avisBridgeMamaQueue_destroy (queueBridge queue)
mama_status
avisBridgeMamaQueue_dispatch (queueBridge queue)
{
- CHECK_QUEUE(queue);
wombatQueueStatus status;

+ CHECK_QUEUE(queue);
do
{
/* 500 is .5 seconds */
@@ -132,8 +134,8 @@ avisBridgeMamaQueue_dispatch (queueBridge queue)
mama_status
avisBridgeMamaQueue_timedDispatch (queueBridge queue, uint64_t timeout)
{
- CHECK_QUEUE(queue);
wombatQueueStatus status;
+ CHECK_QUEUE(queue);

status = wombatQueue_timedDispatch (avisQueue(queue)->mQueue,
NULL, NULL, timeout);
@@ -154,8 +156,8 @@ avisBridgeMamaQueue_timedDispatch (queueBridge queue, uint64_t timeout)
mama_status
avisBridgeMamaQueue_dispatchEvent (queueBridge queue)
{
- CHECK_QUEUE(queue);
wombatQueueStatus status;
+ CHECK_QUEUE(queue);

status = wombatQueue_dispatch (avisQueue(queue)->mQueue,
NULL, NULL);
@@ -186,10 +188,10 @@ avisBridgeMamaQueue_enqueueEvent (queueBridge queue,
void* closure)
{
wombatQueueStatus status;
+ avisQueueClosure* cl = NULL;
CHECK_QUEUE(queue);

- avisQueueClosure* cl =
- (avisQueueClosure*)calloc(1, sizeof(avisQueueClosure));
+ cl = (avisQueueClosure*)calloc(1, sizeof(avisQueueClosure));
if (NULL == cl) return MAMA_STATUS_NOMEM;

cl->mImpl = avisQueue(queue);
@@ -208,8 +210,8 @@ avisBridgeMamaQueue_enqueueEvent (queueBridge queue,
mama_status
avisBridgeMamaQueue_stopDispatch (queueBridge queue)
{
- CHECK_QUEUE(queue);
wombatQueueStatus status;
+ CHECK_QUEUE(queue);

if (queue == NULL)
return MAMA_STATUS_NULL_ARG;
diff --git a/mama/c_cpp/src/c/bridge/avis/sub.c b/mama/c_cpp/src/c/bridge/avis/sub.c
index edc026b..08fc697 100644
--- a/mama/c_cpp/src/c/bridge/avis/sub.c
+++ b/mama/c_cpp/src/c/bridge/avis/sub.c
@@ -153,7 +153,6 @@ avis_queue_callback (void* data, void* closure)

attributes_free ((Attributes*)data);
free ((Attributes*)data);
-
}

static void
@@ -199,10 +198,11 @@ avisBridgeMamaSubscription_create (subscriptionBridge* subscriber,
mamaSubscription subscription,
void* closure)
{
+ avisSubscription* impl = NULL;
if (!subscriber || !subscription || !transport )
return MAMA_STATUS_NULL_ARG;

- avisSubscription* impl = (avisSubscription*)calloc (1, sizeof(avisSubscription));
+ impl = (avisSubscription*)calloc (1, sizeof(avisSubscription));
if (impl == NULL)
return MAMA_STATUS_NOMEM;

@@ -269,9 +269,9 @@ avisBridgeMamaSubscription_createWildCard (
mama_status
avisBridgeMamaSubscription_destroy (subscriptionBridge subscriber)
{
- CHECK_SUBSCRIBER(subscriber);
mama_status status = MAMA_STATUS_OK;
wombatQueue queue = NULL;
+ CHECK_SUBSCRIBER(subscriber);

elvin_subscription_remove_listener(avisSub(subscriber)->mAvisSubscription, avis_callback);

diff --git a/mama/c_cpp/src/c/bridge/avis/timer.c b/mama/c_cpp/src/c/bridge/avis/timer.c
index 7a69051..18aad31 100755
--- a/mama/c_cpp/src/c/bridge/avis/timer.c
+++ b/mama/c_cpp/src/c/bridge/avis/timer.c
@@ -72,7 +72,7 @@ timerCb (timerElement timer,

/* Mama timers are repeating */
timeout.tv_sec = (time_t)impl->mInterval;
- timeout.tv_usec = (suseconds_t)((impl->mInterval- timeout.tv_sec) * 1000000.0);
+ timeout.tv_usec = ((impl->mInterval- timeout.tv_sec) * 1000000.0);
if (0 != createTimer (&impl->mTimerElement,
gTimerHeap,
timerCb,
@@ -122,7 +122,7 @@ avisBridgeMamaTimer_create (timerBridge* result,
*result = (timerBridge)impl;

timeout.tv_sec = (time_t)interval;
- timeout.tv_usec = (suseconds_t)((interval-timeout.tv_sec) * 1000000.0);
+ timeout.tv_usec = ((interval-timeout.tv_sec) * 1000000.0);
if (0 != createTimer (&impl->mTimerElement,
gTimerHeap,
timerCb,
@@ -180,7 +180,7 @@ avisBridgeMamaTimer_reset (timerBridge timer)
impl = (avisTimerImpl*)timer;

timeout.tv_sec = (time_t)impl->mInterval;
- timeout.tv_usec = (suseconds_t)((impl->mInterval-timeout.tv_sec) * 1000000.0);
+ timeout.tv_usec = ((impl->mInterval-timeout.tv_sec) * 1000000.0);

if (timer == NULL)
return MAMA_STATUS_NULL_ARG;
--
1.7.7.6

Join Openmama-dev@lists.openmama.org to automatically receive all group messages.