aboutsummaryrefslogtreecommitdiff
path: root/nxcompshad
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-07-12 22:34:11 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2017-07-13 11:38:42 +0200
commit59e829f3647005a6c93662adfbcea36e27a993d8 (patch)
treeadf3a76db11fc7d20c6c800e47ecd6d10acfef4b /nxcompshad
parent8f5ce18d4f152619387b10d9d05ea4ceccc42b3a (diff)
downloadnx-libs-59e829f3647005a6c93662adfbcea36e27a993d8.tar.gz
nx-libs-59e829f3647005a6c93662adfbcea36e27a993d8.tar.bz2
nx-libs-59e829f3647005a6c93662adfbcea36e27a993d8.zip
nxcompshad: Rewrite Logger class methods to properly take advantage of the 'gnu_printf' format attribute.
Diffstat (limited to 'nxcompshad')
-rw-r--r--nxcompshad/src/Logger.cpp20
-rw-r--r--nxcompshad/src/Logger.h8
2 files changed, 20 insertions, 8 deletions
diff --git a/nxcompshad/src/Logger.cpp b/nxcompshad/src/Logger.cpp
index 9648509b8..2f3eab65c 100644
--- a/nxcompshad/src/Logger.cpp
+++ b/nxcompshad/src/Logger.cpp
@@ -41,11 +41,14 @@
Logger logger;
-void Logger::user(const char *format, va_list arguments)
+void Logger::user(const char *format, ...)
{
char string[1024];
+ va_list arguments;
+ va_start(arguments, format);
vsnprintf(string, 1024, format, arguments);
+ va_end(arguments);
fprintf(stderr, "%s\n", string);
}
@@ -56,20 +59,26 @@ void Logger::error(const char *name, int error)
name, error, strerror(error));
}
-void Logger::warning(const char *name, const char *format, va_list arguments)
+void Logger::warning(const char *name, const char *format, ...)
{
char string[1024];
+ va_list arguments;
+ va_start(arguments, format);
vsnprintf(string, 1024, format, arguments);
+ va_end(arguments);
fprintf(stderr, "%s: WARNING! %s\n", name, string);
}
-void Logger::test(const char *name, const char *format, va_list arguments)
+void Logger::test(const char *name, const char *format, ...)
{
char string[1024];
+ va_list arguments;
+ va_start(arguments, format);
vsnprintf(string, 1024, format, arguments);
+ va_end(arguments);
fprintf(stderr, "%s: %s\n", name, string);
}
@@ -79,11 +88,14 @@ void Logger::trace(const char *name)
fprintf(stderr, "%s\n", name);
}
-void Logger::debug(const char *name, const char *format, va_list arguments)
+void Logger::debug(const char *name, const char *format, ...)
{
char string[1024];
+ va_list arguments;
+ va_start(arguments, format);
vsnprintf(string, 1024, format, arguments);
+ va_end(arguments);
fprintf(stderr, "%s: %s\n", name, string);
}
diff --git a/nxcompshad/src/Logger.h b/nxcompshad/src/Logger.h
index eba81f642..37b378cb2 100644
--- a/nxcompshad/src/Logger.h
+++ b/nxcompshad/src/Logger.h
@@ -43,17 +43,17 @@ class Logger
{
public:
- void user(const char *format, va_list arguments);
+ void user(const char *format, ...) __attribute__((format(gnu_printf, 2, 3)));
void error(const char *name, int error);
- void warning(const char *name, const char *format, va_list arguments);
+ void warning(const char *name, const char *format, ...) __attribute__((format(gnu_printf, 3, 4)));
- void test(const char *name, const char *format, va_list arguments);
+ void test(const char *name, const char *format, ...) __attribute__((format(gnu_printf, 3, 4)));
void trace(const char *name);
- void debug(const char *name, const char *format, va_list arguments);
+ void debug(const char *name, const char *format, ...) __attribute__((format(gnu_printf, 3, 4)));
void dump(const char *name, const char *data, int size);
};