diff --git a/Makefile b/Makefile index 4ceed4e..add5d08 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,13 @@ endif all: _all +BUILD_DEPS := +ifeq ($(MAKECMDGOALS),clean) +else ifeq ($(MAKECMDGOALS),format) +else + BUILD_DEPS := yes +endif + VASQ_DIR := . include make.mk diff --git a/README.rst b/README.rst index f991a4a..4b36a84 100644 --- a/README.rst +++ b/README.rst @@ -3,8 +3,8 @@ Vanilla Squad ============= :Author: Daniel Walker -:Version: 6.0.3 -:Date: 2022-08-16 +:Version: 6.0.4 +:Date: 2022-08-21 Overview ======== diff --git a/changelog b/changelog index fb03b52..b0d24f5 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,8 @@ +6.0.4: + - Added the format __attribute__ to several printf-like functions. + - Added the BUILD_DEPS variable to make.mk. + - deps.mk is now written to VASQ_OBJ_DIR. + 6.0.3.: - Deprecated various logging wrapper functions such as vasqMalloc. - Added the use of LDFLAGS and VASQ_OBJ_DIR to make.mk. diff --git a/include/vasq/definitions.h b/include/vasq/definitions.h index 1df1670..c8dae5a 100644 --- a/include/vasq/definitions.h +++ b/include/vasq/definitions.h @@ -9,7 +9,7 @@ /** * @brief Current version of the library. */ -#define VASQ_VERSION "6.0.3" +#define VASQ_VERSION "6.0.4" #ifndef NO_OP #define NO_OP ((void)0) diff --git a/include/vasq/logger.h b/include/vasq/logger.h index 831f52b..def4570 100644 --- a/include/vasq/logger.h +++ b/include/vasq/logger.h @@ -189,7 +189,11 @@ vasqSetLoggerUserData(vasqLogger *logger, void *user); * @param format A format string (corresponding to vasqSafeSnprintf's syntax) for the the message. */ void -vasqLogStatement(const vasqLogger *logger, vasqLogLevel_t level, VASQ_CONTEXT_DECL, const char *format, ...); +vasqLogStatement(const vasqLogger *logger, vasqLogLevel_t level, VASQ_CONTEXT_DECL, const char *format, ...) +#ifdef __GNUC__ + __attribute__((format(printf, 6, 7))) +#endif + ; /** * @brief Emit a message at the ALWAYS level. @@ -273,7 +277,11 @@ vasqVLogStatement(const vasqLogger *logger, vasqLogLevel_t level, VASQ_CONTEXT_D * @param format A format string (corresponding to vasqSafeSnprintf's syntax) for the the message. */ void -vasqRawLog(const vasqLogger *logger, const char *format, ...); +vasqRawLog(const vasqLogger *logger, const char *format, ...) +#ifdef __GNUC__ + __attribute__((format(printf, 2, 3))) +#endif + ; /** * @brief Same as vasqRawLog but takes a va_list insead of variable arguments. @@ -313,7 +321,12 @@ vasqHexDump(const vasqLogger *logger, VASQ_CONTEXT_DECL, const char *name, const * * @return The same return value as malloc. */ -void *__attribute__((deprecated)) vasqMalloc(const vasqLogger *logger, VASQ_CONTEXT_DECL, size_t size); +void * +vasqMalloc(const vasqLogger *logger, VASQ_CONTEXT_DECL, size_t size) +#ifdef __GNUC__ + __attribute__((deprecated)) +#endif + ; /** * @brief Wrap vasqMalloc by automatically supplying the file name, function name, and line number. @@ -334,8 +347,12 @@ void *__attribute__((deprecated)) vasqMalloc(const vasqLogger *logger, VASQ_CONT * * @return The same return value as calloc. */ -void *__attribute__((deprecated)) -vasqCalloc(const vasqLogger *logger, VASQ_CONTEXT_DECL, size_t nmemb, size_t size); +void * +vasqCalloc(const vasqLogger *logger, VASQ_CONTEXT_DECL, size_t nmemb, size_t size) +#ifdef __GNUC__ + __attribute__((deprecated)) +#endif + ; /** * @brief Wrap vasqCalloc by automatically supplying the file name, function name, and line number. @@ -356,8 +373,12 @@ vasqCalloc(const vasqLogger *logger, VASQ_CONTEXT_DECL, size_t nmemb, size_t siz * * @return The same return value as realloc. */ -void *__attribute__((deprecated)) -vasqRealloc(const vasqLogger *logger, VASQ_CONTEXT_DECL, void *ptr, size_t size); +void * +vasqRealloc(const vasqLogger *logger, VASQ_CONTEXT_DECL, void *ptr, size_t size) +#ifdef __GNUC__ + __attribute__((deprecated)) +#endif + ; /** * @brief Wrap vasqRealloc by automatically supplying the file name, function name, and line number. @@ -377,7 +398,12 @@ vasqRealloc(const vasqLogger *logger, VASQ_CONTEXT_DECL, void *ptr, size_t size) * * @return The same return value as fork. */ -pid_t __attribute__((deprecated)) vasqFork(const vasqLogger *logger, VASQ_CONTEXT_DECL); +pid_t +vasqFork(const vasqLogger *logger, VASQ_CONTEXT_DECL) +#ifdef __GNUC__ + __attribute__((deprecated)) +#endif + ; /** * @brief Wrap vasqFork by automatically supplying the file name, function name, and line number. @@ -397,8 +423,12 @@ pid_t __attribute__((deprecated)) vasqFork(const vasqLogger *logger, VASQ_CONTEX * @param value The value passed to exit/_exit. * @param quick If true, _exit is called. Otherwise, exit is called. */ -void __attribute__((deprecated)) vasqExit(vasqLogger *logger, VASQ_CONTEXT_DECL, int value, bool quick) - __attribute__((noreturn)); +void +vasqExit(vasqLogger *logger, VASQ_CONTEXT_DECL, int value, bool quick) +#ifdef __GNUC__ + __attribute__((noreturn)) __attribute__((deprecated)) +#endif + ; /** * @brief Wrap vasqExit by automatically supplying the file name, function name, and line number and setting diff --git a/include/vasq/safe_snprintf.h b/include/vasq/safe_snprintf.h index fdf60d8..ac8f750 100644 --- a/include/vasq/safe_snprintf.h +++ b/include/vasq/safe_snprintf.h @@ -25,7 +25,11 @@ * buffer or format is NULL or if size is 0, then -1 is returned. */ ssize_t -vasqSafeSnprintf(char *buffer, size_t size, const char *format, ...); +vasqSafeSnprintf(char *buffer, size_t size, const char *format, ...) +#ifdef __GNUC__ + __attribute__((format(printf, 3, 4))) +#endif + ; /** * @brief Same as vasqSafeSnprintf but takes a va_list instead of variable arguments. @@ -49,7 +53,11 @@ vasqSafeVsnprintf(char *buffer, size_t size, const char *format, va_list args); * @return Same as for vasqSafeSnprintf. */ ssize_t -vasqIncSnprintf(char **output, size_t *capacity, const char *format, ...); +vasqIncSnprintf(char **output, size_t *capacity, const char *format, ...) +#ifdef __GNUC__ + __attribute__((format(printf, 3, 4))) +#endif + ; /** * @brief Same as vasqIncSnprintf but takes a va_list instead of variable arguments. diff --git a/source/logger.c b/source/logger.c index cc7bc3e..15e8bbe 100644 --- a/source/logger.c +++ b/source/logger.c @@ -118,8 +118,8 @@ vlogToBuffer(const vasqLogger *logger, vasqLogLevel_t level, VASQ_CONTEXT_DECL, if (c == '%') { switch (logger->format[++k]) { - unsigned int padding_length; - size_t len, idx; + unsigned int padding_length, len; + size_t idx; char time_string[30], padding[LOG_LEVEL_NAME_MAX_PADDING + 1]; case 'M': vasqIncVsnprintf(dst, remaining, format, args); break; @@ -438,7 +438,8 @@ vasqHexDump(const vasqLogger *logger, VASQ_CONTEXT_DECL, const char *name, const char output[VASQ_LOGGING_LENGTH + HEXDUMP_BUFFER_SIZE]; char *dst = output; int remote_errno; - size_t actual_dump_size, remaining = sizeof(output); + unsigned int actual_dump_size; + size_t remaining = sizeof(output); vasqLogLevel_t dump_level; if (!logger) { @@ -455,7 +456,7 @@ vasqHexDump(const vasqLogger *logger, VASQ_CONTEXT_DECL, const char *name, const "%s (%zu byte%s):", name, size, (size == 1) ? "" : "s"); actual_dump_size = MIN(size, VASQ_HEXDUMP_SIZE); - for (size_t k = 0; k < actual_dump_size; k += VASQ_HEXDUMP_WIDTH) { + for (unsigned int k = 0; k < actual_dump_size; k += VASQ_HEXDUMP_WIDTH) { unsigned int line_length; char print_buffer[VASQ_HEXDUMP_WIDTH];