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 adb1028..011f5eb 100644
--- a/compiler/cpp/src/generate/t_cpp_generator.cc
+++ b/compiler/cpp/src/generate/t_cpp_generator.cc
@@ -515,7 +515,8 @@
     // 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 @@
   vector<t_function*>::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 @@
  * @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 @@
     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 @@
  * @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<t_field*>& fields = tstruct->get_members();
@@ -2804,7 +2806,8 @@
     } 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 8b395a5..bdbaf7d 100644
--- a/compiler/cpp/src/generate/t_cpp_generator.h
+++ b/compiler/cpp/src/generate/t_cpp_generator.h
@@ -147,8 +147,8 @@
   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 3ebc0b1..29e3567 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 <config.h>
+#endif
 
 #include <assert.h>
 #include <stddef.h>
diff --git a/lib/cpp/src/server/TNonblockingServer.h b/lib/cpp/src/server/TNonblockingServer.h
index df3103f..e043b54 100644
--- a/lib/cpp/src/server/TNonblockingServer.h
+++ b/lib/cpp/src/server/TNonblockingServer.h
@@ -310,13 +310,13 @@
   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 b51d1d5..d7245c7 100644
--- a/lib/cpp/src/server/TServer.h
+++ b/lib/cpp/src/server/TServer.h
@@ -44,14 +44,14 @@
   /**
    * Called when a new client has connected and is about to being processing.
    */
-  virtual void clientBegin(boost::shared_ptr<TProtocol> input,
-                           boost::shared_ptr<TProtocol> output) {}
+  virtual void clientBegin(boost::shared_ptr<TProtocol> /* input */,
+                           boost::shared_ptr<TProtocol> /* output */) {}
 
   /**
    * Called when a client has finished making requests.
    */
-  virtual void clientEnd(boost::shared_ptr<TProtocol> input,
-                         boost::shared_ptr<TProtocol> output) {}
+  virtual void clientEnd(boost::shared_ptr<TProtocol> /* input */,
+                         boost::shared_ptr<TProtocol> /* output */) {}
 
  protected:
 
diff --git a/lib/cpp/src/transport/TTransport.h b/lib/cpp/src/transport/TTransport.h
index 469acd2..d775d4e 100644
--- a/lib/cpp/src/transport/TTransport.h
+++ b/lib/cpp/src/transport/TTransport.h
@@ -71,7 +71,7 @@
    * @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 @@
    * @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 @@
    *         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 @@
    * @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 0aa29c9..83abf8e 100644
--- a/lib/cpp/src/transport/TTransportUtils.h
+++ b/lib/cpp/src/transport/TTransportUtils.h
@@ -34,7 +34,7 @@
 
   void open() {}
 
-  void write(const uint8_t* buf, uint32_t len) {
+  void write(const uint8_t* /* buf */, uint32_t /* len */) {
     return;
   }