diff options
author | Steve Kondik <shade@chemlab.org> | 2017-07-08 02:06:16 -0700 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2017-07-10 09:14:43 -0700 |
commit | 5ec2d09b84d8ea77c67ac0b9ea44c0590d252ad3 (patch) | |
tree | 8b996b672ae85f489c062962590c279b37171ec6 /common | |
parent | ff69074635de8690b17f9ed90b8a6188ebb6176f (diff) | |
download | tigervnc-5ec2d09b84d8ea77c67ac0b9ea44c0590d252ad3.tar.gz tigervnc-5ec2d09b84d8ea77c67ac0b9ea44c0590d252ad3.zip |
rfb: Silence nonliteral format string warning in Logger
Clang complains loudly about this with Wformat=2, so add
a __printf_attr to help out.
Fixes:
/home/shade/dev/tigervnc/common/rfb/Logger.cxx:48:35: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
vsnprintf(buf1, sizeof(buf1)-1, format, ap);
^~~~~~
1 error generated.
Diffstat (limited to 'common')
-rw-r--r-- | common/rfb/LogWriter.h | 6 | ||||
-rw-r--r-- | common/rfb/Logger.h | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/common/rfb/LogWriter.h b/common/rfb/LogWriter.h index 69b530ca..104a8752 100644 --- a/common/rfb/LogWriter.h +++ b/common/rfb/LogWriter.h @@ -36,9 +36,9 @@ // is assigned a particular log level. #define DEF_LOGFUNCTION(name, level) \ - inline void v##name(const char* fmt, va_list ap) { \ - if (m_log && (level <= m_level)) \ - m_log->write(level, m_name, fmt, ap);\ + inline void v##name(const char* fmt, va_list ap) __printf_attr(2, 0) { \ + if (m_log && (level <= m_level)) \ + m_log->write(level, m_name, fmt, ap); \ } \ inline void name(const char* fmt, ...) __printf_attr(2, 3) { \ if (m_log && (level <= m_level)) { \ diff --git a/common/rfb/Logger.h b/common/rfb/Logger.h index e53764b7..b75594c9 100644 --- a/common/rfb/Logger.h +++ b/common/rfb/Logger.h @@ -28,6 +28,12 @@ // and is attached to a particular Logger instance and // is assigned a particular log level. +#ifdef __GNUC__ +# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b))) +#else +# define __printf_attr(a, b) +#endif // __GNUC__ + namespace rfb { class Logger { @@ -45,7 +51,7 @@ namespace rfb { // -=- Write data to a log virtual void write(int level, const char *logname, const char *text) = 0; - void write(int level, const char *logname, const char* format, va_list ap); + void write(int level, const char *logname, const char* format, va_list ap) __printf_attr(4, 0); // -=- Register a logger |