THRIFT-3285 c_glib: Library: Build without compiler warnings

These changes allow the C (GLib) library to be built without
warnings from the compiler, even with extra compiler warnings
enabled. The changes involve

- Moving variable declarations to the top of every code block,

- Using unions instead of type-punning to follow strict-aliasing
  rules,

- Replacing variable-length array declarations with arrays
  allocated on the stack (using g_newa and g_alloca),

- Casting void pointers to a suitably sized data type before
  performing arithmetic on them,

- Replacing C++-style ("//") comments with C-style equivalents,
  and

- Removing an errant semicolon and comma.

This closes #576
diff --git a/lib/c_glib/src/thrift/c_glib/processor/thrift_dispatch_processor.c b/lib/c_glib/src/thrift/c_glib/processor/thrift_dispatch_processor.c
index 7d223bf..57f0bed 100644
--- a/lib/c_glib/src/thrift/c_glib/processor/thrift_dispatch_processor.c
+++ b/lib/c_glib/src/thrift/c_glib/processor/thrift_dispatch_processor.c
@@ -23,7 +23,7 @@
 
 G_DEFINE_ABSTRACT_TYPE (ThriftDispatchProcessor,
                         thrift_dispatch_processor,
-                        THRIFT_TYPE_PROCESSOR);
+                        THRIFT_TYPE_PROCESSOR)
 
 gboolean
 thrift_dispatch_processor_process (ThriftProcessor *processor,
diff --git a/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.c b/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.c
index 32a8000..358396c 100644
--- a/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.c
+++ b/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol.c
@@ -53,13 +53,13 @@
     const gchar *name, const ThriftMessageType message_type,
     const gint32 seqid, GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
-
   gint32 version = (THRIFT_BINARY_PROTOCOL_VERSION_1)
                    | ((gint32) message_type);
   gint32 ret;
   gint32 xfer = 0;
 
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
   if ((ret = thrift_protocol_write_i32 (protocol, version, error)) < 0)
   {
     return -1;
@@ -117,12 +117,13 @@
                                           const gint16 field_id,
                                           GError **error)
 {
-  THRIFT_UNUSED_VAR (name);
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
-
   gint32 ret;
   gint32 xfer = 0;
 
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  THRIFT_UNUSED_VAR (name);
+
   if ((ret = thrift_protocol_write_byte (protocol, (gint8) field_type,
                                          error)) < 0)
   {
@@ -162,11 +163,11 @@
                                         const guint32 size,
                                         GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
-
   gint32 ret;
   gint32 xfer = 0;
 
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
   if ((ret = thrift_protocol_write_byte (protocol, (gint8) key_type,
                                          error)) < 0)
   {
@@ -202,11 +203,11 @@
                                          const guint32 size, 
                                          GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1); 
-
   gint32 ret;
   gint32 xfer = 0;
 
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
   if ((ret = thrift_protocol_write_byte (protocol, (gint8) element_type,
                                          error)) < 0)
   {
@@ -256,8 +257,11 @@
 thrift_binary_protocol_write_bool (ThriftProtocol *protocol,
                                    const gboolean value, GError **error)
 {
+  guint8 tmp;
+
   g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
-  guint8 tmp = value ? 1 : 0;
+
+  tmp = value ? 1 : 0;
   return thrift_protocol_write_byte (protocol, tmp, error);
 }
 
@@ -280,9 +284,11 @@
 thrift_binary_protocol_write_i16 (ThriftProtocol *protocol, const gint16 value,
                                   GError **error)
 {
+  gint16 net;
+
   g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
 
-  gint16 net = g_htons (value);
+  net = g_htons (value);
   if (thrift_transport_write (protocol->transport,
                               (const gpointer) &net, 2, error))
   {
@@ -296,9 +302,11 @@
 thrift_binary_protocol_write_i32 (ThriftProtocol *protocol, const gint32 value,
                                   GError **error)
 {
+  gint32 net;
+
   g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
 
-  gint32 net = g_htonl (value);
+  net = g_htonl (value);
   if (thrift_transport_write (protocol->transport,
                               (const gpointer) &net, 4, error))
   {
@@ -312,9 +320,11 @@
 thrift_binary_protocol_write_i64 (ThriftProtocol *protocol, const gint64 value,
                                   GError **error)
 {
+  gint64 net;
+
   g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
 
-  gint64 net = GUINT64_TO_BE (value);
+  net = GUINT64_TO_BE (value);
   if (thrift_transport_write (protocol->transport,
                               (const gpointer) &net, 8, error))
   {
@@ -328,9 +338,11 @@
 thrift_binary_protocol_write_double (ThriftProtocol *protocol,
                                      const gdouble value, GError **error)
 {
+  guint64 bits;
+
   g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
 
-  guint64 bits = GUINT64_FROM_BE (thrift_bitwise_cast_guint64 (value));
+  bits = GUINT64_FROM_BE (thrift_bitwise_cast_guint64 (value));
   if (thrift_transport_write (protocol->transport,
                               (const gpointer) &bits, 8, error))
   {
@@ -344,9 +356,11 @@
 thrift_binary_protocol_write_string (ThriftProtocol *protocol,
                                      const gchar *str, GError **error)
 {
+  guint32 len;
+
   g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
 
-  guint32 len = str != NULL ? strlen (str) : 0;
+  len = str != NULL ? strlen (str) : 0;
   /* write the string length + 1 which includes the null terminator */
   return thrift_protocol_write_binary (protocol, (const gpointer) str, 
                                        len, error);
@@ -357,10 +371,11 @@
                                      const gpointer buf,
                                      const guint32 len, GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
   gint32 ret;
   gint32 xfer = 0;
 
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
   if ((ret = thrift_protocol_write_i32 (protocol, len, error)) < 0)
   {
     return -1;
@@ -386,12 +401,12 @@
                                            ThriftMessageType *message_type,
                                            gint32 *seqid, GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
-
   gint32 ret;
   gint32 xfer = 0;
   gint32 sz;
 
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
   if ((ret = thrift_protocol_read_i32 (protocol, &sz, error)) < 0)
   {
     return -1;
@@ -464,13 +479,14 @@
                                          gint16 *field_id,
                                          GError **error)
 {
-  THRIFT_UNUSED_VAR (name);
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
-
   gint32 ret;
   gint32 xfer = 0;
   gint8 type;
 
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
+  THRIFT_UNUSED_VAR (name);
+
   if ((ret = thrift_protocol_read_byte (protocol, &type, error)) < 0)
   {
     return -1;
@@ -506,13 +522,13 @@
                                        guint32 *size,
                                        GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
-
   gint32 ret;
   gint32 xfer = 0;
   gint8 k, v;
   gint32 sizei;
 
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
   if ((ret = thrift_protocol_read_byte (protocol, &k, error)) < 0)
   {
     return -1;
@@ -559,13 +575,13 @@
                                         ThriftType *element_type,
                                         guint32 *size, GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
-
   gint32 ret;
   gint32 xfer = 0;
   gint8 e;
   gint32 sizei;
 
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
   if ((ret = thrift_protocol_read_byte (protocol, &e, error)) < 0)
   {
     return -1;
@@ -623,10 +639,11 @@
 thrift_binary_protocol_read_bool (ThriftProtocol *protocol, gboolean *value,
                                   GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
   gint32 ret;
   gpointer b[1];
 
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
   if ((ret = 
        thrift_transport_read (protocol->transport,
                               b, 1, error)) < 0)
@@ -641,10 +658,11 @@
 thrift_binary_protocol_read_byte (ThriftProtocol *protocol, gint8 *value,
                                   GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
   gint32 ret;
   gpointer b[1];
 
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
   if ((ret =
        thrift_transport_read (protocol->transport,
                               b, 1, error)) < 0)
@@ -659,18 +677,22 @@
 thrift_binary_protocol_read_i16 (ThriftProtocol *protocol, gint16 *value,
                                  GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
   gint32 ret;
-  gpointer b[2];
+  union
+  {
+    gint8 byte_array[2];
+    gint16 int16;
+  } b;
+
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
 
   if ((ret =
        thrift_transport_read (protocol->transport,
-                              b, 2, error)) < 0)
+                              b.byte_array, 2, error)) < 0)
   {
     return -1;
   }
-  *value = *(gint16 *) b;
-  *value = g_ntohs (*value);
+  *value = g_ntohs (b.int16);
   return ret;
 }
 
@@ -678,18 +700,22 @@
 thrift_binary_protocol_read_i32 (ThriftProtocol *protocol, gint32 *value,
                                  GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
   gint32 ret;
-  gpointer b[4];
+  union
+  {
+    gint8 byte_array[4];
+    gint32 int32;
+  } b;
+
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
 
   if ((ret =
        thrift_transport_read (protocol->transport,
-                              b, 4, error)) < 0)
+                              b.byte_array, 4, error)) < 0)
   {
     return -1;
   }
-  *value = *(gint32 *) b;
-  *value = g_ntohl (*value);
+  *value = g_ntohl (b.int32);
   return ret;
 }
 
@@ -697,18 +723,22 @@
 thrift_binary_protocol_read_i64 (ThriftProtocol *protocol, gint64 *value,
                                  GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
   gint32 ret;
-  gpointer b[8];
+  union
+  {
+    gint8 byte_array[8];
+    gint64 int64;
+  } b;
+
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
 
   if ((ret =
        thrift_transport_read (protocol->transport,
-                              b, 8, error)) < 0)
+                              b.byte_array, 8, error)) < 0)
   {
     return -1;
   }
-  *value = *(gint64 *) b;
-  *value = GUINT64_FROM_BE (*value);
+  *value = GUINT64_FROM_BE (b.int64);
   return ret;
 }
 
@@ -716,19 +746,22 @@
 thrift_binary_protocol_read_double (ThriftProtocol *protocol,
                                     gdouble *value, GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
   gint32 ret;
-  gpointer b[8];
+  union
+  {
+    gint8 byte_array[8];
+    guint64 uint64;
+  } b;
+
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
 
   if ((ret =
        thrift_transport_read (protocol->transport,
-                              b, 8, error)) < 0)
+                              b.byte_array, 8, error)) < 0)
   {
     return -1;
   }
-  guint64 bits = *(guint64 *) b;
-  bits = GUINT64_FROM_BE (bits);
-  *value = thrift_bitwise_cast_gdouble (bits);
+  *value = thrift_bitwise_cast_gdouble (GUINT64_FROM_BE (b.uint64));
   return ret;
 }
 
@@ -736,12 +769,13 @@
 thrift_binary_protocol_read_string (ThriftProtocol *protocol,
                                     gchar **str, GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
   guint32 len;
   gint32 ret;
   gint32 xfer = 0;
   gint32 read_len = 0;
 
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
   /* read the length into read_len */
   if ((ret =
        thrift_protocol_read_i32 (protocol, &read_len, error)) < 0)
@@ -753,7 +787,7 @@
   if (read_len > 0)
   {
     /* allocate the memory for the string */
-    len = (guint32) read_len + 1; // space for null terminator
+    len = (guint32) read_len + 1; /* space for null terminator */
     *str = g_new0 (gchar, len);
     if ((ret =
          thrift_transport_read (protocol->transport,
@@ -777,11 +811,12 @@
                                     gpointer *buf, guint32 *len,
                                     GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
   gint32 ret;
   gint32 xfer = 0;
   gint32 read_len = 0;
  
+  g_return_val_if_fail (THRIFT_IS_BINARY_PROTOCOL (protocol), -1);
+
   /* read the length into read_len */
   if ((ret =
        thrift_protocol_read_i32 (protocol, &read_len, error)) < 0)
diff --git a/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol_factory.c b/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol_factory.c
index 390c809..774e9ad 100644
--- a/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol_factory.c
+++ b/lib/c_glib/src/thrift/c_glib/protocol/thrift_binary_protocol_factory.c
@@ -27,11 +27,11 @@
 thrift_binary_protocol_factory_get_protocol (ThriftProtocolFactory *factory,
                                              ThriftTransport *transport)
 {
-  THRIFT_UNUSED_VAR (factory);
-
   ThriftBinaryProtocol *tb = g_object_new (THRIFT_TYPE_BINARY_PROTOCOL,
                                            "transport", transport, NULL);
 
+  THRIFT_UNUSED_VAR (factory);
+
   return THRIFT_PROTOCOL (tb);
 }
 
diff --git a/lib/c_glib/src/thrift/c_glib/server/thrift_simple_server.c b/lib/c_glib/src/thrift/c_glib/server/thrift_simple_server.c
index cb20ab6..22a96c7 100644
--- a/lib/c_glib/src/thrift/c_glib/server/thrift_simple_server.c
+++ b/lib/c_glib/src/thrift/c_glib/server/thrift_simple_server.c
@@ -27,14 +27,14 @@
 gboolean
 thrift_simple_server_serve (ThriftServer *server, GError **error)
 {
-  g_return_val_if_fail (THRIFT_IS_SIMPLE_SERVER (server), FALSE);
-
   ThriftTransport *t = NULL;
   ThriftTransport *input_transport = NULL, *output_transport = NULL;
   ThriftProtocol *input_protocol = NULL, *output_protocol = NULL;
   ThriftSimpleServer *tss = THRIFT_SIMPLE_SERVER(server);
   GError *process_error = NULL;
 
+  g_return_val_if_fail (THRIFT_IS_SIMPLE_SERVER (server), FALSE);
+
   if (thrift_server_transport_listen (server->server_transport, error)) {
     tss->running = TRUE;
     while (tss->running == TRUE)
@@ -69,11 +69,11 @@
           g_message ("thrift_simple_server_serve: %s", process_error->message);
           g_clear_error (&process_error);
 
-          // Note we do not propagate processing errors to the caller as they
-          // normally are transient and not fatal to the server
+          /* Note we do not propagate processing errors to the caller as they
+           * normally are transient and not fatal to the server */
         }
 
-        // TODO: handle exceptions
+        /* TODO: handle exceptions */
         THRIFT_TRANSPORT_GET_CLASS (input_transport)->close (input_transport,
                                                              NULL);
         THRIFT_TRANSPORT_GET_CLASS (output_transport)->close (output_transport,
@@ -81,13 +81,13 @@
       }
     }
 
-    // attempt to shutdown
+    /* attempt to shutdown */
     THRIFT_SERVER_TRANSPORT_GET_CLASS (server->server_transport)
       ->close (server->server_transport, NULL);
   }
 
-  // Since this method is designed to run forever, it can only ever return on
-  // error
+  /* Since this method is designed to run forever, it can only ever return on
+   * error */
   return FALSE;
 }
 
@@ -101,10 +101,10 @@
 static void
 thrift_simple_server_init (ThriftSimpleServer *tss)
 {
-  tss->running = FALSE;
-
   ThriftServer *server = THRIFT_SERVER(tss);
 
+  tss->running = FALSE;
+
   if (server->input_transport_factory == NULL)
   {
     server->input_transport_factory =
diff --git a/lib/c_glib/src/thrift/c_glib/thrift.c b/lib/c_glib/src/thrift/c_glib/thrift.c
index 079cb51..15f409f 100644
--- a/lib/c_glib/src/thrift/c_glib/thrift.c
+++ b/lib/c_glib/src/thrift/c_glib/thrift.c
@@ -25,8 +25,10 @@
 void
 thrift_hash_table_get_keys (gpointer key, gpointer value, gpointer user_data)
 {
-  THRIFT_UNUSED_VAR (value);
   GList **list = (GList **) user_data;
+
+  THRIFT_UNUSED_VAR (value);
+
   *list = g_list_append (*list, key);
 }
 
diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_buffered_transport.c b/lib/c_glib/src/thrift/c_glib/transport/thrift_buffered_transport.c
index ee8e1aa..ede28cf 100644
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_buffered_transport.c
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_buffered_transport.c
@@ -80,13 +80,13 @@
   gint ret = 0;
   guint32 want = len;
   guint32 got = 0;
-  guchar tmpdata[len];
+  guchar *tmpdata = g_alloca (len);
   guint32 have = t->r_buf->len;
 
-  // we shouldn't hit this unless the buffer doesn't have enough to read
+  /* we shouldn't hit this unless the buffer doesn't have enough to read */
   assert (t->r_buf->len < want);
 
-  // first copy what we have in our buffer.
+  /* first copy what we have in our buffer. */
   if (have > 0)
   {
     memcpy (buf, t->r_buf, t->r_buf->len);
@@ -94,9 +94,9 @@
     t->r_buf = g_byte_array_remove_range (t->r_buf, 0, t->r_buf->len);
   }
 
-  // if the buffer is still smaller than what we want to read, then just
-  // read it directly.  otherwise, fill the buffer and then give out
-  // enough to satisfy the read.
+  /* if the buffer is still smaller than what we want to read, then just
+   * read it directly.  otherwise, fill the buffer and then give out
+   * enough to satisfy the read. */
   if (t->r_buf_size < want)
   {
     if ((ret = THRIFT_TRANSPORT_GET_CLASS (t->transport)->read (t->transport,
@@ -107,10 +107,12 @@
     }
     got += ret;
 
-    // copy the data starting from where we left off
-    memcpy (buf + have, tmpdata, got);
+    /* copy the data starting from where we left off */
+    memcpy ((guint8 *)buf + have, tmpdata, got);
     return got + have; 
   } else {
+    guint32 give;
+
     if ((ret = THRIFT_TRANSPORT_GET_CLASS (t->transport)->read (t->transport,
                                                                 tmpdata,
                                                                 want,
@@ -120,11 +122,11 @@
     got += ret;
     t->r_buf = g_byte_array_append (t->r_buf, tmpdata, got);
     
-    // hand over what we have up to what the caller wants
-    guint32 give = want < t->r_buf->len ? want : t->r_buf->len;
+    /* hand over what we have up to what the caller wants */
+    give = want < t->r_buf->len ? want : t->r_buf->len;
 
 
-    memcpy (buf + len - want, t->r_buf->data, give);
+    memcpy ((guint8 *)buf + len - want, t->r_buf->data, give);
     t->r_buf = g_byte_array_remove_range (t->r_buf, 0, give);
     want -= give;
 
@@ -170,8 +172,8 @@
   guint32 have_bytes = t->w_buf->len;
   guint32 space = t->w_buf_size - t->w_buf->len;
 
-  // we need two syscalls because the buffered data plus the buffer itself
-  // is too big.
+  /* we need two syscalls because the buffered data plus the buffer itself
+   * is too big. */
   if ((have_bytes + len >= 2*t->w_buf_size) || (have_bytes == 0))
   {
     if (have_bytes > 0)
@@ -200,7 +202,7 @@
   }
 
   t->w_buf = g_byte_array_remove_range (t->w_buf, 0, t->w_buf->len);
-  t->w_buf = g_byte_array_append (t->w_buf, buf+space, len-space);
+  t->w_buf = g_byte_array_append (t->w_buf, (guint8 *)buf + space, len-space);
 
   return TRUE;
 }
@@ -242,7 +244,7 @@
 
   if (t->w_buf != NULL && t->w_buf->len > 0)
   {
-    // write the buffer and then empty it
+    /* write the buffer and then empty it */
     if (!THRIFT_TRANSPORT_GET_CLASS (t->transport)->write (t->transport,
                                                            t->w_buf->data,
                                                            t->w_buf->len,
@@ -290,9 +292,10 @@
 thrift_buffered_transport_get_property (GObject *object, guint property_id,
                                         GValue *value, GParamSpec *pspec)
 {
-  THRIFT_UNUSED_VAR (pspec);
   ThriftBufferedTransport *transport = THRIFT_BUFFERED_TRANSPORT (object);
 
+  THRIFT_UNUSED_VAR (pspec);
+
   switch (property_id)
   {
     case PROP_THRIFT_BUFFERED_TRANSPORT_TRANSPORT:
@@ -312,9 +315,10 @@
 thrift_buffered_transport_set_property (GObject *object, guint property_id,
                                         const GValue *value, GParamSpec *pspec)
 {
-  THRIFT_UNUSED_VAR (pspec);
   ThriftBufferedTransport *transport = THRIFT_BUFFERED_TRANSPORT (object);
 
+  THRIFT_UNUSED_VAR (pspec);
+
   switch (property_id)
   {
     case PROP_THRIFT_BUFFERED_TRANSPORT_TRANSPORT:
@@ -333,6 +337,7 @@
 static void
 thrift_buffered_transport_class_init (ThriftBufferedTransportClass *cls)
 {
+  ThriftTransportClass *ttc = THRIFT_TRANSPORT_CLASS (cls);
   GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
   GParamSpec *param_spec = NULL;
 
@@ -373,8 +378,6 @@
                                    param_spec);
 
 
-  ThriftTransportClass *ttc = THRIFT_TRANSPORT_CLASS (cls);
-
   gobject_class->finalize = thrift_buffered_transport_finalize;
   ttc->is_open = thrift_buffered_transport_is_open;
   ttc->peek = thrift_buffered_transport_peek;
diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_framed_transport.c b/lib/c_glib/src/thrift/c_glib/transport/thrift_framed_transport.c
index 47a7960..4c8b71f 100644
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_framed_transport.c
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_framed_transport.c
@@ -89,10 +89,12 @@
                              sizeof (sz),
                              error) == sizeof (sz))
   {
+    guchar *tmpdata;
+
     sz = ntohl (sz);
 
     /* create a buffer to hold the data and read that much data */
-    guchar tmpdata[sz];
+    tmpdata = g_alloca (sz);
     bytes = thrift_transport_read (t->transport, tmpdata, sz, error);
 
     if (bytes > 0 && (error == NULL || *error == NULL))
@@ -117,10 +119,10 @@
   guint32 have = t->r_buf->len;
   gint32 result = -1;
 
-  // we shouldn't hit this unless the buffer doesn't have enough to read
+  /* we shouldn't hit this unless the buffer doesn't have enough to read */
   assert (t->r_buf->len < want);
 
-  // first copy what we have in our buffer, if there is anything left
+  /* first copy what we have in our buffer, if there is anything left */
   if (have > 0)
   {
     memcpy (buf, t->r_buf, t->r_buf->len);
@@ -128,14 +130,14 @@
     t->r_buf = g_byte_array_remove_range (t->r_buf, 0, t->r_buf->len);
   }
 
-  // read a frame of input and buffer it
+  /* read a frame of input and buffer it */
   if (thrift_framed_transport_read_frame (transport, error) == TRUE)
   {
-    // hand over what we have up to what the caller wants
+    /* hand over what we have up to what the caller wants */
     guint32 give = want < t->r_buf->len ? want : t->r_buf->len;
 
-    // copy the data into the buffer
-    memcpy (buf + len - want, t->r_buf->data, give);
+    /* copy the data into the buffer */
+    memcpy ((guint8 *)buf + len - want, t->r_buf->data, give);
     t->r_buf = g_byte_array_remove_range (t->r_buf, 0, give);
     want -= give;
 
@@ -179,10 +181,11 @@
 thrift_framed_transport_write_slow (ThriftTransport *transport, gpointer buf,
                                     guint32 len, GError **error)
 {
-  THRIFT_UNUSED_VAR (error);
   ThriftFramedTransport *t = THRIFT_FRAMED_TRANSPORT (transport);
 
-  // append the data to the buffer and we're done
+  THRIFT_UNUSED_VAR (error);
+
+  /* append the data to the buffer and we're done */
   g_byte_array_append (t->w_buf, buf, len);
 
   return TRUE;
@@ -223,13 +226,14 @@
 {
   ThriftFramedTransport *t = THRIFT_FRAMED_TRANSPORT (transport);
   gint32 sz_hbo, sz_nbo;
+  guchar *tmpdata;
 
-  // get the size of the frame in host and network byte order
+  /* get the size of the frame in host and network byte order */
   sz_hbo = t->w_buf->len + sizeof(sz_nbo);
   sz_nbo = (gint32) htonl ((guint32) t->w_buf->len);
 
-  // copy the size of the frame and then the frame itself
-  guchar tmpdata[sz_hbo];
+  /* copy the size of the frame and then the frame itself */
+  tmpdata = g_alloca (sz_hbo);
   memcpy (tmpdata, (guint8 *) &sz_nbo, sizeof (sz_nbo));
 
   if (t->w_buf->len > 0)
@@ -238,7 +242,7 @@
     t->w_buf = g_byte_array_remove_range (t->w_buf, 0, t->w_buf->len);
   }
     
-  // write the buffer and then empty it
+  /* write the buffer and then empty it */
   THRIFT_TRANSPORT_GET_CLASS (t->transport)->write (t->transport,
                                                     tmpdata, sz_hbo,
                                                     error);
@@ -282,9 +286,10 @@
 thrift_framed_transport_get_property (GObject *object, guint property_id,
                                       GValue *value, GParamSpec *pspec)
 {
-  THRIFT_UNUSED_VAR (pspec);
   ThriftFramedTransport *transport = THRIFT_FRAMED_TRANSPORT (object);
 
+  THRIFT_UNUSED_VAR (pspec);
+
   switch (property_id)
   {
     case PROP_THRIFT_FRAMED_TRANSPORT_TRANSPORT:
@@ -304,9 +309,10 @@
 thrift_framed_transport_set_property (GObject *object, guint property_id,
                                       const GValue *value, GParamSpec *pspec)
 {
-  THRIFT_UNUSED_VAR (pspec);
   ThriftFramedTransport *transport = THRIFT_FRAMED_TRANSPORT (object);
 
+  THRIFT_UNUSED_VAR (pspec);
+
   switch (property_id)
   {
     case PROP_THRIFT_FRAMED_TRANSPORT_TRANSPORT:
@@ -325,6 +331,7 @@
 static void
 thrift_framed_transport_class_init (ThriftFramedTransportClass *cls)
 {
+  ThriftTransportClass *ttc = THRIFT_TRANSPORT_CLASS (cls);
   GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
   GParamSpec *param_spec = NULL;
 
@@ -364,9 +371,6 @@
                                    PROP_THRIFT_FRAMED_TRANSPORT_WRITE_BUFFER_SIZE,
                                    param_spec);
 
-
-  ThriftTransportClass *ttc = THRIFT_TRANSPORT_CLASS (cls);
-
   gobject_class->finalize = thrift_framed_transport_finalize;
   ttc->is_open = thrift_framed_transport_is_open;
   ttc->peek = thrift_framed_transport_peek;
diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_memory_buffer.c b/lib/c_glib/src/thrift/c_glib/transport/thrift_memory_buffer.c
index aa05e96..8d66c3d 100644
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_memory_buffer.c
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_memory_buffer.c
@@ -32,7 +32,7 @@
 enum _ThriftMemoryBufferProperties
 {
   PROP_0,
-  PROP_THRIFT_MEMORY_BUFFER_BUFFER_SIZE,
+  PROP_THRIFT_MEMORY_BUFFER_BUFFER_SIZE
 };
 
 G_DEFINE_TYPE(ThriftMemoryBuffer, thrift_memory_buffer, THRIFT_TYPE_TRANSPORT)
@@ -68,10 +68,11 @@
 thrift_memory_buffer_read (ThriftTransport *transport, gpointer buf,
                            guint32 len, GError **error)
 {
-  THRIFT_UNUSED_VAR (error);
   ThriftMemoryBuffer *t = THRIFT_MEMORY_BUFFER (transport);
   guint32 give = len; 
 
+  THRIFT_UNUSED_VAR (error);
+
   /* if the requested bytes are more than what we have available,
    * just give all that we have the buffer */
   if (t->buf->len < len)
@@ -102,10 +103,10 @@
                             const gpointer buf,     
                             const guint32 len, GError **error)
 {
-  THRIFT_UNUSED_VAR (error);
-
   ThriftMemoryBuffer *t = THRIFT_MEMORY_BUFFER (transport);
 
+  THRIFT_UNUSED_VAR (error);
+
   /* return an exception if the buffer doesn't have enough space. */
   if (len > t->buf_size - t->buf->len)
   {
@@ -165,9 +166,10 @@
 thrift_memory_buffer_get_property (GObject *object, guint property_id,
                                    GValue *value, GParamSpec *pspec)
 {
-  THRIFT_UNUSED_VAR (pspec);
   ThriftMemoryBuffer *transport = THRIFT_MEMORY_BUFFER (object);
 
+  THRIFT_UNUSED_VAR (pspec);
+
   switch (property_id)
   {
     case PROP_THRIFT_MEMORY_BUFFER_BUFFER_SIZE:
@@ -181,9 +183,10 @@
 thrift_memory_buffer_set_property (GObject *object, guint property_id,
                                    const GValue *value, GParamSpec *pspec)
 {
-  THRIFT_UNUSED_VAR (pspec);
   ThriftMemoryBuffer *transport = THRIFT_MEMORY_BUFFER (object);
 
+  THRIFT_UNUSED_VAR (pspec);
+
   switch (property_id)
   {
     case PROP_THRIFT_MEMORY_BUFFER_BUFFER_SIZE:
@@ -196,6 +199,7 @@
 static void
 thrift_memory_buffer_class_init (ThriftMemoryBufferClass *cls)
 {
+  ThriftTransportClass *ttc = THRIFT_TRANSPORT_CLASS (cls);
   GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
   GParamSpec *param_spec = NULL;
 
@@ -215,8 +219,6 @@
                                    PROP_THRIFT_MEMORY_BUFFER_BUFFER_SIZE,
                                    param_spec);
 
-  ThriftTransportClass *ttc = THRIFT_TRANSPORT_CLASS (cls);
-
   gobject_class->finalize = thrift_memory_buffer_finalize;
   ttc->is_open = thrift_memory_buffer_is_open;
   ttc->open = thrift_memory_buffer_open;
diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_server_socket.c b/lib/c_glib/src/thrift/c_glib/transport/thrift_server_socket.c
index 5d1f452..97a0ec2 100644
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_server_socket.c
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_server_socket.c
@@ -215,6 +215,7 @@
 static void
 thrift_server_socket_class_init (ThriftServerSocketClass *cls)
 {
+  ThriftServerTransportClass *tstc = THRIFT_SERVER_TRANSPORT_CLASS (cls);
   GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
   GParamSpec *param_spec = NULL;
 
@@ -248,7 +249,6 @@
 
   gobject_class->finalize = thrift_server_socket_finalize;
 
-  ThriftServerTransportClass *tstc = THRIFT_SERVER_TRANSPORT_CLASS (cls);
   tstc->listen = thrift_server_socket_listen;
   tstc->accept = thrift_server_socket_accept;
   tstc->close = thrift_server_socket_close;
diff --git a/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c b/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c
index 6bc9af3..1c147ec 100644
--- a/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c
+++ b/lib/c_glib/src/thrift/c_glib/transport/thrift_socket.c
@@ -186,7 +186,7 @@
 
   while (got < len)
   {
-    ret = recv (socket->sd, buf+got, len-got, 0);
+    ret = recv (socket->sd, (guint8 *)buf + got, len-got, 0);
     if (ret <= 0)
     {
       g_set_error (error, THRIFT_TRANSPORT_ERROR,
@@ -224,7 +224,7 @@
 
   while (sent < len)
   {
-    ret = send (socket->sd, buf + sent, len - sent, 0);
+    ret = send (socket->sd, (guint8 *)buf + sent, len - sent, 0);
     if (ret < 0)
     {
       g_set_error (error, THRIFT_TRANSPORT_ERROR,
@@ -291,9 +291,10 @@
 thrift_socket_get_property (GObject *object, guint property_id,
                             GValue *value, GParamSpec *pspec)
 {
-  THRIFT_UNUSED_VAR (pspec);
   ThriftSocket *socket = THRIFT_SOCKET (object);
 
+  THRIFT_UNUSED_VAR (pspec);
+
   switch (property_id)
   {
     case PROP_THRIFT_SOCKET_HOSTNAME:
@@ -310,9 +311,10 @@
 thrift_socket_set_property (GObject *object, guint property_id,
                             const GValue *value, GParamSpec *pspec)
 {
-  THRIFT_UNUSED_VAR (pspec);
   ThriftSocket *socket = THRIFT_SOCKET (object);
 
+  THRIFT_UNUSED_VAR (pspec);
+
   switch (property_id)
   {
     case PROP_THRIFT_SOCKET_HOSTNAME:
@@ -328,6 +330,7 @@
 static void
 thrift_socket_class_init (ThriftSocketClass *cls)
 {
+  ThriftTransportClass *ttc = THRIFT_TRANSPORT_CLASS (cls);
   GObjectClass *gobject_class = G_OBJECT_CLASS (cls);
   GParamSpec *param_spec = NULL;
 
@@ -355,8 +358,6 @@
   g_object_class_install_property (gobject_class, PROP_THRIFT_SOCKET_PORT,
                                    param_spec);
 
-  ThriftTransportClass *ttc = THRIFT_TRANSPORT_CLASS (cls);
-
   gobject_class->finalize = thrift_socket_finalize;
   ttc->is_open = thrift_socket_is_open;
   ttc->peek = thrift_socket_peek;