Clean-ups and fixes to compile with more warnings enabled and with g++.
[invirt/third/libt4.git] / rpc / rpctest.cc
index d4f53f4..f7df5fe 100644 (file)
@@ -35,7 +35,7 @@ namespace srv_protocol {
     REMOTE_PROCEDURE(23, fast, (int &, int));
     REMOTE_PROCEDURE(24, slow, (int &, int));
     REMOTE_PROCEDURE(25, bigrep, (string &, size_t));
-};
+}
 
 // a handler. a and b are arguments, r is the result.
 // there can be multiple arguments but only one result.
@@ -67,7 +67,7 @@ int srv::handle_bigrep(string & r, const size_t len) {
 
 static srv service;
 
-void startserver() {
+static void startserver() {
     server = new rpcs(port);
     server->reg(srv_protocol::_22, &srv::handle_22, &service);
     server->reg(srv_protocol::fast, &srv::handle_fast, &service);
@@ -76,7 +76,7 @@ void startserver() {
     server->start();
 }
 
-void testmarshall() {
+static void testmarshall() {
     marshall m;
     rpc_protocol::request_header rh{1,2,3,4,5};
     m.pack_header(rh);
@@ -85,13 +85,15 @@ void testmarshall() {
     unsigned long long l = 1223344455L;
     size_t sz = 101010101;
     string s = "hallo....";
+    string bin("\x00\x00\x00\x00\x00\x00\x00\x40\x00\x00\x7f\xe5", 12);
     m << i;
     m << l;
     m << s;
     m << sz;
+    m << bin;
 
     string b = m;
-    VERIFY(b.size() == rpc_protocol::RPC_HEADER_SZ+sizeof(i)+sizeof(l)+s.size()+sizeof(int)+sizeof(uint32_t));
+    VERIFY(b.size() == rpc_protocol::RPC_HEADER_SZ+sizeof(i)+sizeof(l)+sizeof(uint32_t)+s.size()+sizeof(uint32_t)+sizeof(uint32_t)+bin.size());
 
     unmarshall un(b, true);
     rpc_protocol::request_header rh1;
@@ -100,16 +102,18 @@ void testmarshall() {
     int i1;
     unsigned long long l1;
     string s1;
+    string bin1;
     size_t sz1;
     un >> i1;
     un >> l1;
     un >> s1;
     un >> sz1;
+    un >> bin1;
     VERIFY(un.okdone());
-    VERIFY(i1==i && l1==l && s1==s && sz1==sz);
+    VERIFY(i1==i && l1==l && s1==s && sz1==sz && bin1==bin);
 }
 
-void client1(size_t cl) {
+static void client1(size_t cl) {
     // test concurrency.
     size_t which_cl = cl % NUM_CL;
 
@@ -142,7 +146,7 @@ void client1(size_t cl) {
     }
 }
 
-void client2(size_t cl) {
+static void client2(size_t cl) {
     size_t which_cl = cl % NUM_CL;
 
     time_t t1;
@@ -158,7 +162,7 @@ void client2(size_t cl) {
     }
 }
 
-void client3(void *xx) {
+static void client3(void *xx) {
     rpcc *c = (rpcc *) xx;
 
     for(int i = 0; i < 4; i++){
@@ -168,7 +172,7 @@ void client3(void *xx) {
     }
 }
 
-void simple_tests(rpcc *c) {
+static void simple_tests(rpcc *c) {
     cout << "simple_tests" << endl;
     // an RPC call to procedure #22.
     // rpcc::call() looks at the argument types to decide how
@@ -219,7 +223,7 @@ void simple_tests(rpcc *c) {
     cout << "simple_tests OK" << endl;
 }
 
-void concurrent_test(size_t nt) {
+static void concurrent_test(size_t nt) {
     // create threads that make lots of calls in parallel,
     // to test thread synchronization for concurrent calls
     // and dispatches.
@@ -236,7 +240,7 @@ void concurrent_test(size_t nt) {
     cout << " OK" << endl;
 }
 
-void lossy_test() {
+static void lossy_test() {
     cout << "start lossy_test ...";
     VERIFY(setenv("RPC_LOSSY", "5", 1) == 0);
 
@@ -265,7 +269,7 @@ void lossy_test() {
     VERIFY(setenv("RPC_LOSSY", "0", 1) == 0);
 }
 
-void failure_test() {
+static void failure_test() {
     rpcc *client1;
     rpcc *client = clients[0];