diff --git a/include/maxscale/cdefs.h b/include/maxscale/cdefs.h index 89819b78a..13c6e8e6e 100644 --- a/include/maxscale/cdefs.h +++ b/include/maxscale/cdefs.h @@ -79,6 +79,17 @@ */ #define MXS_MAX(a,b) ((a)>(b) ? (a) : (b)) +/** + * Define function attributes + * + * The function attributes are compiler specific. + */ +#ifdef __GNUC__ +#define mxs_attribute(a) __attribute__(a) +#else +#define mxs_attribute(a) +#endif + /** * COMMON INCLUDE FILES */ diff --git a/include/maxscale/log_manager.h b/include/maxscale/log_manager.h index e926599a0..e1452d7d4 100644 --- a/include/maxscale/log_manager.h +++ b/include/maxscale/log_manager.h @@ -119,7 +119,7 @@ static inline bool mxs_log_priority_is_enabled(int priority) int mxs_log_message(int priority, const char* modname, const char* file, int line, const char* function, - const char* format, ...) __attribute__((format(printf, 6, 7))); + const char* format, ...) mxs_attribute((format(printf, 6, 7))); /** * Log an error, warning, notice, info, or debug message. * diff --git a/include/maxscale/modulecmd.h b/include/maxscale/modulecmd.h index bcbb3d5ff..427208484 100644 --- a/include/maxscale/modulecmd.h +++ b/include/maxscale/modulecmd.h @@ -256,7 +256,7 @@ bool modulecmd_call_command(const MODULECMD *cmd, const MODULECMD_ARG *args, jso * @param format Format string * @param ... Format string arguments */ -void modulecmd_set_error(const char *format, ...); +void modulecmd_set_error(const char *format, ...) mxs_attribute((format (printf, 1, 2))); /** * @brief Get the latest error generated by the modulecmd system diff --git a/server/core/config_runtime.cc b/server/core/config_runtime.cc index 846af16c2..9559c078e 100644 --- a/server/core/config_runtime.cc +++ b/server/core/config_runtime.cc @@ -42,6 +42,9 @@ static SPINLOCK crt_lock = SPINLOCK_INIT; #define RUNTIME_ERRMSG_BUFSIZE 512 thread_local char runtime_errmsg[RUNTIME_ERRMSG_BUFSIZE]; +/** Attributes need to be in the declaration */ +static void runtime_error(const char* fmt, ...) mxs_attribute((format (printf, 1, 2))); + static void runtime_error(const char* fmt, ...) { va_list list; @@ -1166,7 +1169,8 @@ static bool validate_ssl_json(json_t* params) !mxs_json_pointer(params, CN_SSL_CERT) || !mxs_json_pointer(params, CN_SSL_CA_CERT)) { - runtime_error("SSL configuration requires '%s', '%s' and '%s' parameters"); + runtime_error("SSL configuration requires '%s', '%s' and '%s' parameters", + CN_SSL_KEY, CN_SSL_CERT, CN_SSL_CA_CERT); rval = false; } diff --git a/server/core/modulecmd.cc b/server/core/modulecmd.cc index 7849de63a..6d2b4f615 100644 --- a/server/core/modulecmd.cc +++ b/server/core/modulecmd.cc @@ -509,7 +509,7 @@ MODULECMD_ARG* modulecmd_arg_parse(const MODULECMD *cmd, int argc, const void ** if (!process_argument(cmd, &cmd->arg_types[i], argv[i], &arg->argv[i], &err)) { error = true; - modulecmd_set_error("Argument %d, %s: %s", i + 1, err, argv[i] ? argv[i] : "No argument given"); + modulecmd_set_error("Argument %d, %s: %s", i + 1, err, argv[i] ? (char*)argv[i] : "No argument given"); break; } }