From: Vsevolod Stakhov Date: Thu, 5 Feb 2026 14:05:32 +0000 (+0000) Subject: [Fix] Fix printf format specifiers found by clang-plugin X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c1b27cd1c9b2d70e83bf4fe8753c4b6af9f5c91e;p=thirdparty%2Frspamd.git [Fix] Fix printf format specifiers found by clang-plugin --- diff --git a/src/client/rspamc.cxx b/src/client/rspamc.cxx index 369c6b31ef..e5abf17383 100644 --- a/src/client/rspamc.cxx +++ b/src/client/rspamc.cxx @@ -1582,7 +1582,7 @@ rspamc_counters_output(FILE *out, ucl_object_t *obj) if (sym->len > max_len) { rspamd_snprintf(sym_buf, sizeof(sym_buf), "%*s...", - (max_len - 3), ucl_object_tostring(sym)); + (int) (max_len - 3), ucl_object_tostring(sym)); sym_name = sym_buf; } else { diff --git a/src/libmime/lang_detection_fasttext.cxx b/src/libmime/lang_detection_fasttext.cxx index 983ff78de4..75b17d8b32 100644 --- a/src/libmime/lang_detection_fasttext.cxx +++ b/src/libmime/lang_detection_fasttext.cxx @@ -206,7 +206,7 @@ rspamd_fasttext_predict_result_t rspamd_lang_detection_fasttext_detect(void *ud, } } - msg_debug_lang_det("fasttext: got %z word tokens from %ud words", words_vec.size(), words_count); + msg_debug_lang_det("fasttext: got %z word tokens from %z words", words_vec.size(), words_count); auto *res = real_model->detect_language(words_vec, k); diff --git a/src/libserver/cfg_utils.cxx b/src/libserver/cfg_utils.cxx index fcfab6ae9c..a70473adc4 100644 --- a/src/libserver/cfg_utils.cxx +++ b/src/libserver/cfg_utils.cxx @@ -597,7 +597,7 @@ rspamd_config_process_var(struct rspamd_config *cfg, const rspamd_ftok_t *var, else { /* Load lua code and ensure that we have function ref returned */ if (!content || content->len == 0) { - msg_err_config("lua variable needs content: %T", &tok); + msg_err_config("lua variable needs content: %*s", (int) tok.size(), tok.data()); return FALSE; } diff --git a/src/libserver/composites/composites.cxx b/src/libserver/composites/composites.cxx index 1670a9162a..226df4e987 100644 --- a/src/libserver/composites/composites.cxx +++ b/src/libserver/composites/composites.cxx @@ -440,7 +440,7 @@ rspamd_composite_expr_parse(const char *line, gsize len, if (re == nullptr) { msg_err_pool("cannot create regexp from string %*s: %e", - opt_len, opt_start, re_err); + (int) opt_len, opt_start, re_err); g_error_free(re_err); } diff --git a/src/libserver/hs_cache_backend.c b/src/libserver/hs_cache_backend.c index cbbb1f4457..885438fd93 100644 --- a/src/libserver/hs_cache_backend.c +++ b/src/libserver/hs_cache_backend.c @@ -556,7 +556,7 @@ gboolean rspamd_hs_cache_lua_load_sync(const char *cache_key, memcpy(*data, t->start, t->len); } if (len) *len = t->len; - msg_debug_hyperscan("load_sync: loaded %uz bytes for %s", t->len, cache_key); + msg_debug_hyperscan("load_sync: loaded %ud bytes for %s", t->len, cache_key); } else { if (error) *error = g_strdup("Empty or invalid data returned"); diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx index eada311197..3604df09e0 100644 --- a/src/libserver/html/html.cxx +++ b/src/libserver/html/html.cxx @@ -2177,7 +2177,7 @@ auto html_process_input(struct rspamd_task *task, } if (task->cfg && in->len > task->cfg->max_html_len) { - msg_notice_task("html input is too big: %z, limit is %z", + msg_notice_task("html input is too big: %ud, limit is %z", in->len, task->cfg->max_html_len); process_size = task->cfg->max_html_len; diff --git a/src/libserver/redis_pool.cxx b/src/libserver/redis_pool.cxx index cdb301b82b..9ca5212aed 100644 --- a/src/libserver/redis_pool.cxx +++ b/src/libserver/redis_pool.cxx @@ -423,7 +423,7 @@ auto redis_pool_connection::redis_conn_timeout_cb(EV_P_ ev_timer *w, int revents else { /* Finalising by timeout */ ev_timer_stop(EV_A_ w); - msg_debug_rpool("final removal of connection %p, refcount: %d", + msg_debug_rpool("final removal of connection %p", conn->ctx); /* Erasure of shared pointer will cause it to be removed */ diff --git a/src/libserver/rspamd_control.c b/src/libserver/rspamd_control.c index 16993bb49b..a5c603c4b0 100644 --- a/src/libserver/rspamd_control.c +++ b/src/libserver/rspamd_control.c @@ -520,8 +520,7 @@ rspamd_control_reply_handler(EV_P_ ev_io *w, int revents) /* Look up request by ID */ k = kh_get(rspamd_control_requests, h, rep.id); if (k == kh_end(h)) { - msg_warn_main("received control reply for unknown request id %" G_GUINT64_FORMAT - " from worker %P", + msg_warn_main("received control reply for unknown request id %uL from worker %P", rep.id, wrk->pid); if (rfd != -1) { close(rfd); @@ -532,7 +531,7 @@ rspamd_control_reply_handler(EV_P_ ev_io *w, int revents) elt = kh_val(h, k); kh_del(rspamd_control_requests, h, k); - msg_debug_control("received reply for command %d id %" G_GUINT64_FORMAT " from worker %P(%s)", + msg_debug_control("received reply for command %d id %uL from worker %P(%s)", (int) rep.type, rep.id, wrk->pid, g_quark_to_string(wrk->type)); if (rfd != -1) { @@ -620,8 +619,7 @@ rspamd_control_broadcast_cmd(struct rspamd_main *rspamd_main, } if (ret == 0) { /* Key already exists - ID collision (extremely unlikely with 64-bit random) */ - msg_warn_main("control command ID collision for %" G_GUINT64_FORMAT - ", previous request will be orphaned", + msg_warn_main("control command ID collision for %uL, previous request will be orphaned", cmd->id); /* Free the old entry to prevent memory leak */ struct rspamd_control_reply_elt *old_elt = kh_val(h, kh); @@ -640,7 +638,7 @@ rspamd_control_broadcast_cmd(struct rspamd_main *rspamd_main, } DL_APPEND(res, rep_elt); - msg_debug_control("sent command %d id %" G_GUINT64_FORMAT " to worker %P(%s), fd: %d", + msg_debug_control("sent command %d id %uL to worker %P(%s), fd: %d", (int) cmd->type, cmd->id, wrk->pid, g_quark_to_string(wrk->type), @@ -1548,7 +1546,7 @@ rspamd_srv_pipe_handler(EV_P_ ev_io *w, int revents) /* Look up request by ID */ k = kh_get(rspamd_srv_requests, ctx->requests, rep.id); if (k == kh_end(ctx->requests)) { - msg_warn("received reply for unknown request id %" G_GUINT64_FORMAT, + msg_warn("received reply for unknown request id %uL", rep.id); continue; } diff --git a/src/libserver/symcache/symcache_c.cxx b/src/libserver/symcache/symcache_c.cxx index 50af263403..5defe9daac 100644 --- a/src/libserver/symcache/symcache_c.cxx +++ b/src/libserver/symcache/symcache_c.cxx @@ -628,7 +628,7 @@ unsigned int rspamd_symcache_item_async_dec_full(struct rspamd_task *task, real_dyn_item->async_events, subsystem, loc); if (G_UNLIKELY(real_dyn_item->async_events == 0)) { - msg_err_cache_task("INTERNAL ERROR: trying decrease async events counter for %s(%d) that is already zero; " + msg_err_cache_task("INTERNAL ERROR: trying decrease async events counter for %s(%d) that is already zero (events: %ud); " "subsystem %s (%s)", static_item->symbol.c_str(), static_item->id, real_dyn_item->async_events, subsystem, loc); diff --git a/src/libserver/symcache/symcache_impl.cxx b/src/libserver/symcache/symcache_impl.cxx index e2be5c40eb..cbabb3b89b 100644 --- a/src/libserver/symcache/symcache_impl.cxx +++ b/src/libserver/symcache/symcache_impl.cxx @@ -260,8 +260,8 @@ auto symcache::load_items() -> bool if (cached_map->get_size() < (int) sizeof(symcache_header)) { - msg_info_cache("cannot use file %s, truncated: %z", cfg->cache_filename, - errno, strerror(errno)); + msg_info_cache("cannot use file %s, error: %s", cfg->cache_filename, + strerror(errno)); return false; } @@ -401,8 +401,8 @@ bool symcache::save_items() const memcpy(hdr.magic, symcache_magic, sizeof(symcache_magic)); if (write(file_sink->get_fd(), &hdr, sizeof(hdr)) == -1) { - msg_err_cache("cannot write to file %s, error %d, %s", cfg->cache_filename, - errno, strerror(errno)); + msg_err_cache("cannot write to file %s, error %d, %s", cfg->cache_filename, errno, + strerror(errno)); return false; } @@ -667,7 +667,7 @@ auto symcache::resort() -> void */ total_hits = 0; auto used_items = ord->d.size(); - msg_debug_cache("topologically sort %d filters", used_items); + msg_debug_cache("topologically sort %z filters", used_items); for (const auto &it: ord->d) { if (it->order == 0) { diff --git a/src/libserver/symcache/symcache_item.cxx b/src/libserver/symcache/symcache_item.cxx index 15d2bde531..77750bbb98 100644 --- a/src/libserver/symcache/symcache_item.cxx +++ b/src/libserver/symcache/symcache_item.cxx @@ -488,8 +488,8 @@ auto cache_item::add_augmentation(const symcache &cache, std::string_view augmen } } else { - msg_debug_cache("added unknown augmentation %s for symbol %s", - "unknown", augmentation.data(), symbol.data()); + msg_debug_cache("added augmentation %s for symbol %s", + augmentation.data(), symbol.data()); return augmentations.try_emplace(augmentation, 0).second; } diff --git a/src/libstat/classifiers/bayes.c b/src/libstat/classifiers/bayes.c index 2e983f2e68..afa12e7c62 100644 --- a/src/libstat/classifiers/bayes.c +++ b/src/libstat/classifiers/bayes.c @@ -757,7 +757,7 @@ bayes_classify(struct rspamd_classifier *ctx, g_assert(tokens != NULL); /* Check if this is a multi-class classifier */ - msg_debug_bayes("classification check: class_names=%p, len=%uz", + msg_debug_bayes("classification check: class_names=%p, len=%ud", ctx->cfg->class_names, ctx->cfg->class_names ? ctx->cfg->class_names->len : 0); diff --git a/src/libstat/learn_cache/redis_cache.cxx b/src/libstat/learn_cache/redis_cache.cxx index 484a21cce3..81f31b834b 100644 --- a/src/libstat/learn_cache/redis_cache.cxx +++ b/src/libstat/learn_cache/redis_cache.cxx @@ -218,7 +218,7 @@ rspamd_stat_cache_checked(lua_State *L) } else { /* Different class learned, unlearn flag */ - msg_debug_task("<%s> cached value %ld != expected %lu for class %s, will unlearn", + msg_debug_task("<%s> cached value %L != expected %uL for class %s, will unlearn", MESSAGE_FIELD(task, message_id), val, expected_id, autolearn_class); task->flags |= RSPAMD_TASK_FLAG_UNLEARN; diff --git a/src/lua/lua_cryptobox.c b/src/lua/lua_cryptobox.c index 6fa661ea09..da40523581 100644 --- a/src/lua/lua_cryptobox.c +++ b/src/lua/lua_cryptobox.c @@ -678,8 +678,8 @@ lua_cryptobox_signature_load(lua_State *L) *psig = sig; } else { - msg_err("size of %s mismatches: %d while %d is expected", - filename, (int) st.st_size, + msg_err("size of %s mismatches: %z while %z is expected", + filename, (size_t) st.st_size, crypto_sign_bytes()); lua_pushnil(L); } diff --git a/src/lua/lua_thread_pool.cxx b/src/lua/lua_thread_pool.cxx index e1eabe60b4..161d4a85f4 100644 --- a/src/lua/lua_thread_pool.cxx +++ b/src/lua/lua_thread_pool.cxx @@ -93,14 +93,14 @@ struct lua_thread_pool { thread_entry->task = NULL; thread_entry->cfg = NULL; - msg_debug_lua_threads("%s: returned thread to the threads pool %ud items", + msg_debug_lua_threads("%s: returned thread to the threads pool %z items", loc, available_items.size()); available_items.push_back(thread_entry); } else { - msg_debug_lua_threads("%s: removed thread as thread pool has %ud items", + msg_debug_lua_threads("%s: removed thread as thread pool has %z items", loc, available_items.size()); thread_entry_free(L, thread_entry); diff --git a/src/rspamadm/signtool.c b/src/rspamadm/signtool.c index 538767b19b..adce83fc9b 100644 --- a/src/rspamadm/signtool.c +++ b/src/rspamadm/signtool.c @@ -539,9 +539,9 @@ rspamadm_signtool(int argc, char **argv, const struct rspamadm_command *cmd) pk = rspamd_pubkey_from_base32(map, flen, RSPAMD_KEYPAIR_SIGN); if (pk == NULL) { - rspamd_fprintf(stderr, "bad size %s: %ud, %ud expected\n", + rspamd_fprintf(stderr, "bad size %s: %z, %z expected\n", pubkey_file, - (unsigned int) flen, + flen, crypto_sign_publickeybytes()); exit(EXIT_FAILURE); } @@ -553,9 +553,9 @@ rspamadm_signtool(int argc, char **argv, const struct rspamadm_command *cmd) RSPAMD_KEYPAIR_SIGN); if (pk == NULL) { - rspamd_fprintf(stderr, "bad size %s: %ud, %ud expected\n", + rspamd_fprintf(stderr, "bad size %s: %z, %z expected\n", pubkey_file, - (unsigned int) strlen(pubkey), + strlen(pubkey), crypto_sign_publickeybytes()); exit(EXIT_FAILURE); }