loader: Mark set_error() with format attribute

This commit is contained in:
Paweł Bylica 2019-04-17 16:40:14 +02:00
parent 4484a8b74a
commit 32af5f41ac
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
1 changed files with 13 additions and 3 deletions

View File

@ -31,7 +31,16 @@
#define DLL_GET_ERROR_MSG() dlerror() #define DLL_GET_ERROR_MSG() dlerror()
#endif #endif
#define PATH_MAX_LENGTH 4096 #ifdef __has_attribute
#if __has_attribute(format)
#define ATTR_FORMAT(archetype, string_index, first_to_check) \
__attribute__((format(archetype, string_index, first_to_check)))
#endif
#endif
#ifndef ATTR_FORMAT
#define ATTR_FORMAT(...)
#endif
#if !_WIN32 #if !_WIN32
/* /*
@ -48,6 +57,8 @@ static void strcpy_s(char* dest, size_t destsz, const char* src)
} }
#endif #endif
#define PATH_MAX_LENGTH 4096
static const char* last_error_msg = NULL; static const char* last_error_msg = NULL;
#define LAST_ERROR_MSG_BUFFER_SIZE 511 #define LAST_ERROR_MSG_BUFFER_SIZE 511
@ -56,8 +67,7 @@ static const char* last_error_msg = NULL;
// It has one null byte extra to avoid buffer read overflow during concurrent access. // It has one null byte extra to avoid buffer read overflow during concurrent access.
static char last_error_msg_buffer[LAST_ERROR_MSG_BUFFER_SIZE + 1]; static char last_error_msg_buffer[LAST_ERROR_MSG_BUFFER_SIZE + 1];
// TODO: Change that into a macro - will be simpler and we will get compilers warnings for snprintf ATTR_FORMAT(printf, 2, 3)
// misuse.
static enum evmc_loader_error_code set_error(enum evmc_loader_error_code error_code, static enum evmc_loader_error_code set_error(enum evmc_loader_error_code error_code,
const char* format, const char* format,
...) ...)