Selaa lähdekoodia

2010-10-27 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

	Added printf format check attribute.
	* src/Logger.h
	* src/StringFormat.h
Tatsuhiro Tsujikawa 15 vuotta sitten
vanhempi
commit
9ff8e55d04
3 muutettua tiedostoa jossa 28 lisäystä ja 11 poistoa
  1. 6 0
      ChangeLog
  2. 20 10
      src/Logger.h
  3. 2 1
      src/StringFormat.h

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2010-10-27  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
+
+	Added printf format check attribute.
+	* src/Logger.h
+	* src/StringFormat.h
+
 2010-10-27  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Use std::numeric_limits<time_t> instead of checking of

+ 20 - 10
src/Logger.h

@@ -92,25 +92,35 @@ public:
 
   virtual ~Logger();
 
-  void debug(const char* msg, ...);
+  void debug(const char* msg, ...)
+    __attribute__ ((format (printf, 2, 3)));
 
-  void debug(const char* msg, const Exception& ex, ...);
+  void debug(const char* msg, const Exception& ex, ...)
+    __attribute__ ((format (printf, 2, 4)));
 
-  void info(const char* msg, ...);
+  void info(const char* msg, ...)
+    __attribute__ ((format (printf, 2, 3)));
 
-  void info(const char* msg, const Exception& ex, ...);
+  void info(const char* msg, const Exception& ex, ...)
+    __attribute__ ((format (printf, 2, 4)));
 
-  void notice(const char* msg, ...);
+  void notice(const char* msg, ...)
+    __attribute__ ((format (printf, 2, 3)));
 
-  void notice(const char* msg, const Exception& ex, ...);
+  void notice(const char* msg, const Exception& ex, ...)
+    __attribute__ ((format (printf, 2, 4)));
 
-  void warn(const char* msg, ...);
+  void warn(const char* msg, ...)
+    __attribute__ ((format (printf, 2, 3)));
 
-  void warn(const char* msg, const Exception& ex, ...);
+  void warn(const char* msg, const Exception& ex, ...)
+    __attribute__ ((format (printf, 2, 4)));
 
-  void error(const char*  msg, ...);
+  void error(const char*  msg, ...)
+    __attribute__ ((format (printf, 2, 3)));
 
-  void error(const char* msg, const Exception& ex, ...);
+  void error(const char* msg, const Exception& ex, ...)
+    __attribute__ ((format (printf, 2, 4)));
 
   void openFile(const std::string& filename);
 

+ 2 - 1
src/StringFormat.h

@@ -47,7 +47,8 @@ class StringFormat {
 private:
   std::string msg_;
 public:
-  StringFormat(const char* fmt, ...);
+  StringFormat(const char* fmt, ...)
+    __attribute__ ((format (printf, 2, 3)));
 
   const std::string& str() const;
 };