diff options
author | Pierre Ossman <ossman@cendio.se> | 2023-01-04 16:22:13 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2023-01-05 16:43:34 +0100 |
commit | 7a36fb8ca702fdf6548d3a791896a161c94af5b4 (patch) | |
tree | 0b481bdc87db90a90b36bb09dd441345a30123eb /common/rfb | |
parent | ebfd56106d033c92f5f1a7d1c55d3509ebf978f7 (diff) | |
download | tigervnc-7a36fb8ca702fdf6548d3a791896a161c94af5b4.tar.gz tigervnc-7a36fb8ca702fdf6548d3a791896a161c94af5b4.zip |
Use __attribute__:s directly
These are supported by gcc and clang, and I don't think MSVC works well
with our code anyway, so let's keep things simple and use these
directly.
Diffstat (limited to 'common/rfb')
-rw-r--r-- | common/rfb/LogWriter.h | 18 | ||||
-rw-r--r-- | common/rfb/Logger.h | 9 | ||||
-rw-r--r-- | common/rfb/SConnection.h | 3 | ||||
-rw-r--r-- | common/rfb/util.h | 9 |
4 files changed, 15 insertions, 24 deletions
diff --git a/common/rfb/LogWriter.h b/common/rfb/LogWriter.h index f718d60e..6eff6da1 100644 --- a/common/rfb/LogWriter.h +++ b/common/rfb/LogWriter.h @@ -25,22 +25,20 @@ #include <rfb/Logger.h> #include <rfb/Configuration.h> -#ifdef __GNUC__ -# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b))) -#else -# define __printf_attr(a, b) -#endif // __GNUC__ - // Each log writer instance has a unique textual name, // and is attached to a particular Log instance and // is assigned a particular log level. #define DEF_LOGFUNCTION(name, level) \ - inline void v##name(const char* fmt, va_list ap) __printf_attr(2, 0) { \ + inline void v##name(const char* fmt, va_list ap) \ + __attribute__((__format__ (__printf__, 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) { \ + inline void name(const char* fmt, ...) \ + __attribute__((__format__ (__printf__, 2, 3))) \ + { \ if (m_log && (level <= m_level)) { \ va_list ap; va_start(ap, fmt); \ m_log->write(level, m_name, fmt, ap);\ @@ -63,7 +61,9 @@ namespace rfb { void setLevel(int level); int getLevel(void) { return m_level; } - inline void write(int level, const char* format, ...) __printf_attr(3, 4) { + inline void write(int level, const char* format, ...) + __attribute__((__format__ (__printf__, 3, 4))) + { if (m_log && (level <= m_level)) { va_list ap; va_start(ap, format); diff --git a/common/rfb/Logger.h b/common/rfb/Logger.h index b75594c9..76f03535 100644 --- a/common/rfb/Logger.h +++ b/common/rfb/Logger.h @@ -28,12 +28,6 @@ // 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 { @@ -51,7 +45,8 @@ 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) __printf_attr(4, 0); + void write(int level, const char *logname, const char* format, va_list ap) + __attribute__((__format__ (__printf__, 4, 0))); // -=- Register a logger diff --git a/common/rfb/SConnection.h b/common/rfb/SConnection.h index 2c382513..b7e30c6a 100644 --- a/common/rfb/SConnection.h +++ b/common/rfb/SConnection.h @@ -222,7 +222,8 @@ namespace rfb { // throwConnFailedException() prints a message to the log, sends a conn // failed message to the client (if possible) and throws a // ConnFailedException. - void throwConnFailedException(const char* format, ...) __printf_attr(2, 3); + void throwConnFailedException(const char* format, ...) + __attribute__((__format__ (__printf__, 2, 3))); void setState(stateEnum s) { state_ = s; } diff --git a/common/rfb/util.h b/common/rfb/util.h index d0b32a61..99d350e3 100644 --- a/common/rfb/util.h +++ b/common/rfb/util.h @@ -29,12 +29,6 @@ struct timeval; -#ifdef __GNUC__ -# define __printf_attr(a, b) __attribute__((__format__ (__printf__, a, b))) -#else -# define __printf_attr(a, b) -#endif // __GNUC__ - namespace rfb { // -=- Class to handle cleanup of arrays of characters @@ -49,7 +43,8 @@ namespace rfb { ~CharArray() { delete [] buf; } - void format(const char *fmt, ...) __printf_attr(2, 3); + void format(const char *fmt, ...) + __attribute__((__format__ (__printf__, 2, 3))); // Get the buffer pointer & clear it (i.e. caller takes ownership) char* takeBuf() {char* tmp = buf; buf = 0; return tmp;} void replaceBuf(char* b) {delete [] buf; buf = b;} |