From: Mark Slee Date: Sat, 9 Feb 2008 00:02:26 +0000 (+0000) Subject: Patch from Ross McFarland to compile with strict warnings X-Git-Tag: 0.2.0~1003 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=a8de4895f61196d6bf139c3becbad5800b977e1c;p=common%2Fthrift.git Patch from Ross McFarland to compile with strict warnings Summary: Use comment trick in params that are unused to prevent warnings Reviewed By: dreiss Test Plan: Generate C++ code and compile -W -Wall git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665469 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/compiler/cpp/src/generate/t_cpp_generator.cc b/compiler/cpp/src/generate/t_cpp_generator.cc index adb1028a..011f5eb6 100644 --- a/compiler/cpp/src/generate/t_cpp_generator.cc +++ b/compiler/cpp/src/generate/t_cpp_generator.cc @@ -515,7 +515,8 @@ void t_cpp_generator::generate_struct_definition(ofstream& out, // Generate an equality testing operator. Make it inline since the compiler // will do a better job than we would when deciding whether to inline it. out << - indent() << "bool operator == (const " << tstruct->get_name() << " & rhs) const" << endl; + indent() << "bool operator == (const " << tstruct->get_name() << " & " << + (members.size() > 0 ? "rhs" : "/* rhs */") << ") const" << endl; scope_up(out); for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { // Most existing Thrift code does not use isset or optional/required, @@ -1160,7 +1161,7 @@ void t_cpp_generator::generate_service_null(t_service* tservice) { vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { f_header_ << - indent() << function_signature(*f_iter) << " {" << endl; + indent() << function_signature(*f_iter, "", false) << " {" << endl; indent_up(); t_type* returntype = (*f_iter)->get_returntype(); if (returntype->is_void()) { @@ -2769,7 +2770,8 @@ string t_cpp_generator::declare_field(t_field* tfield, bool init, bool pointer, * @return String of rendered function definition */ string t_cpp_generator::function_signature(t_function* tfunction, - string prefix) { + string prefix, + bool name_params) { t_type* ttype = tfunction->get_returntype(); t_struct* arglist = tfunction->get_arglist(); @@ -2777,12 +2779,12 @@ string t_cpp_generator::function_signature(t_function* tfunction, bool empty = arglist->get_members().size() == 0; return "void " + prefix + tfunction->get_name() + - "(" + type_name(ttype) + "& _return" + - (empty ? "" : (", " + argument_list(arglist))) + ")"; + "(" + type_name(ttype) + (name_params ? "& _return" : "& /* _return */") + + (empty ? "" : (", " + argument_list(arglist, name_params))) + ")"; } else { return type_name(ttype) + " " + prefix + tfunction->get_name() + - "(" + argument_list(arglist) + ")"; + "(" + argument_list(arglist, name_params) + ")"; } } @@ -2792,7 +2794,7 @@ string t_cpp_generator::function_signature(t_function* tfunction, * @param tstruct The struct definition * @return Comma sepearated list of all field names in that struct */ -string t_cpp_generator::argument_list(t_struct* tstruct) { +string t_cpp_generator::argument_list(t_struct* tstruct, bool name_params) { string result = ""; const vector& fields = tstruct->get_members(); @@ -2804,7 +2806,8 @@ string t_cpp_generator::argument_list(t_struct* tstruct) { } else { result += ", "; } - result += type_name((*f_iter)->get_type(), false, true) + " " + (*f_iter)->get_name(); + result += type_name((*f_iter)->get_type(), false, true) + " " + + (name_params ? (*f_iter)->get_name() : "/* " + (*f_iter)->get_name() + " */"); } return result; } diff --git a/compiler/cpp/src/generate/t_cpp_generator.h b/compiler/cpp/src/generate/t_cpp_generator.h index 8b395a5a..bdbaf7d6 100644 --- a/compiler/cpp/src/generate/t_cpp_generator.h +++ b/compiler/cpp/src/generate/t_cpp_generator.h @@ -147,8 +147,8 @@ class t_cpp_generator : public t_oop_generator { std::string type_name(t_type* ttype, bool in_typedef=false, bool arg=false); std::string base_type_name(t_base_type::t_base tbase); std::string declare_field(t_field* tfield, bool init=false, bool pointer=false, bool constant=false, bool reference=false); - std::string function_signature(t_function* tfunction, std::string prefix=""); - std::string argument_list(t_struct* tstruct); + std::string function_signature(t_function* tfunction, std::string prefix="", bool name_params=true); + std::string argument_list(t_struct* tstruct, bool name_params=true); std::string type_to_enum(t_type* ttype); std::string local_reflection_name(const char*, t_type* ttype); diff --git a/lib/cpp/src/concurrency/Util.h b/lib/cpp/src/concurrency/Util.h index 3ebc0b14..29e3567d 100644 --- a/lib/cpp/src/concurrency/Util.h +++ b/lib/cpp/src/concurrency/Util.h @@ -7,7 +7,9 @@ #ifndef _THRIFT_CONCURRENCY_UTIL_H_ #define _THRIFT_CONCURRENCY_UTIL_H_ 1 +#ifdef HAVE_CONFIG_H #include +#endif #include #include diff --git a/lib/cpp/src/server/TNonblockingServer.h b/lib/cpp/src/server/TNonblockingServer.h index df3103f7..e043b546 100644 --- a/lib/cpp/src/server/TNonblockingServer.h +++ b/lib/cpp/src/server/TNonblockingServer.h @@ -310,13 +310,13 @@ class TConnection { void transition(); // Handler wrapper - static void eventHandler(int fd, short which, void* v) { + static void eventHandler(int fd, short /* which */, void* v) { assert(fd == ((TConnection*)v)->socket_); ((TConnection*)v)->workSocket(); } // Handler wrapper for task block - static void taskHandler(int fd, short which, void* v) { + static void taskHandler(int fd, short /* which */, void* v) { assert(fd == ((TConnection*)v)->taskHandle_); if (-1 == ::close(((TConnection*)v)->taskHandle_)) { GlobalOutput("TConnection::taskHandler close handle failed, resource leak"); diff --git a/lib/cpp/src/server/TServer.h b/lib/cpp/src/server/TServer.h index b51d1d5e..d7245c7c 100644 --- a/lib/cpp/src/server/TServer.h +++ b/lib/cpp/src/server/TServer.h @@ -44,14 +44,14 @@ class TServerEventHandler { /** * Called when a new client has connected and is about to being processing. */ - virtual void clientBegin(boost::shared_ptr input, - boost::shared_ptr output) {} + virtual void clientBegin(boost::shared_ptr /* input */, + boost::shared_ptr /* output */) {} /** * Called when a client has finished making requests. */ - virtual void clientEnd(boost::shared_ptr input, - boost::shared_ptr output) {} + virtual void clientEnd(boost::shared_ptr /* input */, + boost::shared_ptr /* output */) {} protected: diff --git a/lib/cpp/src/transport/TTransport.h b/lib/cpp/src/transport/TTransport.h index 469acd23..d775d4e5 100644 --- a/lib/cpp/src/transport/TTransport.h +++ b/lib/cpp/src/transport/TTransport.h @@ -71,7 +71,7 @@ class TTransport { * @return How many bytes were actually read * @throws TTransportException If an error occurs */ - virtual uint32_t read(uint8_t* buf, uint32_t len) { + virtual uint32_t read(uint8_t* /* buf */, uint32_t /* len */) { throw TTransportException(TTransportException::NOT_OPEN, "Base TTransport cannot read."); } @@ -115,7 +115,7 @@ class TTransport { * @param buf The data to write out * @throws TTransportException if an error occurs */ - virtual void write(const uint8_t* buf, uint32_t len) { + virtual void write(const uint8_t* /* buf */, uint32_t /* len */) { throw TTransportException(TTransportException::NOT_OPEN, "Base TTransport cannot write."); } @@ -162,7 +162,7 @@ class TTransport { * the transport's internal buffers. * @throws TTransportException if an error occurs */ - virtual const uint8_t* borrow(uint8_t* buf, uint32_t* len) { + virtual const uint8_t* borrow(uint8_t* /* buf */, uint32_t* /* len */) { return NULL; } @@ -175,7 +175,7 @@ class TTransport { * @param len How many bytes to consume * @throws TTransportException If an error occurs */ - virtual void consume(uint32_t len) { + virtual void consume(uint32_t /* len */) { throw TTransportException(TTransportException::NOT_OPEN, "Base TTransport cannot consume."); } diff --git a/lib/cpp/src/transport/TTransportUtils.h b/lib/cpp/src/transport/TTransportUtils.h index 0aa29c99..83abf8e0 100644 --- a/lib/cpp/src/transport/TTransportUtils.h +++ b/lib/cpp/src/transport/TTransportUtils.h @@ -34,7 +34,7 @@ class TNullTransport : public TTransport { void open() {} - void write(const uint8_t* buf, uint32_t len) { + void write(const uint8_t* /* buf */, uint32_t /* len */) { return; }