qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cliffjan...@apache.org
Subject svn commit: r1441855 - in /qpid/proton/trunk/proton-c: CMakeLists.txt src/buffer.c src/dispatcher/dispatcher.c src/engine/engine.c src/messenger.c src/platform.c src/proton.c src/sasl/sasl.c src/ssl/openssl.c src/util.h
Date Sun, 03 Feb 2013 04:14:58 GMT
Author: cliffjansen
Date: Sun Feb  3 04:14:58 2013
New Revision: 1441855

URL: http://svn.apache.org/viewvc?rev=1441855&view=rev
Log:
PROTON-159: C++ support part 1.  See https://reviews.apache.org/r/8223/

Modified:
    qpid/proton/trunk/proton-c/CMakeLists.txt
    qpid/proton/trunk/proton-c/src/buffer.c
    qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c
    qpid/proton/trunk/proton-c/src/engine/engine.c
    qpid/proton/trunk/proton-c/src/messenger.c
    qpid/proton/trunk/proton-c/src/platform.c
    qpid/proton/trunk/proton-c/src/proton.c
    qpid/proton/trunk/proton-c/src/sasl/sasl.c
    qpid/proton/trunk/proton-c/src/ssl/openssl.c
    qpid/proton/trunk/proton-c/src/util.h

Modified: qpid/proton/trunk/proton-c/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/CMakeLists.txt?rev=1441855&r1=1441854&r2=1441855&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/CMakeLists.txt (original)
+++ qpid/proton/trunk/proton-c/CMakeLists.txt Sun Feb  3 04:14:58 2013
@@ -187,7 +187,7 @@ if (CMAKE_COMPILER_IS_GNUCC)
   if (ENABLE_WARNING_ERROR)
     set (WERROR "-Werror")
   endif (ENABLE_WARNING_ERROR)
-  set (COMPILE_WARNING_FLAGS "${WERROR} -Wall -pedantic-errors")
+  set (COMPILE_WARNING_FLAGS "${WERROR} -Wall -pedantic-errors -Wc++-compat")
   set (COMPILE_LANGUAGE_FLAGS "-std=c99")
   set (COMPILE_PLATFORM_FLAGS "-std=gnu99")
   if (ENABLE_UNDEFINED_ERROR)

Modified: qpid/proton/trunk/proton-c/src/buffer.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/buffer.c?rev=1441855&r1=1441854&r2=1441855&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/buffer.c (original)
+++ qpid/proton/trunk/proton-c/src/buffer.c Sun Feb  3 04:14:58 2013
@@ -132,7 +132,7 @@ int pn_buffer_ensure(pn_buffer_t *buf, s
   }
 
   if (buf->capacity != old_capacity) {
-    buf->bytes = realloc(buf->bytes, buf->capacity);
+    buf->bytes = (char *) realloc(buf->bytes, buf->capacity);
 
     if (wrapped) {
       size_t n = old_capacity - old_head;

Modified: qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c?rev=1441855&r1=1441854&r2=1441855&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c (original)
+++ qpid/proton/trunk/proton-c/src/dispatcher/dispatcher.c Sun Feb  3 04:14:58 2013
@@ -380,7 +380,7 @@ int pn_post_transfer_frame(pn_dispatcher
     while (!(n = pn_write_frame(disp->output + disp->available,
                                 disp->capacity - disp->available, frame))) {
       disp->capacity *= 2;
-      disp->output = realloc(disp->output, disp->capacity);
+      disp->output = (char *) realloc(disp->output, disp->capacity);
     }
     disp->output_frames_ct += 1;
     if (disp->trace & PN_TRACE_RAW) {

Modified: qpid/proton/trunk/proton-c/src/engine/engine.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1441855&r1=1441854&r2=1441855&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/engine/engine.c (original)
+++ qpid/proton/trunk/proton-c/src/engine/engine.c Sun Feb  3 04:14:58 2013
@@ -38,7 +38,7 @@
 void pn_delivery_buffer_init(pn_delivery_buffer_t *db, pn_sequence_t next, size_t capacity)
 {
   // XXX: error handling
-  db->deliveries = malloc(sizeof(pn_delivery_state_t) * capacity);
+  db->deliveries = (pn_delivery_state_t *) malloc(sizeof(pn_delivery_state_t) * capacity);
   db->next = next;
   db->capacity = capacity;
   db->head = 0;
@@ -250,7 +250,7 @@ void pn_transport_free(pn_transport_t *t
 
 void pn_add_session(pn_connection_t *conn, pn_session_t *ssn)
 {
-  PN_ENSURE(conn->sessions, conn->session_capacity, conn->session_count + 1);
+    PN_ENSURE(conn->sessions, conn->session_capacity, conn->session_count + 1, pn_session_t*);
   conn->sessions[conn->session_count++] = ssn;
   ssn->connection = conn;
   ssn->id = conn->session_count;
@@ -312,7 +312,7 @@ void pn_session_set_context(pn_session_t
 
 void pn_add_link(pn_session_t *ssn, pn_link_t *link)
 {
-  PN_ENSURE(ssn->links, ssn->link_capacity, ssn->link_count + 1);
+  PN_ENSURE(ssn->links, ssn->link_capacity, ssn->link_count + 1, pn_link_t*);
   ssn->links[ssn->link_count++] = link;
   link->session = ssn;
   link->id = ssn->link_count;
@@ -800,7 +800,7 @@ void pn_transport_init(pn_transport_t *t
 pn_session_state_t *pn_session_get_state(pn_transport_t *transport, pn_session_t *ssn)
 {
   int old_capacity = transport->session_capacity;
-  PN_ENSURE(transport->sessions, transport->session_capacity, ssn->id + 1);
+  PN_ENSURE(transport->sessions, transport->session_capacity, ssn->id + 1, pn_session_state_t);
   for (int i = old_capacity; i < transport->session_capacity; i++)
   {
     transport->sessions[i] = (pn_session_state_t) {.session=NULL,
@@ -816,13 +816,13 @@ pn_session_state_t *pn_session_get_state
 
 pn_session_state_t *pn_channel_state(pn_transport_t *transport, uint16_t channel)
 {
-  PN_ENSUREZ(transport->channels, transport->channel_capacity, channel + 1);
+  PN_ENSUREZ(transport->channels, transport->channel_capacity, channel + 1, pn_session_state_t
*);
   return transport->channels[channel];
 }
 
 void pn_map_channel(pn_transport_t *transport, uint16_t channel, pn_session_state_t *state)
 {
-  PN_ENSUREZ(transport->channels, transport->channel_capacity, channel + 1);
+  PN_ENSUREZ(transport->channels, transport->channel_capacity, channel + 1, pn_session_state_t
*);
   state->remote_channel = channel;
   transport->channels[channel] = state;
 }
@@ -1081,7 +1081,7 @@ int pn_terminus_copy(pn_terminus_t *term
 pn_link_state_t *pn_link_get_state(pn_session_state_t *ssn_state, pn_link_t *link)
 {
   int old_capacity = ssn_state->link_capacity;
-  PN_ENSURE(ssn_state->links, ssn_state->link_capacity, link->id + 1);
+  PN_ENSURE(ssn_state->links, ssn_state->link_capacity, link->id + 1, pn_link_state_t);
   for (int i = old_capacity; i < ssn_state->link_capacity; i++)
   {
     ssn_state->links[i] = (pn_link_state_t) {.link=NULL, .local_handle = -1,
@@ -1094,14 +1094,14 @@ pn_link_state_t *pn_link_get_state(pn_se
 
 void pn_map_handle(pn_session_state_t *ssn_state, uint32_t handle, pn_link_state_t *state)
 {
-  PN_ENSUREZ(ssn_state->handles, ssn_state->handle_capacity, handle + 1);
+  PN_ENSUREZ(ssn_state->handles, ssn_state->handle_capacity, handle + 1, pn_link_state_t*);
   state->remote_handle = handle;
   ssn_state->handles[handle] = state;
 }
 
 pn_link_state_t *pn_handle_state(pn_session_state_t *ssn_state, uint32_t handle)
 {
-  PN_ENSUREZ(ssn_state->handles, ssn_state->handle_capacity, handle + 1);
+  PN_ENSUREZ(ssn_state->handles, ssn_state->handle_capacity, handle + 1, pn_link_state_t*);
   return ssn_state->handles[handle];
 }
 
@@ -1693,7 +1693,7 @@ int pn_do_flow(pn_dispatcher_t *disp)
 
 int pn_do_disposition(pn_dispatcher_t *disp)
 {
-  pn_transport_t *transport = disp->context;
+  pn_transport_t *transport = (pn_transport_t *) disp->context;
   bool role;
   pn_sequence_t first, last;
   uint64_t code;

Modified: qpid/proton/trunk/proton-c/src/messenger.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/messenger.c?rev=1441855&r1=1441854&r2=1441855&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/messenger.c (original)
+++ qpid/proton/trunk/proton-c/src/messenger.c Sun Feb  3 04:14:58 2013
@@ -83,7 +83,7 @@ void pn_queue_init(pn_queue_t *queue)
   queue->window = 0;
   queue->lwm = 0;
   queue->hwm = 0;
-  queue->deliveries = calloc(queue->capacity, sizeof(pn_delivery_t *));
+  queue->deliveries = (pn_delivery_t **) calloc(queue->capacity, sizeof(pn_delivery_t
*));
 }
 
 void pn_queue_tini(pn_queue_t *queue)
@@ -122,13 +122,13 @@ void pn_queue_gc(pn_queue_t *queue)
 
 static void pn_incref(pn_connection_t *conn)
 {
-  pn_connection_ctx_t *ctx = pn_connection_get_context(conn);
+  pn_connection_ctx_t *ctx = (pn_connection_ctx_t *) pn_connection_get_context(conn);
   ctx->refcount++;
 }
 
 static void pn_decref(pn_connection_t *conn)
 {
-  pn_connection_ctx_t *ctx = pn_connection_get_context(conn);
+  pn_connection_ctx_t *ctx = (pn_connection_ctx_t *) pn_connection_get_context(conn);
   ctx->refcount--;
   if (ctx->refcount == 0) {
     pn_connection_free(conn);
@@ -178,7 +178,7 @@ pn_sequence_t pn_queue_add(pn_queue_t *q
 {
   pn_sequence_t id = queue->hwm++;
   size_t offset = id - queue->lwm;
-  PN_ENSUREZ(queue->deliveries, queue->capacity, offset + 1);
+  PN_ENSUREZ(queue->deliveries, queue->capacity, offset + 1, pn_delivery_t *);
   assert(offset >= 0 && offset < queue->capacity);
   queue->deliveries[offset] = delivery;
   pn_delivery_set_context(delivery, (void *) (intptr_t) id);
@@ -411,7 +411,7 @@ static void pn_transport_config(pn_messe
                                 pn_connector_t *connector,
                                 pn_connection_t *connection)
 {
-  pn_connection_ctx_t *ctx = pn_connection_get_context(connection);
+  pn_connection_ctx_t *ctx = (pn_connection_ctx_t *) pn_connection_get_context(connection);
   pn_transport_t *transport = pn_connector_transport(connector);
   if (ctx->scheme && !strcmp(ctx->scheme, "amqps")) {
     pn_ssl_domain_t *d = pn_ssl_domain( PN_SSL_MODE_CLIENT );
@@ -562,7 +562,7 @@ pn_connection_t *pn_messenger_connection
 {
   pn_connection_t *connection = pn_connection();
   if (!connection) return NULL;
-  pn_connection_ctx_t *ctx = malloc(sizeof(pn_connection_ctx_t));
+  pn_connection_ctx_t *ctx = (pn_connection_ctx_t *) malloc(sizeof(pn_connection_ctx_t));
   ctx->refcount = 0;
   ctx->scheme = pn_strdup(scheme);
   ctx->user = pn_strdup(user);
@@ -733,7 +733,7 @@ pn_connection_t *pn_messenger_resolve(pn
   pn_connector_t *ctor = pn_connector_head(messenger->driver);
   while (ctor) {
     pn_connection_t *connection = pn_connector_connection(ctor);
-    pn_connection_ctx_t *ctx = pn_connection_get_context(connection);
+    pn_connection_ctx_t *ctx = (pn_connection_ctx_t *) pn_connection_get_context(connection);
     if (pn_streq(scheme, ctx->scheme) && pn_streq(user, ctx->user) &&
         pn_streq(pass, ctx->pass) && pn_streq(host, ctx->host) &&
         pn_streq(port, ctx->port)) {
@@ -761,7 +761,7 @@ pn_connection_t *pn_messenger_resolve(pn
 
 pn_subscription_t *pn_subscription(pn_messenger_t *messenger, const char *scheme)
 {
-  PN_ENSURE(messenger->subscriptions, messenger->sub_capacity, messenger->sub_count
+ 1);
+  PN_ENSURE(messenger->subscriptions, messenger->sub_capacity, messenger->sub_count
+ 1, pn_subscription_t);
   pn_subscription_t *sub = messenger->subscriptions + messenger->sub_count++;
   sub->scheme = pn_strdup(scheme);
   sub->context = NULL;
@@ -858,7 +858,7 @@ pn_subscription_t *pn_messenger_subscrib
   } else {
     pn_link_t *src = pn_messenger_source(messenger, source);
     if (src) {
-      pn_subscription_t *sub = pn_link_get_context(src);
+      pn_subscription_t *sub = (pn_subscription_t *) pn_link_get_context(src);
       return sub;
     } else {
       pn_error_format(messenger->error, PN_ERR,
@@ -1109,7 +1109,7 @@ int pn_messenger_get(pn_messenger_t *mes
     while (d) {
       if (pn_delivery_readable(d) && !pn_delivery_partial(d)) {
         pn_link_t *l = pn_delivery_link(d);
-        pn_subscription_t *sub = pn_link_get_context(l);
+        pn_subscription_t *sub = (pn_subscription_t *) pn_link_get_context(l);
         size_t pending = pn_delivery_pending(d);
         pn_buffer_t *buf = messenger->buffer;
         int err = pn_buffer_ensure(buf, pending + 1);

Modified: qpid/proton/trunk/proton-c/src/platform.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/platform.c?rev=1441855&r1=1441854&r2=1441855&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/platform.c (original)
+++ qpid/proton/trunk/proton-c/src/platform.c Sun Feb  3 04:14:58 2013
@@ -46,7 +46,7 @@ pn_timestamp_t pn_i_now(void)
 #include <uuid/uuid.h>
 #include <stdlib.h>
 char* pn_i_genuuid(void) {
-    char *generated = malloc(37*sizeof(char));
+    char *generated = (char *) malloc(37*sizeof(char));
     uuid_t uuid;
     uuid_generate(uuid);
     uuid_unparse(uuid, generated);

Modified: qpid/proton/trunk/proton-c/src/proton.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/proton.c?rev=1441855&r1=1441854&r2=1441855&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/proton.c (original)
+++ qpid/proton/trunk/proton-c/src/proton.c Sun Feb  3 04:14:58 2013
@@ -130,7 +130,7 @@ void server_callback(pn_connector_t *cto
   }
 
   pn_connection_t *conn = pn_connector_connection(ctor);
-  struct server_context *ctx = pn_connector_context(ctor);
+  struct server_context *ctx = (struct server_context *) pn_connector_context(ctor);
   char tagstr[1024];
   char msg[10*1024];
   char data[ctx->size + 16];

Modified: qpid/proton/trunk/proton-c/src/sasl/sasl.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/sasl/sasl.c?rev=1441855&r1=1441854&r2=1441855&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/sasl/sasl.c (original)
+++ qpid/proton/trunk/proton-c/src/sasl/sasl.c Sun Feb  3 04:14:58 2013
@@ -66,7 +66,7 @@ int pn_do_outcome(pn_dispatcher_t *disp)
 pn_sasl_t *pn_sasl(pn_transport_t *transport)
 {
   if (!transport->sasl) {
-    pn_sasl_t *sasl = malloc(sizeof(pn_sasl_t));
+    pn_sasl_t *sasl = (pn_sasl_t *) malloc(sizeof(pn_sasl_t));
     sasl->disp = pn_dispatcher(1, sasl);
     sasl->disp->batch = false;
 
@@ -375,7 +375,7 @@ int pn_do_mechanisms(pn_dispatcher_t *di
 
 int pn_do_recv(pn_dispatcher_t *disp)
 {
-  pn_sasl_t *sasl = disp->context;
+  pn_sasl_t *sasl = (pn_sasl_t *) disp->context;
   pn_bytes_t recv;
   int err = pn_scan_args(disp, "D.[z]", &recv);
   if (err) return err;
@@ -395,7 +395,7 @@ int pn_do_response(pn_dispatcher_t *disp
 
 int pn_do_outcome(pn_dispatcher_t *disp)
 {
-  pn_sasl_t *sasl = disp->context;
+  pn_sasl_t *sasl = (pn_sasl_t *) disp->context;
   uint8_t outcome;
   int err = pn_scan_args(disp, "D.[B]", &outcome);
   if (err) return err;

Modified: qpid/proton/trunk/proton-c/src/ssl/openssl.c
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/ssl/openssl.c?rev=1441855&r1=1441854&r2=1441855&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/ssl/openssl.c (original)
+++ qpid/proton/trunk/proton-c/src/ssl/openssl.c Sun Feb  3 04:14:58 2013
@@ -210,7 +210,7 @@ static bool match_dns_pattern( const cha
     const char *cptr;
     int len;
 
-    cptr = memchr( pattern, '.', plen );
+    cptr = (const char *) memchr( pattern, '.', plen );
     len = (cptr) ? cptr - pattern : plen;
     if (len > sizeof(plabel) - 1) return false;
     memcpy( plabel, pattern, len );
@@ -218,7 +218,7 @@ static bool match_dns_pattern( const cha
     pattern = cptr + 1;
     plen -= len;
 
-    cptr = memchr( hostname, '.', slen );
+    cptr = (const char *) memchr( hostname, '.', slen );
     len = (cptr) ? cptr - hostname : slen;
     if (len > sizeof(slabel) - 1) return false;
     memcpy( slabel, hostname, len );
@@ -255,7 +255,7 @@ static int verify_callback(int preverify
     return preverify_ok;
 
   X509 *cert = X509_STORE_CTX_get_current_cert(ctx);
-  SSL *ssn = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
+  SSL *ssn = (SSL *) X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
   if (!ssn) {
     _log_error("Error: unexpected error - SSL session info not available for peer verify!\n");
     return 0;  // fail connection
@@ -419,7 +419,7 @@ pn_ssl_domain_t *pn_ssl_domain( pn_ssl_m
                                               NULL, NULL, NULL);
   }
 
-  pn_ssl_domain_t *domain = calloc(1, sizeof(pn_ssl_domain_t));
+  pn_ssl_domain_t *domain = (pn_ssl_domain_t *) calloc(1, sizeof(pn_ssl_domain_t));
   if (!domain) return NULL;
 
   domain->ref_count = 1;
@@ -712,7 +712,7 @@ pn_ssl_t *pn_ssl(pn_transport_t *transpo
   if (!transport) return NULL;
   if (transport->ssl) return transport->ssl;
 
-  pn_ssl_t *ssl = calloc(1, sizeof(pn_ssl_t));
+  pn_ssl_t *ssl = (pn_ssl_t *) calloc(1, sizeof(pn_ssl_t));
   if (!ssl) return NULL;
   ssl->transport = transport;
   transport->ssl = ssl;

Modified: qpid/proton/trunk/proton-c/src/util.h
URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/util.h?rev=1441855&r1=1441854&r2=1441855&view=diff
==============================================================================
--- qpid/proton/trunk/proton-c/src/util.h (original)
+++ qpid/proton/trunk/proton-c/src/util.h Sun Feb  3 04:14:58 2013
@@ -97,18 +97,18 @@ char *pn_strndup(const char *src, size_t
 #define pn_min(X,Y) ((X) > (Y) ? (Y) : (X))
 #define pn_max(X,Y) ((X) < (Y) ? (Y) : (X))
 
-#define PN_ENSURE(ARRAY, CAPACITY, COUNT)                      \
+#define PN_ENSURE(ARRAY, CAPACITY, COUNT, TYPE)                 \
   while ((CAPACITY) < (COUNT)) {                                \
     (CAPACITY) = (CAPACITY) ? 2 * (CAPACITY) : 16;              \
-    (ARRAY) = realloc((ARRAY), (CAPACITY) * sizeof (*(ARRAY))); \
+    (ARRAY) = (TYPE *) realloc((ARRAY), (CAPACITY) * sizeof (TYPE));    \
   }                                                             \
 
-#define PN_ENSUREZ(ARRAY, CAPACITY, COUNT)                \
+#define PN_ENSUREZ(ARRAY, CAPACITY, COUNT, TYPE)           \
   {                                                        \
     size_t _old_capacity = (CAPACITY);                     \
-    PN_ENSURE((ARRAY), (CAPACITY), (COUNT));               \
+    PN_ENSURE(ARRAY, CAPACITY, COUNT, TYPE);               \
     memset((ARRAY) + _old_capacity, 0,                     \
-           sizeof(*(ARRAY))*((CAPACITY) - _old_capacity)); \
+           sizeof(TYPE)*((CAPACITY) - _old_capacity));     \
   }
 
 #endif /* util.h */



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message