diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-09-26 23:53:33 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2012-09-26 23:53:33 +0200 |
commit | 24618c56527b7180feaf858b3a1c7990f4cd7105 (patch) | |
tree | edc13fe91ef4e54209ccc8f4541cd7cc96524a48 | |
parent | e8db95ccb2ac16055e0af1177f69127da40f52de (diff) | |
download | osc-graphics-24618c56527b7180feaf858b3a1c7990f4cd7105.tar.gz |
let the compiler check format-strings and params in OSCServer::add/del_method() calls
also allow add_method() with NULL format string
-rw-r--r-- | osc_server.cpp | 8 | ||||
-rw-r--r-- | osc_server.h | 8 |
2 files changed, 11 insertions, 5 deletions
diff --git a/osc_server.cpp b/osc_server.cpp index 119d276..7b220cd 100644 --- a/osc_server.cpp +++ b/osc_server.cpp @@ -65,7 +65,7 @@ OSCServer::OSCServer(const char *port) { server = lo_server_thread_new(port, error_handler); - add_method(NULL, generic_handler, NULL, ""); + add_method(NULL, generic_handler, NULL, NULL); } void @@ -75,8 +75,10 @@ OSCServer::add_method_v(MethodHandlerId **hnd, const char *types, { char buf[255]; - vsnprintf(buf, sizeof(buf), fmt, ap); - lo_server_thread_add_method(server, buf, types, handler, data); + if (fmt) + vsnprintf(buf, sizeof(buf), fmt, ap); + lo_server_thread_add_method(server, fmt ? buf : NULL, types, + handler, data); if (hnd) *hnd = new MethodHandlerId(types, buf, data); diff --git a/osc_server.h b/osc_server.h index b14dfa8..2380028 100644 --- a/osc_server.h +++ b/osc_server.h @@ -37,7 +37,8 @@ public: private: void add_method_v(MethodHandlerId **hnd, const char *types, lo_method_handler handler, void *data, - const char *fmt, va_list ap); + const char *fmt, va_list ap) + __attribute__((format(printf, 6, 0))); public: typedef void (*MethodHandlerCb)(Layer *obj, lo_arg **argv); @@ -62,6 +63,7 @@ public: add_method(MethodHandlerId **hnd, const char *types, lo_method_handler handler, void *data, const char *fmt, ...) + __attribute__((format(printf, 6, 7))) { va_list ap; va_start(ap, fmt); @@ -72,6 +74,7 @@ public: add_method(const char *types, lo_method_handler handler, void *data, const char *fmt, ...) + __attribute__((format(printf, 5, 6))) { va_list ap; va_start(ap, fmt); @@ -79,7 +82,8 @@ public: va_end(ap); } - void del_method(const char *types, const char *fmt, ...); + void del_method(const char *types, const char *fmt, ...) + __attribute__((format(printf, 3, 4))); inline void del_method(MethodHandlerId *hnd) { |