diff --git a/src/client/client_send.c b/src/client/client_send.c index 535cb5d..c777d52 100644 --- a/src/client/client_send.c +++ b/src/client/client_send.c @@ -1967,7 +1967,7 @@ static int incremental_check(Client* client, File* file, const Config* config, send_status(client->file_descriptor, STATUS_ERROR); return -1; } - log_debug_message(LOG_DEBUG_RECV, "recv: delta signature for %s (%d blocks)", + log_debug_message(LOG_DEBUG_RECV, "recv: delta signature for %s (%u blocks)", file_wire_path(file), sig->block_count); *out_sig = sig; return 2; diff --git a/src/client/usage.c b/src/client/usage.c index b4e0584..cd5e35c 100644 --- a/src/client/usage.c +++ b/src/client/usage.c @@ -165,7 +165,7 @@ void print_usage(void) { printf(" --no-delta, or --no-incremental)\n"); printf(" --no-fuzzy Disable --fuzzy\n"); printf(" -B , --block-size , --delta-block \n"); - printf(" Delta block size in bytes (default: %d)\n", DELTA_BLOCK_SIZE_DEFAULT); + printf(" Delta block size in bytes (default: %u)\n", DELTA_BLOCK_SIZE_DEFAULT); printf(" --delta-max Max file size for delta transfer (default: %llu)\n", DELTA_MAX_FILE_SIZE); printf(" -j, --threads[=N] Enable the multithreaded scanner/loader/sender\n"); diff --git a/src/shared/log.h b/src/shared/log.h index b3a258c..d64c467 100644 --- a/src/shared/log.h +++ b/src/shared/log.h @@ -5,6 +5,15 @@ #include #include +/* Ask the compiler to type-check the printf-style arguments of the variadic + * logging helpers. Only enabled for GNU-compatible compilers (gcc/clang). */ +#if defined(__GNUC__) +#define LOG_PRINTF_ATTR(fmt_idx, first_vararg_idx) \ + __attribute__((format(printf, fmt_idx, first_vararg_idx))) +#else +#define LOG_PRINTF_ATTR(fmt_idx, first_vararg_idx) +#endif + typedef enum { LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_WARNING, LOG_LEVEL_ERROR } LogLevel; typedef enum { LOG_STDERR_ERRORS, LOG_STDERR_ALL } LogStderrMode; @@ -59,7 +68,7 @@ typedef enum { LOG_INFO_PROGRESS | LOG_INFO_MOUNT, } LogInfoFlag; -void log_message(LogLevel log_level, const char* message, ...); +void log_message(LogLevel log_level, const char* message, ...) LOG_PRINTF_ATTR(2, 3); void log_perror(const char* context); void set_log_level(LogLevel level); void set_log_debug_flags(uint32_t flags); @@ -68,10 +77,10 @@ uint32_t get_log_debug_flags(void); * the debug log level is enabled AND the flag is selected. Hot paths use this * to skip expensive message formatting/escaping when the line is filtered. */ bool log_debug_enabled(LogDebugFlag flag); -void log_debug_message(LogDebugFlag flag, const char* message, ...); +void log_debug_message(LogDebugFlag flag, const char* message, ...) LOG_PRINTF_ATTR(2, 3); void set_log_info_flags(uint32_t flags); uint32_t get_log_info_flags(void); -void log_info_message(LogInfoFlag flag, const char* message, ...); +void log_info_message(LogInfoFlag flag, const char* message, ...) LOG_PRINTF_ATTR(2, 3); void log_set_file(FILE* fp); void log_set_8_bit_output(bool enabled); bool log_get_8_bit_output(void); diff --git a/src/shared/protocol.c b/src/shared/protocol.c index 581ebb8..fa1fff2 100644 --- a/src/shared/protocol.c +++ b/src/shared/protocol.c @@ -390,7 +390,7 @@ bool protocol_send_n_data(ProtocolSession* session, const void* data, size_t dat if (session->ssl) wait_events = POLLOUT; } - log_debug_message(LOG_DEBUG_IO, " Send n Data: %zu", total_bytes_send); + log_debug_message(LOG_DEBUG_IO, " Send n Data: %zd", total_bytes_send); atomic_fetch_add(&io_bytes_written, (unsigned long long)total_bytes_send); return true; }