[PATCH 1/2] C Compiler warnings


Ian Bell <IBell@...>
 

From e0560b414fba376587f5a172a8bece82b56e4508 Mon Sep 17 00:00:00 2001

Message-Id: <e0560b414fba376587f5a172a8bece82b56e4508.1348585382.git.ibell@...>

From: Ian Bell <ibell@...>

Date: Tue, 25 Sep 2012 14:48:53 +0100

Subject: [PATCH 1/2] C Compiler warnings

 

Tightened up the compiler flags and fixed some warnings.  The tighter

flags should help to prevent some common cross platform issues

 

Signed-off-by: Ian Bell <ibell@...>

---

mama/c_cpp/src/c/Makefile.am             |    5 +++--

mama/c_cpp/src/c/clientmanageresponder.c |    2 +-

mama/c_cpp/src/c/mama/transport.h        |    2 +-

mama/c_cpp/src/c/msgfield.c              |   11 ----------

mama/c_cpp/src/c/publisher.c             |    2 +-

mama/c_cpp/src/c/queue.c                 |    2 +-

mama/c_cpp/src/c/refreshtransport.c      |   33 ++----------------------------

mama/c_cpp/src/c/subscription.c          |    6 +++---

mama/c_cpp/src/c/transport.c             |   16 ++++++++-------

mama/c_cpp/src/c/transportimpl.h         |    1 +

10 files changed, 22 insertions(+), 58 deletions(-)

 

diff --git a/mama/c_cpp/src/c/Makefile.am b/mama/c_cpp/src/c/Makefile.am

index 1c7bd64..64ebac0 100644

--- a/mama/c_cpp/src/c/Makefile.am

+++ b/mama/c_cpp/src/c/Makefile.am

@@ -90,11 +90,12 @@ nobase_include_HEADERS  = \

CFLAGS   += -I${srcdir}/../../../../common/c_cpp/src/c

LDFLAGS  += -L${srcdir}/../../../../common/c_cpp/src/c

-LIBS     += -ldl -lrt -lwombatcommon

+LIBS     += -lm -lrt -lwombatcommon -ldl -lpthread

 

 if USE_GCC_FLAGS

-CPPFLAGS += -pedantic -Wall -Wno-long-long -D_GNU_SOURCE

+CFLAGS   += -std=gnu99 -pedantic-errors -Wmissing-prototypes -Wstrict-prototypes

+CPPFLAGS += -pedantic-errors -Wall -Wno-long-long -D_GNU_SOURCE

endif

 

diff --git a/mama/c_cpp/src/c/clientmanageresponder.c b/mama/c_cpp/src/c/clientmanageresponder.c

index 73f25d7..2f009f8 100644

--- a/mama/c_cpp/src/c/clientmanageresponder.c

+++ b/mama/c_cpp/src/c/clientmanageresponder.c

@@ -183,7 +183,7 @@ mama_status mamaCmResponder_destroy(mamaCmResponder responder)

  *           Returns                                :               MAMA_STATUS_NO_BRIDGE_IMPL

  *                                                                           MAMA_STATUS_OK

  */

-mama_status populateCmResponder(mamaCmResponderImpl *impl)

+static mama_status populateCmResponder(mamaCmResponderImpl *impl)

{

               /* Returns */

     mama_status ret = MAMA_STATUS_NO_BRIDGE_IMPL;

diff --git a/mama/c_cpp/src/c/mama/transport.h b/mama/c_cpp/src/c/mama/transport.h

index 6b77321..6a31570 100644

--- a/mama/c_cpp/src/c/mama/transport.h

+++ b/mama/c_cpp/src/c/mama/transport.h

@@ -91,7 +91,7 @@ typedef enum

typedef enum

{

     MAMA_TRANSPORT_TOPIC_SUBSCRIBED,

-    MAMA_TRANSPORT_TOPIC_UNSUBSRCIBED

+    MAMA_TRANSPORT_TOPIC_UNSUBSCRIBED

} mamaTransportTopicEvent;

 

diff --git a/mama/c_cpp/src/c/msgfield.c b/mama/c_cpp/src/c/msgfield.c

index eafb850..3dc7944 100644

--- a/mama/c_cpp/src/c/msgfield.c

+++ b/mama/c_cpp/src/c/msgfield.c

@@ -1194,17 +1194,6 @@ mamaMsgField_getTypeName(

}

 mama_status

-mamaMsgFieldImpl_setPayloadBridge (mamaMsgField             msgField,

-                                   mamaPayloadBridgeImpl*   payloadBridge)

-{

-    mamaMsgFieldImpl* impl = (mamaMsgFieldImpl*)msgField;

-    if (!impl) return MAMA_STATUS_NULL_ARG;

-    impl->myPayloadBridge  =   payloadBridge;

-

-    return MAMA_STATUS_OK;

-}

-

-mama_status

mamaMsgFieldImpl_setPayload (mamaMsgField           msgField,

                              msgFieldPayload        payload)

{

diff --git a/mama/c_cpp/src/c/publisher.c b/mama/c_cpp/src/c/publisher.c

index 2d2e892..222a94d 100644

--- a/mama/c_cpp/src/c/publisher.c

+++ b/mama/c_cpp/src/c/publisher.c

@@ -157,7 +157,7 @@ mamaPublisher_create (mamaPublisher*    result,

                                         root);

}

-mama_status mamaPublisherImpl_destroy(mamaPublisherImpl *impl)

+static mama_status mamaPublisherImpl_destroy(mamaPublisherImpl *impl)

{

     /* Returns. */

     mama_status        status   = MAMA_STATUS_OK;

diff --git a/mama/c_cpp/src/c/queue.c b/mama/c_cpp/src/c/queue.c

index 84ccc94..c617b3d 100644

--- a/mama/c_cpp/src/c/queue.c

+++ b/mama/c_cpp/src/c/queue.c

@@ -140,7 +140,7 @@ mamaQueue_getClosure ( mamaQueue queue, void** closure)

}

 

-mama_status

+static mama_status

mamaQueue_createReuseableMsg (mamaQueueImpl*  impl)

{

                mama_status     status      =   MAMA_STATUS_OK;

diff --git a/mama/c_cpp/src/c/refreshtransport.c b/mama/c_cpp/src/c/refreshtransport.c

index 1e44775..0bdbc81 100644

--- a/mama/c_cpp/src/c/refreshtransport.c

+++ b/mama/c_cpp/src/c/refreshtransport.c

@@ -46,8 +46,6 @@

 #define SYNC_SUBJECTS_PER_MESSAGE  100

-static time_t last = 0;

-

typedef struct refreshTransportImpl_

{

     mamaTransport      mMamaTransport;

@@ -147,7 +145,7 @@ refreshTransportImpl_staleRecapTimerCallback (mamaTimer timer, void *closure)

     mamaTimer_destroy (timer);

}

-extern void

+static void

refreshTransport_startRefreshTimer (struct refreshTransportImpl_ *impl)

{

     mama_status status = MAMA_STATUS_OK;

@@ -177,7 +175,7 @@ refreshTransport_startRefreshTimer (struct refreshTransportImpl_ *impl)

     return;

}

-extern void

+void

refreshTransport_startStaleRecapTimer (struct refreshTransportImpl_ *impl)

{

     mama_status status = MAMA_STATUS_OK;

@@ -252,33 +250,6 @@ refreshTransport_addSubscription (refreshTransport transport,

     return;

}

-extern mama_status

-refreshTransport_stopRefreshTimer (refreshTransportImpl *impl)

-{

-    if (impl->mRefreshTimer != NULL)

-    {

-        mamaTimer_destroy (impl->mRefreshTimer);

-        impl->mRefreshTimer = NULL;

-    }

-

-    return MAMA_STATUS_OK;

-}

-

-

-

-void checkOrder (wList list, void *element, void *closure)

-{

-    SubscriptionInfo *info = (SubscriptionInfo*)element;

-

-    if (info->mNextRefreshTime < last)

-    {

-        fprintf (stderr, "Bad list order!!!!\n");

-        exit (0);

-    }

-

-    last = info->mNextRefreshTime;

-}

-

static void

refreshTransportImpl_processNewSubscriptions (refreshTransportImpl *impl)

{

diff --git a/mama/c_cpp/src/c/subscription.c b/mama/c_cpp/src/c/subscription.c

index 27c5397..a13e499 100644

--- a/mama/c_cpp/src/c/subscription.c

+++ b/mama/c_cpp/src/c/subscription.c

@@ -531,7 +531,7 @@ isEntitledToSymbol (const char *source, const char*symbol, mamaSubscription subs

}

 

-char* mamaSubscriptionImpl_copyString (const char*  str)

+static char* mamaSubscriptionImpl_copyString (const char*  str)

{

     /* Windows does not like strdup */

     size_t len = strlen (str) + 1;

@@ -540,7 +540,7 @@ char* mamaSubscriptionImpl_copyString (const char*  str)

     return result;

}

-void checkFree (char**  str)

+static void checkFree (char**  str)

{

     if (*str)

     {

@@ -549,7 +549,7 @@ void checkFree (char**  str)

     }

}

-mama_status

+static mama_status

setSubscInfo (

     mamaSubscription  subscription,

     mamaTransport     transport,

diff --git a/mama/c_cpp/src/c/transport.c b/mama/c_cpp/src/c/transport.c

index 3691f35..ae1ffca 100644

--- a/mama/c_cpp/src/c/transport.c

+++ b/mama/c_cpp/src/c/transport.c

@@ -717,14 +717,16 @@ mamaTransport_create (mamaTransport transport,

                 self->mLoadBalanceHandle = openSharedLib (sharedObjectName, NULL);

                 if (self->mLoadBalanceHandle)

                 {

+                                                                             void*     vp = NULL;

                     mama_log (MAMA_LOG_LEVEL_FINER,

                               "Using Library defined load balancing");

-                    self->mLoadBalanceCb =  (mamaTransportLbCB)

-                        loadLibFunc ((LIB_HANDLE)self->mLoadBalanceHandle,

+                    vp = loadLibFunc ((LIB_HANDLE)self->mLoadBalanceHandle,

                                 "loadBalance");

-                    self->mLoadBalanceInitialCb = (mamaTransportLbInitialCB)

-                        loadLibFunc ((LIB_HANDLE)self->mLoadBalanceHandle,

+                    self->mLoadBalanceCb = *(mamaTransportLbCB*)&vp;

+

+                    vp = loadLibFunc ((LIB_HANDLE)self->mLoadBalanceHandle,

                                 "loadBalanceInitial");

+                    self->mLoadBalanceInitialCb = *(mamaTransportLbInitialCB*)&vp;

                 }

                 else

                 {

@@ -840,8 +842,8 @@ mamaTransport_create (mamaTransport transport,

 

     setPreInitialStrategy ((mamaTransport)self);

-    setDQStrategy (self);

-    setFtStrategy (self);

+    setDQStrategy ((mamaTransport)self);

+    setFtStrategy ((mamaTransport)self);

     if (mamaTransportImpl_disableDisconnectCb (name))

     {

@@ -2144,7 +2146,7 @@ void mamaTransportImpl_setAdvisoryCauseAndPlatformInfo (mamaTransport transport,

     {

         /* Set the cause. */

         impl->mCause        = cause;

-        impl->mPlatformInfo = platformInfo;

+        impl->mPlatformInfo = (void*) platformInfo;

     }

     /* Otherwise write an error log. */

diff --git a/mama/c_cpp/src/c/transportimpl.h b/mama/c_cpp/src/c/transportimpl.h

index 6b2c56e..a3115b1 100644

--- a/mama/c_cpp/src/c/transportimpl.h

+++ b/mama/c_cpp/src/c/transportimpl.h

@@ -264,6 +264,7 @@ preInitialScheme mamaTransportImpl_getPreInitialScheme (mamaTransport transport)

  *              MAMA_STATUS_NULL_ARG

  *              MAMA_STATUS_OK

  */

+MAMAExpDLL

mama_status mamaTransportImpl_allocateInternalTransport(mamaTransport *transport);

 /**

--

1.7.9.5

 




Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error, please advise the sender immediately by reply e-mail and delete this message and any attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.