Add format checks for printf-style functions
Added format checks to functions that expect printf style arguments and fixed any broken calls to these functions.
This commit is contained in:
parent
b5202a99f4
commit
730072e2ef
@ -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
|
||||
*/
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user