From a8cef6e55bcbcf7045adbc3ccca5e59e7c504f6b Mon Sep 17 00:00:00 2001 From: Roger Meier Date: Sun, 17 Jul 2011 18:55:59 +0000 Subject: [PATCH] THRIFT-916 gcc warnings in c++ header files git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1147700 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/src/generate/t_as3_generator.cc | 1 - compiler/cpp/src/generate/t_cpp_generator.cc | 8 +++++++- compiler/cpp/src/generate/t_go_generator.cc | 13 ++++++++++++- compiler/cpp/src/generate/t_java_generator.cc | 1 + lib/cpp/src/async/TEvhttpClientChannel.cpp | 4 ++++ lib/cpp/src/async/TEvhttpServer.cpp | 1 + lib/cpp/src/transport/TSSLSocket.cpp | 7 +++++-- lib/cpp/src/transport/TSSLSocket.h | 10 +++++----- test/cpp/src/StressTest.cpp | 2 +- test/cpp/src/StressTestNonBlocking.cpp | 2 +- test/cpp/src/TestClient.cpp | 5 ++++- test/cpp/src/TestServer.cpp | 11 ++++++++++- 12 files changed, 51 insertions(+), 14 deletions(-) mode change 100644 => 100755 compiler/cpp/src/generate/t_go_generator.cc mode change 100644 => 100755 lib/cpp/src/async/TEvhttpClientChannel.cpp mode change 100644 => 100755 lib/cpp/src/async/TEvhttpServer.cpp mode change 100644 => 100755 lib/cpp/src/transport/TSSLSocket.cpp mode change 100644 => 100755 lib/cpp/src/transport/TSSLSocket.h mode change 100644 => 100755 test/cpp/src/StressTest.cpp mode change 100644 => 100755 test/cpp/src/StressTestNonBlocking.cpp mode change 100644 => 100755 test/cpp/src/TestClient.cpp diff --git a/compiler/cpp/src/generate/t_as3_generator.cc b/compiler/cpp/src/generate/t_as3_generator.cc index cebb0784..05514f15 100644 --- a/compiler/cpp/src/generate/t_as3_generator.cc +++ b/compiler/cpp/src/generate/t_as3_generator.cc @@ -769,7 +769,6 @@ void t_as3_generator::generate_as3_struct_definition(ofstream &out, "public function " << tstruct->get_name() << "() {" << endl; indent_up(); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - t_type* t = get_true_type((*m_iter)->get_type()); if ((*m_iter)->get_value() != NULL) { indent(out) << "this._" << (*m_iter)->get_name() << " = " << (*m_iter)->get_value()->get_integer() << ";" << endl; diff --git a/compiler/cpp/src/generate/t_cpp_generator.cc b/compiler/cpp/src/generate/t_cpp_generator.cc index 389bbf90..6b1f6077 100755 --- a/compiler/cpp/src/generate/t_cpp_generator.cc +++ b/compiler/cpp/src/generate/t_cpp_generator.cc @@ -3007,6 +3007,12 @@ void t_cpp_generator::generate_process_function(t_service* tservice, indent() << "T_GENERIC_PROTOCOL(this, oprot, _oprot);" << endl << endl; } + if (tfunction->is_oneway()) { + out << + indent() << "(void) seqid;" << endl << + indent() << "(void) oprot;" << endl; + } + out << indent() << tservice->get_name() + "_" + tfunction->get_name() + "_args" << " args;" << endl << indent() << "void* ctx = NULL;" << endl << @@ -3996,7 +4002,7 @@ string t_cpp_generator::function_signature(t_function* tfunction, ? "()" : ("(" + type_name(ttype) + " const& _return)")); if (has_xceptions) { - exn_cob = ", std::tr1::function exn_cob"; + exn_cob = ", std::tr1::function /* exn_cob */"; } } else { throw "UNKNOWN STYLE"; diff --git a/compiler/cpp/src/generate/t_go_generator.cc b/compiler/cpp/src/generate/t_go_generator.cc old mode 100644 new mode 100755 index fe34bb75..6b2efc8a --- a/compiler/cpp/src/generate/t_go_generator.cc +++ b/compiler/cpp/src/generate/t_go_generator.cc @@ -46,6 +46,8 @@ class t_go_generator : public t_generator { const std::string& option_string) : t_generator(program) { + (void) parsed_options; + (void) option_string; std::map::const_iterator iter; out_dir_base_ = "gen-go"; } @@ -771,6 +773,7 @@ void t_go_generator::generate_go_struct_definition(ofstream& out, bool is_exception, bool is_result) { + (void) is_exception; const vector& members = tstruct->get_members(); const vector& sorted_members = tstruct->get_sorted_members(); vector::const_iterator m_iter; @@ -996,6 +999,7 @@ void t_go_generator::generate_go_struct_reader(ofstream& out, t_struct* tstruct, const string& tstruct_name, bool is_result) { + (void) is_result; const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; string escaped_tstruct_name(escape_string(tstruct->get_name())); @@ -2236,6 +2240,8 @@ void t_go_generator::generate_deserialize_field(ofstream &out, string err, bool inclass, bool coerceData) { + (void) inclass; + (void) coerceData; t_type* orig_type = tfield->get_type(); t_type* type = get_true_type(orig_type); string name(prefix + publicize(variable_name_to_go_name(tfield->get_name()))); @@ -2330,6 +2336,7 @@ void t_go_generator::generate_deserialize_struct(ofstream &out, bool declare, string prefix, string err) { + (void) err; string err2(tmp("err")); string eq(" := "); if(!declare) { @@ -2452,6 +2459,8 @@ void t_go_generator::generate_deserialize_map_element(ofstream &out, bool declare, string prefix, string err) { + (void) declare; + (void) err; string key = tmp("_key"); string val = tmp("_val"); t_field fkey(tmap->get_key_type(), key); @@ -2472,6 +2481,7 @@ void t_go_generator::generate_deserialize_set_element(ofstream &out, bool declare, string prefix, string err) { + (void) declare; string elem = tmp("_elem"); t_field felem(tset->get_elem_type(), elem); @@ -2489,6 +2499,7 @@ void t_go_generator::generate_deserialize_list_element(ofstream &out, bool declare, string prefix, string err) { + (void) declare; string elem = tmp("_elem"); t_field felem(tlist->get_elem_type(), elem); @@ -3074,4 +3085,4 @@ string t_go_generator::type_to_spec_args(t_type* ttype) { } -THRIFT_REGISTER_GENERATOR(go, "Go", ""); +THRIFT_REGISTER_GENERATOR(go, "Go", "") diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc index 04aaa406..1b551726 100644 --- a/compiler/cpp/src/generate/t_java_generator.cc +++ b/compiler/cpp/src/generate/t_java_generator.cc @@ -3875,6 +3875,7 @@ void t_java_generator::generate_java_struct_clear(std::ofstream& out, t_struct* // generates java method to serialize (in the Java sense) the object void t_java_generator::generate_java_struct_write_object(ofstream& out, t_struct* tstruct) { + (void) tstruct; indent(out) << "private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {" << endl; indent(out) << " try {" << endl; indent(out) << " write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));" << endl; diff --git a/lib/cpp/src/async/TEvhttpClientChannel.cpp b/lib/cpp/src/async/TEvhttpClientChannel.cpp old mode 100644 new mode 100755 index 8b471736..b5265ce4 --- a/lib/cpp/src/async/TEvhttpClientChannel.cpp +++ b/lib/cpp/src/async/TEvhttpClientChannel.cpp @@ -93,12 +93,16 @@ bool TEvhttpClientChannel::sendAndRecvMessage( bool TEvhttpClientChannel::sendMessage( const VoidCallback& cob, apache::thrift::transport::TMemoryBuffer* message) { + (void) cob; + (void) message; abort(); // XXX } bool TEvhttpClientChannel::recvMessage( const VoidCallback& cob, apache::thrift::transport::TMemoryBuffer* message) { + (void) cob; + (void) message; abort(); // XXX } diff --git a/lib/cpp/src/async/TEvhttpServer.cpp b/lib/cpp/src/async/TEvhttpServer.cpp old mode 100644 new mode 100755 index 30e33e52..701f8bd0 --- a/lib/cpp/src/async/TEvhttpServer.cpp +++ b/lib/cpp/src/async/TEvhttpServer.cpp @@ -124,6 +124,7 @@ void TEvhttpServer::process(struct evhttp_request* req) { void TEvhttpServer::complete(RequestContext* ctx, bool success) { + (void) success; std::auto_ptr ptr(ctx); int code = 200; diff --git a/lib/cpp/src/transport/TSSLSocket.cpp b/lib/cpp/src/transport/TSSLSocket.cpp old mode 100644 new mode 100755 index 602a8945..913c2586 --- a/lib/cpp/src/transport/TSSLSocket.cpp +++ b/lib/cpp/src/transport/TSSLSocket.cpp @@ -258,7 +258,7 @@ void TSSLSocket::authorize() { // both certificate and access manager are present string host; - sockaddr_storage sa = {}; + sockaddr_storage sa; socklen_t saLength = sizeof(sa); if (getpeername(socket_, (sockaddr*)&sa, &saLength) != 0) { @@ -591,7 +591,10 @@ void buildErrors(string& errors, int errno_copy) { * Default implementation of AccessManager */ Decision DefaultClientAccessManager::verify(const sockaddr_storage& sa) - throw() { return SKIP; } + throw() { + (void) sa; + return SKIP; +} Decision DefaultClientAccessManager::verify(const string& host, const char* name, diff --git a/lib/cpp/src/transport/TSSLSocket.h b/lib/cpp/src/transport/TSSLSocket.h old mode 100644 new mode 100755 index 6b241b21..a0a15029 --- a/lib/cpp/src/transport/TSSLSocket.h +++ b/lib/cpp/src/transport/TSSLSocket.h @@ -201,7 +201,7 @@ class TSSLSocketFactory { * @param password Pass collected password to OpenSSL * @param size Maximum length of password including NULL character */ - virtual void getPassword(std::string& password, int size) { } + virtual void getPassword(std::string& /* password */, int /* size */) {} private: bool server_; boost::shared_ptr access_; @@ -253,7 +253,7 @@ class AccessManager { enum Decision { DENY = -1, // deny access SKIP = 0, // cannot make decision, move on to next (if any) - ALLOW = 1, // allow access + ALLOW = 1 // allow access }; /** * Destructor @@ -270,7 +270,7 @@ class AccessManager { * @param sa Peer IP address * @return True if the peer is trusted, false otherwise */ - virtual Decision verify(const sockaddr_storage& sa) throw() { return DENY; } + virtual Decision verify(const sockaddr_storage& /* sa */ ) throw() { return DENY; } /** * Determine whether the peer should be granted access or not. It's called * every time a DNS subjectAltName/common name is extracted from peer's @@ -284,7 +284,7 @@ class AccessManager { * * Note: The "name" parameter may be UTF8 encoded. */ - virtual Decision verify(const std::string& host, const char* name, int size) + virtual Decision verify(const std::string& /* host */, const char* /* name */, int /* size */) throw() { return DENY; } /** * Determine whether the peer should be granted access or not. It's called @@ -295,7 +295,7 @@ class AccessManager { * @param size Length of the IP address * @return True if the peer is trusted, false otherwise */ - virtual Decision verify(const sockaddr_storage& sa, const char* data, int size) + virtual Decision verify(const sockaddr_storage& /* sa */, const char* /* data */, int /* size */) throw() { return DENY; } }; diff --git a/test/cpp/src/StressTest.cpp b/test/cpp/src/StressTest.cpp old mode 100644 new mode 100755 index 0c919563..4892722d --- a/test/cpp/src/StressTest.cpp +++ b/test/cpp/src/StressTest.cpp @@ -92,7 +92,7 @@ class Server : public ServiceIf { int64_t echoI64(const int64_t arg) {return arg;} void echoString(string& out, const string &arg) { if (arg != "hello") { - T_ERROR_ABORT("WRONG STRING!!!!"); + T_ERROR_ABORT("WRONG STRING (%s)!!!!", arg.c_str()); } out = arg; } diff --git a/test/cpp/src/StressTestNonBlocking.cpp b/test/cpp/src/StressTestNonBlocking.cpp old mode 100644 new mode 100755 index 7650d492..0d8bc3ab --- a/test/cpp/src/StressTestNonBlocking.cpp +++ b/test/cpp/src/StressTestNonBlocking.cpp @@ -98,7 +98,7 @@ class Server : public ServiceIf { int64_t echoI64(const int64_t arg) {return arg;} void echoString(string& out, const string &arg) { if (arg != "hello") { - T_ERROR_ABORT("WRONG STRING!!!!"); + T_ERROR_ABORT("WRONG STRING (%s)!!!!", arg.c_str()); } out = arg; } diff --git a/test/cpp/src/TestClient.cpp b/test/cpp/src/TestClient.cpp old mode 100644 new mode 100755 index 3f22ad22..9aed5510 --- a/test/cpp/src/TestClient.cpp +++ b/test/cpp/src/TestClient.cpp @@ -63,6 +63,9 @@ uint64_t now() } static void testString_clientReturn(const char* host, int port, event_base *base, TProtocolFactory* protocolFactory, ThriftTestCobClient* client) { + (void) host; + (void) port; + (void) protocolFactory; try { string s; client->recv_testString(s); @@ -283,7 +286,7 @@ int main(int argc, char** argv) { */ printf("testDouble(-5.2098523)"); double dub = testClient.testDouble(-5.2098523); - printf(" = %lf\n", dub); + printf(" = %f\n", dub); /** * STRUCT TEST diff --git a/test/cpp/src/TestServer.cpp b/test/cpp/src/TestServer.cpp index 2c9d43a4..4afbef68 100755 --- a/test/cpp/src/TestServer.cpp +++ b/test/cpp/src/TestServer.cpp @@ -88,7 +88,7 @@ class TestHandler : public ThriftTestIf { } double testDouble(const double thing) { - printf("testDouble(%lf)\n", thing); + printf("testDouble(%f)\n", thing); return thing; } @@ -193,6 +193,7 @@ class TestHandler : public ThriftTestIf { } void testInsanity(map > &insane, const Insanity &argument) { + (void) argument; printf("testInsanity()\n"); Xtruct hello; @@ -262,6 +263,10 @@ class TestHandler : public ThriftTestIf { } void testMulti(Xtruct &hello, const int8_t arg0, const int32_t arg1, const int64_t arg2, const std::map &arg3, const Numberz::type arg4, const UserId arg5) { + (void) arg3; + (void) arg4; + (void) arg5; + printf("testMulti()\n"); hello.string_thing = "Hello2"; @@ -319,21 +324,25 @@ class TestHandler : public ThriftTestIf { class TestProcessorEventHandler : public TProcessorEventHandler { virtual void* getContext(const char* fn_name, void* serverContext) { + (void) serverContext; return new std::string(fn_name); } virtual void freeContext(void* ctx, const char* fn_name) { + (void) fn_name; delete static_cast(ctx); } virtual void preRead(void* ctx, const char* fn_name) { communicate("preRead", ctx, fn_name); } virtual void postRead(void* ctx, const char* fn_name, uint32_t bytes) { + (void) bytes; communicate("postRead", ctx, fn_name); } virtual void preWrite(void* ctx, const char* fn_name) { communicate("preWrite", ctx, fn_name); } virtual void postWrite(void* ctx, const char* fn_name, uint32_t bytes) { + (void) bytes; communicate("postWrite", ctx, fn_name); } virtual void asyncComplete(void* ctx, const char* fn_name) { -- 2.17.1