]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Fix printf format specifiers found by clang-plugin
authorVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 5 Feb 2026 14:05:32 +0000 (14:05 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 5 Feb 2026 14:05:32 +0000 (14:05 +0000)
16 files changed:
src/client/rspamc.cxx
src/libmime/lang_detection_fasttext.cxx
src/libserver/cfg_utils.cxx
src/libserver/composites/composites.cxx
src/libserver/hs_cache_backend.c
src/libserver/html/html.cxx
src/libserver/redis_pool.cxx
src/libserver/rspamd_control.c
src/libserver/symcache/symcache_c.cxx
src/libserver/symcache/symcache_impl.cxx
src/libserver/symcache/symcache_item.cxx
src/libstat/classifiers/bayes.c
src/libstat/learn_cache/redis_cache.cxx
src/lua/lua_cryptobox.c
src/lua/lua_thread_pool.cxx
src/rspamadm/signtool.c

index 369c6b31effad72ce2bd7574e2c40d0ff3493a4e..e5abf17383a332d98944332305c969e4d800cd61 100644 (file)
@@ -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 {
index 983ff78de4b9ebc4ee3810356fca7ec3b69cc278..75b17d8b32e5e4472cc48ec5ee1b5d5d96490f8a 100644 (file)
@@ -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);
 
index fcfab6ae9cc4b855484416d82854eee631aaed46..a70473adc489613212d1c9277d8cf02a279f826f 100644 (file)
@@ -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;
                        }
 
index 1670a9162a86f8af9f4205b77289d5daef710c61..226df4e9874cd0e66e79f7c83e5e3f51311a2b5c 100644 (file)
@@ -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);
                                }
index cbbb1f4457feec6da3123bb3cafda33ba895753a..885438fd9344328df4b30855af917067e320eb8d 100644 (file)
@@ -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");
index eada311197c0e5a7ac67e1f058de594bd41a3ec9..3604df09e0dcf4a7a84929b3cdf3379953bf6740 100644 (file)
@@ -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;
index cdb301b82b127f44b69abef943d780b241a0bcea..9ca5212aed4c72ee2f271d8d8e785a8aafe96f97 100644 (file)
@@ -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 */
index 16993bb49bfda7f7ba7a3457b5f94e01805352e6..a5c603c4b05443c3814192a6e03eaa0a2d8fb7a1 100644 (file)
@@ -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;
                        }
index 50af26340343c0ab00fb0804d5bb51041a57f582..5defe9daac457cce29a1594997d6af5078cd026c 100644 (file)
@@ -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);
index e2be5c40eba243545e877959b7ed148e009a99f8..cbabb3b89ba7602b8bde75275a7c7e79f822524d 100644 (file)
@@ -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) {
index 15d2bde5319d8a03859f06958d252648d1543586..77750bbb98914099d78a488d95454aff9b2fb91e 100644 (file)
@@ -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;
        }
 
index 2e983f2e68e47f494ade2751b1071674de4dfa91..afa12e7c621c7b37c4ddf5802beaf4ed9b854869 100644 (file)
@@ -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);
 
index 484a21cce3ba2922998705d0ae0fc1b74a47407c..81f31b834b958a1914ec5b6f922bbf84a0e69f19 100644 (file)
@@ -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;
index 6fa661ea09fa5952b166964c2721a63820718474..da405235819d83d1bf02bd872451796119be3de1 100644 (file)
@@ -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);
                                }
index e1eabe60b41f80843741dd9eb2fe52b7a54dce2b..161d4a85f43322338059a2040239375624e7151b 100644 (file)
@@ -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);
index 538767b19b51678122f18fa48ae8b98fc06985f1..adce83fc9b1c070fa25ac6cb5aa107803d925962 100644 (file)
@@ -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);
                        }