Patch from Ross McFarland to compile with strict warnings
authorMark Slee <mcslee@apache.org>
Sat, 9 Feb 2008 00:02:26 +0000 (00:02 +0000)
committerMark Slee <mcslee@apache.org>
Sat, 9 Feb 2008 00:02:26 +0000 (00:02 +0000)
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

compiler/cpp/src/generate/t_cpp_generator.cc
compiler/cpp/src/generate/t_cpp_generator.h
lib/cpp/src/concurrency/Util.h
lib/cpp/src/server/TNonblockingServer.h
lib/cpp/src/server/TServer.h
lib/cpp/src/transport/TTransport.h
lib/cpp/src/transport/TTransportUtils.h

index adb1028..011f5eb 100644 (file)
@@ -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<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 @@ 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<t_field*>& 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;
 }
index 8b395a5..bdbaf7d 100644 (file)
@@ -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);
 
index 3ebc0b1..29e3567 100644 (file)
@@ -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>
index df3103f..e043b54 100644 (file)
@@ -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");
index b51d1d5..d7245c7 100644 (file)
@@ -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<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:
 
index 469acd2..d775d4e 100644 (file)
@@ -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.");
   }
 
index 0aa29c9..83abf8e 100644 (file)
@@ -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;
   }