From: Vsevolod Stakhov Date: Mon, 16 Feb 2026 16:00:52 +0000 (+0000) Subject: [Minor] Fix compile warnings X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31eb3e5782363bc31439482362ed59f176a2a106;p=thirdparty%2Frspamd.git [Minor] Fix compile warnings - Fix hexdigests array size (use empty brackets for compiler to determine) - Fix char8_t to char32_t implicit conversion in replxx terminal - Fix hex format specifier in hyperscan debug logging (%xd not %x) - Add forward declaration for struct rspamd_external_libs_ctx - Remove unused is_msgpack variable in protocol.c - Fix logic bug: c >= 'a' || c <= 'f' should be && in hex parsing --- diff --git a/contrib/libottery/chacha_merged.c b/contrib/libottery/chacha_merged.c index c31a8bbd57..3958574eef 100644 --- a/contrib/libottery/chacha_merged.c +++ b/contrib/libottery/chacha_merged.c @@ -34,7 +34,7 @@ Public domain. a = PLUS(a,b); d = ROTATE(XOR(d,a), 8); \ c = PLUS(c,d); b = ROTATE(XOR(b,c), 7); -static const char sigma[16] = "expand 32-byte k"; +static const char sigma[] = "expand 32-byte k"; static void ECRYPT_keysetup(ECRYPT_ctx *x,const u8 *k,u32 ivbits) { diff --git a/contrib/replxx/src/terminal.cxx b/contrib/replxx/src/terminal.cxx index e618219e5d..bff62a1c4d 100644 --- a/contrib/replxx/src/terminal.cxx +++ b/contrib/replxx/src/terminal.cxx @@ -295,7 +295,7 @@ char32_t read_unicode_character(void) { if (nread <= 0) return 0; if (c <= 0x7F || locale::is8BitEncoding) { // short circuit ASCII utf8Count = 0; - return c; + return static_cast(c); } else if (utf8Count < sizeof(utf8String) - 1) { utf8String[utf8Count++] = c; utf8String[utf8Count] = 0; diff --git a/src/libserver/hyperscan_tools.cxx b/src/libserver/hyperscan_tools.cxx index 2922b8e611..d19d674ccd 100644 --- a/src/libserver/hyperscan_tools.cxx +++ b/src/libserver/hyperscan_tools.cxx @@ -397,7 +397,7 @@ hs_get_runtime_db_version() -> std::uint32_t if (sscanf(version_str, "%u.%u.%u", &major, &minor, &patch) == 3) { // Format: (major << 24) | (minor << 16) | (patch << 8) | 0 cached_version = (major << 24) | (minor << 16) | (patch << 8); - msg_debug_hyperscan("detected hyperscan runtime version: %s (0x%08x)", + msg_debug_hyperscan("detected hyperscan runtime version: %s (0x%08xd)", version_str, cached_version); } else { @@ -405,7 +405,7 @@ hs_get_runtime_db_version() -> std::uint32_t // Fallback to compile-time version if available #ifdef HS_DB_VERSION cached_version = HS_DB_VERSION; - msg_debug_hyperscan("using compile-time hyperscan version: 0x%08x", cached_version); + msg_debug_hyperscan("using compile-time hyperscan version: 0x%08xd", cached_version); #else cached_version = 0; #endif diff --git a/src/libserver/logger/logger.c b/src/libserver/logger/logger.c index 37741743cb..5f558cc07e 100644 --- a/src/libserver/logger/logger.c +++ b/src/libserver/logger/logger.c @@ -980,7 +980,7 @@ char * rspamd_log_line_hex_escape(const unsigned char *src, gsize srclen, char *dst, gsize dstlen) { - static const char hexdigests[16] = "0123456789ABCDEF"; + static const char hexdigests[] = "0123456789ABCDEF"; char *d = dst; static uint32_t escape[] = { diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index 092c4855dd..69a21fcfcf 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -2572,7 +2572,6 @@ rspamd_protocol_handle_v3_request(struct rspamd_task *task, /* Parse metadata as UCL (detect JSON vs msgpack from Content-Type) */ struct ucl_parser *parser; - gboolean is_msgpack = FALSE; if (metadata_part->content_type && metadata_part->content_type_len > 0 && @@ -2580,7 +2579,6 @@ rspamd_protocol_handle_v3_request(struct rspamd_task *task, metadata_part->content_type_len, "msgpack", sizeof("msgpack") - 1) != -1) { - is_msgpack = TRUE; parser = ucl_parser_new(UCL_PARSER_SAFE_FLAGS); ucl_parser_add_chunk_full(parser, (const unsigned char *) metadata_part->data, metadata_part->data_len, diff --git a/src/libserver/ssl_util.h b/src/libserver/ssl_util.h index 0a042dbff6..647530710c 100644 --- a/src/libserver/ssl_util.h +++ b/src/libserver/ssl_util.h @@ -25,6 +25,7 @@ extern "C" { #endif struct rspamd_ssl_connection; +struct rspamd_external_libs_ctx; typedef void (*rspamd_ssl_handler_t)(int fd, short what, gpointer d); diff --git a/src/libserver/url.c b/src/libserver/url.c index 90d64af950..2147fb780d 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -4214,7 +4214,7 @@ rspamd_url_encode(struct rspamd_url *url, gsize *pdlen, rspamd_mempool_t *pool) { unsigned char *dest, *d, *dend; - static const char hexdigests[16] = "0123456789ABCDEF"; + static const char hexdigests[] = "0123456789ABCDEF"; unsigned int i; gsize dlen = 0; diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c index b73593653e..f59ff4dd40 100644 --- a/src/libutil/str_util.c +++ b/src/libutil/str_util.c @@ -578,7 +578,7 @@ rspamd_xstrtoul(const char *s, gsize len, gulong *value) v += c; } } - else if (c >= 'a' || c <= 'f') { + else if (c >= 'a' && c <= 'f') { c = c - 'a' + 10; if (v > cutoff || (v == cutoff && (uint8_t) c > cutlim)) { /* Range error */ @@ -1450,7 +1450,7 @@ rspamd_encode_qp_fold(const unsigned char *in, gsize inlen, int str_len, char *out; int ch, last_sp; const unsigned char *end = in + inlen, *p = in; - static const char hexdigests[16] = "0123456789ABCDEF"; + static const char hexdigests[] = "0123456789ABCDEF"; while (p < end) { ch = *p; @@ -2503,7 +2503,7 @@ int rspamd_encode_hex_buf(const unsigned char *in, gsize inlen, char *out, { char *o, *end; const unsigned char *p; - static const char hexdigests[16] = "0123456789abcdef"; + static const char hexdigests[] = "0123456789abcdef"; end = out + outlen; o = out; @@ -3194,7 +3194,7 @@ rspamd_encode_qp2047_buf(const char *in, gsize inlen, char *out, gsize outlen) { char *o = out, *end = out + outlen, c; - static const char hexdigests[16] = "0123456789ABCDEF"; + static const char hexdigests[] = "0123456789ABCDEF"; while (inlen > 0 && o < end) { c = *in; @@ -3454,7 +3454,7 @@ rspamd_str_regexp_escape(const char *pattern, gsize slen, const char *p, *end = pattern + slen; char *res, *d, t, *tmp_utf = NULL, *dend; gsize len; - static const char hexdigests[16] = "0123456789abcdef"; + static const char hexdigests[] = "0123456789abcdef"; len = 0; p = pattern; diff --git a/src/libutil/util.c b/src/libutil/util.c index 7714195c4b..2f432c253e 100644 --- a/src/libutil/util.c +++ b/src/libutil/util.c @@ -1588,7 +1588,7 @@ rspamd_get_calendar_ticks(void) void rspamd_random_hex(char *buf, uint64_t len) { - static const char hexdigests[16] = "0123456789abcdef"; + static const char hexdigests[] = "0123456789abcdef"; int64_t i; g_assert(len > 0); diff --git a/src/lua/lua_logger.c b/src/lua/lua_logger.c index 30cd53a2bc..2145d40863 100644 --- a/src/lua/lua_logger.c +++ b/src/lua/lua_logger.c @@ -619,7 +619,7 @@ lua_logger_out_str(lua_State *L, int pos, char *outbuf, gsize len, enum lua_logger_escape_type esc_type) { - static const char hexdigests[16] = "0123456789abcdef"; + static const char hexdigests[] = "0123456789abcdef"; gsize slen; const unsigned char *str = lua_tolstring(L, pos, &slen); unsigned char c; diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c index bea8d2ef9b..62df4a4c37 100644 --- a/src/lua/lua_tcp.c +++ b/src/lua/lua_tcp.c @@ -2027,7 +2027,7 @@ lua_tcp_connect_sync(lua_State *L) cbd = g_new0(struct lua_tcp_cbdata, 1); if (task) { - static const char hexdigests[16] = "0123456789abcdef"; + static const char hexdigests[] = "0123456789abcdef"; cfg = task->cfg; ev_base = task->event_loop;