Guard a few more format strings with __attribute__((format))

This will cause compile-time error messages to be raised if someone
passes incorrect parameters to these strings.
This commit is contained in:
Johanna Amann 2017-04-17 21:46:58 +02:00
parent b3d7d8b1da
commit 15375ba1e3
2 changed files with 4 additions and 4 deletions

View file

@ -66,11 +66,11 @@ public:
// Report a runtime error in evaluating a Bro script expression. This // Report a runtime error in evaluating a Bro script expression. This
// function will not return but raise an InterpreterException. // function will not return but raise an InterpreterException.
void ExprRuntimeError(const Expr* expr, const char* fmt, ...); void ExprRuntimeError(const Expr* expr, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
// Report a runtime error in evaluating a Bro script expression. This // Report a runtime error in evaluating a Bro script expression. This
// function will not return but raise an InterpreterException. // function will not return but raise an InterpreterException.
void RuntimeError(const Location* location, const char* fmt, ...); void RuntimeError(const Location* location, const char* fmt, ...) __attribute__((format(printf, 3, 4)));
// Report a traffic weirdness, i.e., an unexpected protocol situation // Report a traffic weirdness, i.e., an unexpected protocol situation
// that may lead to incorrectly processing a connnection. // that may lead to incorrectly processing a connnection.
@ -123,7 +123,7 @@ public:
private: private:
void DoLog(const char* prefix, EventHandlerPtr event, FILE* out, void DoLog(const char* prefix, EventHandlerPtr event, FILE* out,
Connection* conn, val_list* addl, bool location, bool time, Connection* conn, val_list* addl, bool location, bool time,
const char* postfix, const char* fmt, va_list ap); const char* postfix, const char* fmt, va_list ap) __attribute__((format(printf, 10, 0)));
// The order if addl, name needs to be like that since fmt_name can // The order if addl, name needs to be like that since fmt_name can
// contain format specifiers // contain format specifiers

View file

@ -240,7 +240,7 @@ private:
enum class ErrorType { INFO, WARNING, ERROR }; enum class ErrorType { INFO, WARNING, ERROR };
void ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, const char* fmt, ...) __attribute__((format(printf, 5, 6))); void ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, const char* fmt, ...) __attribute__((format(printf, 5, 6)));
void ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, const char* fmt, va_list ap); void ErrorHandler(const Stream* i, ErrorType et, bool reporter_send, const char* fmt, va_list ap) __attribute__((format(printf, 5, 0)));
Stream* FindStream(const string &name); Stream* FindStream(const string &name);
Stream* FindStream(ReaderFrontend* reader); Stream* FindStream(ReaderFrontend* reader);