summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--include/anope.h2
-rw-r--r--include/channels.h4
-rw-r--r--include/commands.h2
-rw-r--r--include/protocol.h24
-rw-r--r--include/sockets.h4
-rw-r--r--include/sysconf.h.cmake6
-rw-r--r--include/users.h6
-rw-r--r--modules/commands/bs_kick.cpp2
-rw-r--r--modules/protocol/bahamut.cpp2
10 files changed, 30 insertions, 24 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a9195dc96..2d13480b5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -172,7 +172,7 @@ if(MSVC)
# Otherwise, we're not using Visual Studio
else()
# Set the compile flags to have all warnings on (including shadowed variables)
- set(CXXFLAGS "${CXXFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Wpedantic -Wno-unused-parameter ${CMAKE_CXX_FLAGS}")
+ set(CXXFLAGS "${CXXFLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Wformat=2 -Wmissing-format-attribute -Wpedantic -Wno-format-nonliteral -Wno-format-zero-length -Wno-unused-parameter ${CMAKE_CXX_FLAGS}")
endif()
# If CMake has found that the given system requires a special library for dl* calls, include it with the linker flags
diff --git a/include/anope.h b/include/anope.h
index 96ded65a2..31f829195 100644
--- a/include/anope.h
+++ b/include/anope.h
@@ -476,7 +476,7 @@ namespace Anope
* @param ... any number of parameters
* @return a Anope::string
*/
- extern CoreExport string printf(const char *fmt, ...);
+ extern CoreExport string printf(const char *fmt, ...) ATTR_FORMAT(1, 2);
/** Return the last error code
* @return The error code
diff --git a/include/channels.h b/include/channels.h
index 8be4e1335..3ff41005a 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -204,7 +204,7 @@ public:
* @param enforce_mlock Should mlock be enforced on this mode change
* @param cmodes The modes to set
*/
- void SetModes(BotInfo *bi, bool enforce_mlock, const char *cmodes, ...);
+ void SetModes(BotInfo *bi, bool enforce_mlock, const char *cmodes, ...) ATTR_FORMAT(4, 5);
/** Set a string of modes internally on a channel
* @param source The setter
@@ -233,7 +233,7 @@ public:
* @param reason The reason for the kick
* @return true if the kick was successful, false if a module blocked the kick
*/
- bool Kick(BotInfo *bi, User *u, const char *reason = NULL, ...);
+ bool Kick(BotInfo *bi, User *u, const char *reason = NULL, ...) ATTR_FORMAT(4, 5);
/** Get all modes set on this channel, excluding status modes.
* @return a map of modes and their optional parameters.
diff --git a/include/commands.h b/include/commands.h
index 6d10c8da5..cb53cf017 100644
--- a/include/commands.h
+++ b/include/commands.h
@@ -77,7 +77,7 @@ public:
AccessGroup AccessFor(ChannelInfo *ci);
bool IsFounder(ChannelInfo *ci);
- void Reply(const char *message, ...);
+ void Reply(const char *message, ...) ATTR_FORMAT(2, 3);
void Reply(const Anope::string &message);
bool HasCommand(const Anope::string &cmd);
diff --git a/include/protocol.h b/include/protocol.h
index 8d8ca9f8b..86c1528b4 100644
--- a/include/protocol.h
+++ b/include/protocol.h
@@ -128,27 +128,27 @@ public:
* @param user The user to be killed
* @param fmt Kill reason
*/
- virtual void SendSVSKill(const MessageSource &source, User *user, const char *fmt, ...);
+ virtual void SendSVSKill(const MessageSource &source, User *user, const char *fmt, ...) ATTR_FORMAT(4, 5);
- virtual void SendMode(const MessageSource &source, const Channel *dest, const char *fmt, ...);
- virtual void SendMode(const MessageSource &source, User *u, const char *fmt, ...);
+ virtual void SendMode(const MessageSource &source, const Channel *dest, const char *fmt, ...) ATTR_FORMAT(4, 5);
+ virtual void SendMode(const MessageSource &source, User *u, const char *fmt, ...) ATTR_FORMAT(4, 5);
/** Introduces a client to the rest of the network
* @param u The client to introduce
*/
virtual void SendClientIntroduction(User *u) = 0;
- virtual void SendKick(const MessageSource &source, const Channel *chan, User *user, const char *fmt, ...);
+ virtual void SendKick(const MessageSource &source, const Channel *chan, User *user, const char *fmt, ...) ATTR_FORMAT(5, 6);
- virtual void SendNotice(const MessageSource &source, const Anope::string &dest, const char *fmt, ...);
- virtual void SendPrivmsg(const MessageSource &source, const Anope::string &dest, const char *fmt, ...);
- virtual void SendAction(const MessageSource &source, const Anope::string &dest, const char *fmt, ...);
- virtual void SendCTCP(const MessageSource &source, const Anope::string &dest, const char *fmt, ...);
+ virtual void SendNotice(const MessageSource &source, const Anope::string &dest, const char *fmt, ...) ATTR_FORMAT(4, 5);
+ virtual void SendPrivmsg(const MessageSource &source, const Anope::string &dest, const char *fmt, ...) ATTR_FORMAT(4, 5);
+ virtual void SendAction(const MessageSource &source, const Anope::string &dest, const char *fmt, ...) ATTR_FORMAT(4, 5);
+ virtual void SendCTCP(const MessageSource &source, const Anope::string &dest, const char *fmt, ...) ATTR_FORMAT(4, 5);
virtual void SendGlobalNotice(BotInfo *bi, const Server *dest, const Anope::string &msg) = 0;
virtual void SendGlobalPrivmsg(BotInfo *bi, const Server *desc, const Anope::string &msg) = 0;
- virtual void SendQuit(User *u, const char *fmt, ...);
+ virtual void SendQuit(User *u, const char *fmt, ...) ATTR_FORMAT(3, 4);
virtual void SendPing(const Anope::string &servname, const Anope::string &who);
virtual void SendPong(const Anope::string &servname, const Anope::string &who);
@@ -160,7 +160,7 @@ public:
* stacker to be set "soon".
*/
virtual void SendJoin(User *u, Channel *c, const ChannelStatus *status) = 0;
- virtual void SendPart(User *u, const Channel *chan, const char *fmt, ...);
+ virtual void SendPart(User *u, const Channel *chan, const char *fmt, ...) ATTR_FORMAT(4, 5);
/** Force joins a user that isn't ours to a channel.
* @param bi The source of the message
@@ -179,7 +179,7 @@ public:
virtual void SendSVSPart(const MessageSource &source, User *u, const Anope::string &chan, const Anope::string &param) { }
virtual void SendInvite(const MessageSource &source, const Channel *c, User *u);
- virtual void SendGlobops(const MessageSource &source, const char *fmt, ...);
+ virtual void SendGlobops(const MessageSource &source, const char *fmt, ...) ATTR_FORMAT(3, 4);
/** Sends a nick change of one of our clients.
*/
@@ -210,7 +210,7 @@ public:
virtual void SendServer(const Server *) = 0;
virtual void SendSquit(Server *, const Anope::string &message);
- virtual void SendNumeric(int numeric, const Anope::string &dest, const char *fmt, ...);
+ virtual void SendNumeric(int numeric, const Anope::string &dest, const char *fmt, ...) ATTR_FORMAT(4, 5);
virtual void SendLogin(User *u, NickAlias *na) = 0;
virtual void SendLogout(User *u) = 0;
diff --git a/include/sockets.h b/include/sockets.h
index 3df3fce71..d90a52f91 100644
--- a/include/sockets.h
+++ b/include/sockets.h
@@ -319,7 +319,7 @@ public:
protected:
virtual void Write(const char *buffer, size_t l);
public:
- void Write(const char *message, ...);
+ void Write(const char *message, ...) ATTR_FORMAT(2, 3);
void Write(const Anope::string &message);
/** Get the length of the read buffer
@@ -367,7 +367,7 @@ public:
* @param l The length of the data; if 0 then this function returns without doing anything
*/
virtual void Write(const char *buffer, size_t l);
- void Write(const char *message, ...);
+ void Write(const char *message, ...) ATTR_FORMAT(2, 3);
void Write(const Anope::string &message);
/** Called with data from the socket
diff --git a/include/sysconf.h.cmake b/include/sysconf.h.cmake
index 61d998a78..35f876b5e 100644
--- a/include/sysconf.h.cmake
+++ b/include/sysconf.h.cmake
@@ -31,3 +31,9 @@
# endif
# define sleep(x) Sleep(x * 1000)
#endif
+
+#if defined __GNUC__
+# define ATTR_FORMAT(STRINGPOS, FIRSTPOS) __attribute__((format(printf, STRINGPOS, FIRSTPOS)))
+#else
+# define ATTR_FORMAT(STRINGPOS, FIRSTPOS)
+#endif
diff --git a/include/users.h b/include/users.h
index 9c6b525be..28c32f385 100644
--- a/include/users.h
+++ b/include/users.h
@@ -188,7 +188,7 @@ public:
* @param fmt Format of the Message
* @param ... any number of parameters
*/
- void SendMessage(BotInfo *source, const char *fmt, ...);
+ void SendMessage(BotInfo *source, const char *fmt, ...) ATTR_FORMAT(3, 4);
void SendMessage(BotInfo *source, const Anope::string &msg) override;
/** Identify the user to a nick.
@@ -302,13 +302,13 @@ public:
* @param bi The client setting the modes
* @param umodes The modes
*/
- void SetModes(BotInfo *bi, const char *umodes, ...);
+ void SetModes(BotInfo *bi, const char *umodes, ...) ATTR_FORMAT(3, 4);
/** Set a string of modes on a user internally
* @param setter who/what is setting the mode
* @param umodes The modes
*/
- void SetModesInternal(const MessageSource &source, const char *umodes, ...);
+ void SetModesInternal(const MessageSource &source, const char *umodes, ...) ATTR_FORMAT(3, 4);
/** Get modes set for this user.
* @return A string of modes set on the user
diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp
index 454760a12..e1919e241 100644
--- a/modules/commands/bs_kick.cpp
+++ b/modules/commands/bs_kick.cpp
@@ -1070,7 +1070,7 @@ class BSKick : public Module
}
}
- void bot_kick(ChannelInfo *ci, User *u, const char *message, ...)
+ void bot_kick(ChannelInfo *ci, User *u, const char *message, ...) ATTR_FORMAT(4, 5)
{
va_list args;
char buf[1024];
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index b5e4182e1..f58a40a16 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -336,7 +336,7 @@ struct IRCDMessageMode : IRCDMessage
{
User *u = User::Find(params[0]);
if (u)
- u->SetModesInternal(source, "%s", params[1].c_str());
+ u->SetModesInternal(source, params[1]);
}
}
};