mirror of
https://github.com/anope/anope.git
synced 2026-06-27 10:46:38 +02:00
Mark format strings with the GNU printf attribute.
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
+2
-2
@@ -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.
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+12
-12
@@ -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 ¶m) { }
|
||||
|
||||
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;
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+3
-3
@@ -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
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user