summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authoraquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-30 02:48:54 +0000
committeraquanight <aquanight@e03df62e-2008-0410-955e-edbf42e46eb7>2008-03-30 02:48:54 +0000
commit58385dd458e927994957b6d603f7f9da3fc52e14 (patch)
tree70c39a58446bd4f60205a9c34cac78524a67dc54 /include
parentbca70575cb3d58127f80d92a388b60b5f5ed2fde (diff)
Commit -Wformat=2 -Wmissing-format-attributes, printf-like functions in inspircd now get treated like printf (meaning compile-time check goodness) in GCC
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9217 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r--include/channels.h8
-rw-r--r--include/inspircd.h10
-rw-r--r--include/logger.h2
-rw-r--r--include/snomasks.h2
-rw-r--r--include/usermanager.h6
-rw-r--r--include/users.h18
6 files changed, 26 insertions, 20 deletions
diff --git a/include/channels.h b/include/channels.h
index 50076fd86..693f429f4 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -371,7 +371,7 @@ class CoreExport Channel : public Extensible
* @param text A printf-style format string which builds the output line without prefix
* @param ... Zero or more POD types
*/
- void WriteChannel(User* user, const char* text, ...);
+ void WriteChannel(User* user, const char* text, ...) CUSTOM_PRINTF(3, 4);
/** Write to a channel, from a user, using std::string for text
* @param user User whos details to prefix the line with
@@ -384,7 +384,7 @@ class CoreExport Channel : public Extensible
* @param text A printf-style format string which builds the output line without prefix
* @param ... Zero or more POD type
*/
- void WriteChannelWithServ(const char* ServName, const char* text, ...);
+ void WriteChannelWithServ(const char* ServName, const char* text, ...) CUSTOM_PRINTF(3, 4);
/** Write to a channel, from a server, using std::string for text
* @param ServName Server name to prefix the line with
@@ -401,7 +401,7 @@ class CoreExport Channel : public Extensible
* @param text A printf-style format string which builds the output line without prefix
* @param ... Zero or more POD type
*/
- void WriteAllExceptSender(User* user, bool serversource, char status, const char* text, ...);
+ void WriteAllExceptSender(User* user, bool serversource, char status, const char* text, ...) CUSTOM_PRINTF(5, 6);
/** Write to all users on a channel except a list of users, using va_args for text
* @param user User whos details to prefix the line with, and to omit from receipt of the message
@@ -412,7 +412,7 @@ class CoreExport Channel : public Extensible
* @param text A printf-style format string which builds the output line without prefix
* @param ... Zero or more POD type
*/
- void WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const char* text, ...);
+ void WriteAllExcept(User* user, bool serversource, char status, CUList &except_list, const char* text, ...) CUSTOM_PRINTF(6, 7);
/** Write to all users on a channel except a specific user, using std::string for text.
* Internally, this calls WriteAllExcept().
diff --git a/include/inspircd.h b/include/inspircd.h
index 84995710d..9798af4f2 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -25,6 +25,12 @@
#undef ERROR
#endif
+#ifdef __GNUC__
+#define CUSTOM_PRINTF(STRING, FIRST) __attribute__((format(printf, STRING, FIRST)))
+#else
+#define CUSTOM_PRINTF(STRING, FIRST)
+#endif
+
// Required system headers.
#include <time.h>
#include <stdarg.h>
@@ -796,7 +802,7 @@ class CoreExport InspIRCd : public classbase
* @param text Format string of to write to the log
* @param ... Format arguments of text to write to the log
*/
- void Log(int level, const char* text, ...);
+ void Log(int level, const char* text, ...) CUSTOM_PRINTF(3, 4);
/** Output a log message to the ircd.log file
* The text will only be output if the current loglevel
@@ -821,7 +827,7 @@ class CoreExport InspIRCd : public classbase
* @param format Format string for the numeric
* @param ... Parameters for the format string
*/
- void SendWhoisLine(User* user, User* dest, int numeric, const char* format, ...);
+ void SendWhoisLine(User* user, User* dest, int numeric, const char* format, ...) CUSTOM_PRINTF(5, 6);
/** Quit a user for excess flood, and if they are not
* fully registered yet, temporarily zline their IP.
diff --git a/include/logger.h b/include/logger.h
index 596f98aee..25dcea85f 100644
--- a/include/logger.h
+++ b/include/logger.h
@@ -253,7 +253,7 @@ class CoreExport LogManager : public classbase
* @param loglevel Log message level (DEBUG, VERBOSE, DEFAULT, SPARSE, NONE)
* @param msg The format of the message to be logged. See your C manual on printf() for details.
*/
- void Log(const std::string &type, int loglevel, const char *fmt, ...);
+ void Log(const std::string &type, int loglevel, const char *fmt, ...) CUSTOM_PRINTF(4, 5);
};
#endif
diff --git a/include/snomasks.h b/include/snomasks.h
index 9541715e3..6e3f75d7a 100644
--- a/include/snomasks.h
+++ b/include/snomasks.h
@@ -100,7 +100,7 @@ class CoreExport SnomaskManager : public Extensible
* @param text A format string containing text to send
* @param ... Format arguments
*/
- void WriteToSnoMask(char letter, const char* text, ...);
+ void WriteToSnoMask(char letter, const char* text, ...) CUSTOM_PRINTF(3, 4);
/** Called once per 5 seconds from the mainloop, this flushes any cached
* snotices. The way the caching works is as follows:
diff --git a/include/usermanager.h b/include/usermanager.h
index 6016a2462..552fb4136 100644
--- a/include/usermanager.h
+++ b/include/usermanager.h
@@ -138,13 +138,13 @@ class CoreExport UserManager : public classbase
* @param text The text format string to send
* @param ... The format arguments
*/
- void ServerNoticeAll(const char* text, ...);
+ void ServerNoticeAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
/** Send a server message (PRIVMSG) to all local users
* @param text The text format string to send
* @param ... The format arguments
*/
- void ServerPrivmsgAll(const char* text, ...);
+ void ServerPrivmsgAll(const char* text, ...) CUSTOM_PRINTF(2, 3);
/** Send text to all users with a specific set of modes
* @param modes The modes to check against, without a +, e.g. 'og'
@@ -154,7 +154,7 @@ class CoreExport UserManager : public classbase
* @param text The text format string to send
* @param ... The format arguments
*/
- void WriteMode(const char* modes, int flags, const char* text, ...);
+ void WriteMode(const char* modes, int flags, const char* text, ...) CUSTOM_PRINTF(4, 5);
};
#endif
diff --git a/include/users.h b/include/users.h
index 74b55202d..29db518b7 100644
--- a/include/users.h
+++ b/include/users.h
@@ -931,7 +931,7 @@ class CoreExport User : public connection
* @param text The format string for text to send to the user
* @param ... POD-type format arguments
*/
- void Write(const char *text, ...);
+ void Write(const char *text, ...) CUSTOM_PRINTF(2, 3);
/** Write text to this user, appending CR/LF and prepending :server.name
* @param text A std::string to send to the user
@@ -942,9 +942,9 @@ class CoreExport User : public connection
* @param text The format string for text to send to the user
* @param ... POD-type format arguments
*/
- void WriteServ(const char* text, ...);
+ void WriteServ(const char* text, ...) CUSTOM_PRINTF(2, 3);
- void WriteNumeric(unsigned int numeric, const char* text, ...);
+ void WriteNumeric(unsigned int numeric, const char* text, ...) CUSTOM_PRINTF(3, 4);
void WriteNumeric(unsigned int numeric, const std::string &text);
@@ -959,7 +959,7 @@ class CoreExport User : public connection
* @param text The format string for text to send to the user
* @param ... POD-type format arguments
*/
- void WriteFrom(User *user, const char* text, ...);
+ void WriteFrom(User *user, const char* text, ...) CUSTOM_PRINTF(3, 4);
/** Write text to the user provided in the first parameter, appending CR/LF, and prepending THIS user's :nick!user@host.
* @param dest The user to route the message to
@@ -972,7 +972,7 @@ class CoreExport User : public connection
* @param text The format string for text to send to the user
* @param ... POD-type format arguments
*/
- void WriteTo(User *dest, const char *data, ...);
+ void WriteTo(User *dest, const char *data, ...) CUSTOM_PRINTF(3, 4);
/** Write to all users that can see this user (including this user in the list), appending CR/LF
* @param text A std::string to send to the users
@@ -983,13 +983,13 @@ class CoreExport User : public connection
* @param text The format string for text to send to the users
* @param ... POD-type format arguments
*/
- void WriteCommon(const char* text, ...);
+ void WriteCommon(const char* text, ...) CUSTOM_PRINTF(2, 3);
/** Write to all users that can see this user (not including this user in the list), appending CR/LF
* @param text The format string for text to send to the users
* @param ... POD-type format arguments
*/
- void WriteCommonExcept(const char* text, ...);
+ void WriteCommonExcept(const char* text, ...) CUSTOM_PRINTF(2, 3);
/** Write to all users that can see this user (not including this user in the list), appending CR/LF
* @param text A std::string to send to the users
@@ -1008,7 +1008,7 @@ class CoreExport User : public connection
* @param text The format string to send in the WALLOPS message
* @param ... Format arguments
*/
- void WriteWallOps(const char* text, ...);
+ void WriteWallOps(const char* text, ...) CUSTOM_PRINTF(2, 3);
/** Write a WALLOPS message from this user to all local opers.
* If this user is not opered, the function will return without doing anything.
@@ -1058,7 +1058,7 @@ class CoreExport User : public connection
* @param text The text format string to send
* @param ... Format arguments
*/
- void SendAll(const char* command, const char* text, ...);
+ void SendAll(const char* command, const char* text, ...) CUSTOM_PRINTF(3, 4);
/** Compile a channel list for this user, and send it to the user 'source'
* Used internally by WHOIS