summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon South <ssouth@simonsouth.com>2015-08-03 10:51:16 +0000
committerRoger Meier <roger@apache.org>2015-08-03 22:10:23 +0200
commit38e7155c039f1dba6dd73a3114dd3a5ac7052418 (patch)
tree92f45ebeb3fff1d46efa7aa066dc3dc348c95732
parent7bc907a95931985792e11713eb38244259f1b926 (diff)
downloadthrift-38e7155c039f1dba6dd73a3114dd3a5ac7052418.tar.gz
THRIFT-3288 c_glib: Build unit tests without compiler warnings
These changes allow the unit tests for C (GLib) to build without compiler warnings, even with additional warnings enabled. They include - Disabling string-function optimizations when glibc is used, as these produce compiler warnings when a string function is used within a call to assert (); - Remove the "LL" suffix (added in C99) from 64-bit integer literals; - Replace C++-style ("//") comments with C-style equivalents; - Remove unused constant declarations that generated warnings; and - Mark (or remove, from main ()) unused function parameters.
-rwxr-xr-xlib/c_glib/test/testbinaryprotocol.c12
-rwxr-xr-xlib/c_glib/test/testbufferedtransport.c3
-rwxr-xr-xlib/c_glib/test/testframedtransport.c3
-rwxr-xr-xlib/c_glib/test/testoptionalrequired.c4
-rwxr-xr-xlib/c_glib/test/testsimpleserver.c5
-rwxr-xr-xlib/c_glib/test/teststruct.c8
-rwxr-xr-xlib/c_glib/test/testthrifttestclient.cpp12
-rwxr-xr-xlib/c_glib/test/testtransportsocket.c3
8 files changed, 35 insertions, 15 deletions
diff --git a/lib/c_glib/test/testbinaryprotocol.c b/lib/c_glib/test/testbinaryprotocol.c
index c6de38587..517fd2556 100755
--- a/lib/c_glib/test/testbinaryprotocol.c
+++ b/lib/c_glib/test/testbinaryprotocol.c
@@ -17,6 +17,14 @@
* under the License.
*/
+/* Disable string-function optimizations when glibc is used, as these produce
+ compiler warnings about string length when a string function is used inside
+ a call to assert () */
+#include <features.h>
+#ifdef __GLIBC__
+#define __NO_STRING_INLINES 1
+#endif
+
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
@@ -33,7 +41,7 @@
#define TEST_BYTE 123
#define TEST_I16 12345
#define TEST_I32 1234567890
-#define TEST_I64 123456789012345LL
+#define TEST_I64 123456789012345
#define TEST_DOUBLE 1234567890.123
#define TEST_STRING "this is a test string 1234567890!@#$%^&*()"
#define TEST_PORT 51199
@@ -654,7 +662,7 @@ thrift_server_complex_types (const int port)
thrift_binary_protocol_read_string (protocol, &message_name, NULL);
g_object_unref (client);
- // TODO: investigate g_object_unref (tbp);
+ /* TODO: investigate g_object_unref (tbp); */
g_object_unref (tsocket);
}
diff --git a/lib/c_glib/test/testbufferedtransport.c b/lib/c_glib/test/testbufferedtransport.c
index e4bee69b8..3203a66b5 100755
--- a/lib/c_glib/test/testbufferedtransport.c
+++ b/lib/c_glib/test/testbufferedtransport.c
@@ -31,9 +31,6 @@
#include "../src/thrift/c_glib/transport/thrift_buffered_transport.c"
-static const char TEST_ADDRESS[] = "localhost";
-static const short TEST_PORT = 64444;
-
static void thrift_server (const int port);
/* test object creation and destruction */
diff --git a/lib/c_glib/test/testframedtransport.c b/lib/c_glib/test/testframedtransport.c
index 7261ff56d..d50ff23c7 100755
--- a/lib/c_glib/test/testframedtransport.c
+++ b/lib/c_glib/test/testframedtransport.c
@@ -30,9 +30,6 @@
#include "../src/thrift/c_glib/transport/thrift_framed_transport.c"
-static const char TEST_ADDRESS[] = "localhost";
-static const short TEST_PORT = 64444;
-
static void thrift_server (const int port);
/* test object creation and destruction */
diff --git a/lib/c_glib/test/testoptionalrequired.c b/lib/c_glib/test/testoptionalrequired.c
index 931d8bed1..ae0c3d2e0 100755
--- a/lib/c_glib/test/testoptionalrequired.c
+++ b/lib/c_glib/test/testoptionalrequired.c
@@ -74,7 +74,7 @@ test_simple (void)
s2 = g_object_new (T_TEST_TYPE_SIMPLE, NULL);
s3 = g_object_new (T_TEST_TYPE_SIMPLE, NULL);
- // write-to-read with optional fields
+ /* write-to-read with optional fields */
s1->im_optional = 10;
assert (s1->__isset_im_default == FALSE);
assert (s1->__isset_im_optional == FALSE);
@@ -174,7 +174,7 @@ test_tricky4 (void)
t2 = g_object_new (T_TEST_TYPE_TRICKY2, NULL);
t3 = g_object_new (T_TEST_TYPE_TRICKY3, NULL);
- // throws protocol exception
+ /* throws protocol exception */
write_to_read (THRIFT_STRUCT (t2), THRIFT_STRUCT (t3), NULL, &read_error);
assert (read_error != NULL);
g_error_free (read_error);
diff --git a/lib/c_glib/test/testsimpleserver.c b/lib/c_glib/test/testsimpleserver.c
index cb270b4d9..3af2eeb17 100755
--- a/lib/c_glib/test/testsimpleserver.c
+++ b/lib/c_glib/test/testsimpleserver.c
@@ -53,6 +53,11 @@ gboolean
test_processor_process (ThriftProcessor *processor, ThriftProtocol *in,
ThriftProtocol *out, GError **error)
{
+ THRIFT_UNUSED_VAR (processor);
+ THRIFT_UNUSED_VAR (in);
+ THRIFT_UNUSED_VAR (out);
+ THRIFT_UNUSED_VAR (error);
+
return FALSE;
}
diff --git a/lib/c_glib/test/teststruct.c b/lib/c_glib/test/teststruct.c
index a1b3cc0a1..5d4baf347 100755
--- a/lib/c_glib/test/teststruct.c
+++ b/lib/c_glib/test/teststruct.c
@@ -51,6 +51,10 @@ gint32
thrift_test_struct_read (ThriftStruct *object, ThriftProtocol *protocol,
GError **error)
{
+ THRIFT_UNUSED_VAR (object);
+ THRIFT_UNUSED_VAR (protocol);
+ THRIFT_UNUSED_VAR (error);
+
return 0;
}
@@ -58,6 +62,10 @@ gint32
thrift_test_struct_write (ThriftStruct *object, ThriftProtocol *protocol,
GError **error)
{
+ THRIFT_UNUSED_VAR (object);
+ THRIFT_UNUSED_VAR (protocol);
+ THRIFT_UNUSED_VAR (error);
+
return 0;
}
diff --git a/lib/c_glib/test/testthrifttestclient.cpp b/lib/c_glib/test/testthrifttestclient.cpp
index a80ddf33c..e1737cde3 100755
--- a/lib/c_glib/test/testthrifttestclient.cpp
+++ b/lib/c_glib/test/testthrifttestclient.cpp
@@ -191,6 +191,8 @@ class TestHandler : public ThriftTestIf {
}
void testInsanity(map<UserId, map<Numberz::type,Insanity> > &insane, const Insanity &argument) {
+ THRIFT_UNUSED_VARIABLE (argument);
+
printf("[C -> C++] testInsanity()\n");
Xtruct hello;
@@ -260,6 +262,10 @@ class TestHandler : public ThriftTestIf {
}
void testMulti(Xtruct &hello, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map<int16_t, std::string> &arg3, const Numberz::type arg4, const UserId arg5) {
+ THRIFT_UNUSED_VARIABLE (arg3);
+ THRIFT_UNUSED_VARIABLE (arg4);
+ THRIFT_UNUSED_VARIABLE (arg5);
+
printf("[C -> C++] testMulti()\n");
hello.string_thing = "Hello2";
@@ -582,11 +588,13 @@ test_thrift_client (void)
static void
bailout (int signum)
{
+ THRIFT_UNUSED_VARIABLE (signum);
+
exit (1);
}
int
-main (int argc, char **argv)
+main (void)
{
int status;
int pid = fork ();
@@ -607,7 +615,7 @@ main (int argc, char **argv)
sleep (1);
test_thrift_client ();
kill (pid, SIGINT);
- wait (&status) == pid;
+ assert (wait (&status) == pid);
}
return 0;
diff --git a/lib/c_glib/test/testtransportsocket.c b/lib/c_glib/test/testtransportsocket.c
index bb1d47cec..d91507fbf 100755
--- a/lib/c_glib/test/testtransportsocket.c
+++ b/lib/c_glib/test/testtransportsocket.c
@@ -70,9 +70,6 @@ my_send(int socket, const void *buffer, size_t length, int flags)
#undef recv
#undef send
-static const char TEST_ADDRESS[] = "localhost";
-static const short TEST_PORT = 64444;
-
static void thrift_socket_server (const int port);
/* test object creation and destruction */