diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-03-18 14:56:16 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-03-18 14:56:16 +0000 |
commit | 6b2b4167187fee09365271cca182866ecb029af3 (patch) | |
tree | a085717bc896b25ff4280eb86abecca0d5c36767 /src/libstat | |
parent | 47bcfc8360dfa1754474580e779314b8d6a78da6 (diff) | |
download | rspamd-6b2b4167187fee09365271cca182866ecb029af3.tar.gz rspamd-6b2b4167187fee09365271cca182866ecb029af3.zip |
[Rework] Remove some of the GLib types in lieu of standard ones
This types have constant conflicts with the system ones especially on OSX.
Diffstat (limited to 'src/libstat')
-rw-r--r-- | src/libstat/backends/mmaped_file.c | 72 | ||||
-rw-r--r-- | src/libstat/backends/sqlite3_backend.c | 32 | ||||
-rw-r--r-- | src/libstat/classifiers/bayes.c | 6 | ||||
-rw-r--r-- | src/libstat/classifiers/lua_classifier.c | 12 | ||||
-rw-r--r-- | src/libstat/learn_cache/sqlite3_cache.c | 16 | ||||
-rw-r--r-- | src/libstat/stat_api.h | 4 | ||||
-rw-r--r-- | src/libstat/stat_internal.h | 4 | ||||
-rw-r--r-- | src/libstat/stat_process.c | 4 | ||||
-rw-r--r-- | src/libstat/tokenizers/osb.c | 16 | ||||
-rw-r--r-- | src/libstat/tokenizers/tokenizers.c | 32 | ||||
-rw-r--r-- | src/libstat/tokenizers/tokenizers.h | 2 |
11 files changed, 100 insertions, 100 deletions
diff --git a/src/libstat/backends/mmaped_file.c b/src/libstat/backends/mmaped_file.c index 5c2020787..f4354d8e1 100644 --- a/src/libstat/backends/mmaped_file.c +++ b/src/libstat/backends/mmaped_file.c @@ -26,33 +26,33 @@ * Common statfile header */ struct stat_file_header { - u_char magic[3]; /**< magic signature ('r' 's' 'd') */ - u_char version[2]; /**< version of statfile */ - u_char padding[3]; /**< padding */ - guint64 create_time; /**< create time (time_t->guint64) */ - guint64 revision; /**< revision number */ - guint64 rev_time; /**< revision time */ - guint64 used_blocks; /**< used blocks number */ - guint64 total_blocks; /**< total number of blocks */ - guint64 tokenizer_conf_len; /**< length of tokenizer configuration */ - u_char unused[231]; /**< some bytes that can be used in future */ + u_char magic[3]; /**< magic signature ('r' 's' 'd') */ + u_char version[2]; /**< version of statfile */ + u_char padding[3]; /**< padding */ + uint64_t create_time; /**< create time (time_t->uint64_t) */ + uint64_t revision; /**< revision number */ + uint64_t rev_time; /**< revision time */ + uint64_t used_blocks; /**< used blocks number */ + uint64_t total_blocks; /**< total number of blocks */ + uint64_t tokenizer_conf_len; /**< length of tokenizer configuration */ + u_char unused[231]; /**< some bytes that can be used in future */ }; /** * Section header */ struct stat_file_section { - guint64 code; /**< section's code */ - guint64 length; /**< section's length in blocks */ + uint64_t code; /**< section's code */ + uint64_t length; /**< section's length in blocks */ }; /** * Block of data in statfile */ struct stat_file_block { - guint32 hash1; /**< hash1 (also acts as index) */ - guint32 hash2; /**< hash2 */ - double value; /**< double value */ + uint32_t hash1; /**< hash1 (also acts as index) */ + uint32_t hash2; /**< hash2 */ + double value; /**< double value */ }; /** @@ -91,7 +91,7 @@ typedef struct { static void rspamd_mmaped_file_set_block_common(rspamd_mempool_t *pool, rspamd_mmaped_file_t *file, - guint32 h1, guint32 h2, double value); + uint32_t h1, uint32_t h2, double value); rspamd_mmaped_file_t *rspamd_mmaped_file_open(rspamd_mempool_t *pool, const gchar *filename, size_t size, @@ -104,8 +104,8 @@ gint rspamd_mmaped_file_close_file(rspamd_mempool_t *pool, double rspamd_mmaped_file_get_block(rspamd_mmaped_file_t *file, - guint32 h1, - guint32 h2) + uint32_t h1, + uint32_t h2) { struct stat_file_block *block; guint i, blocknum; @@ -137,7 +137,7 @@ rspamd_mmaped_file_get_block(rspamd_mmaped_file_t *file, static void rspamd_mmaped_file_set_block_common(rspamd_mempool_t *pool, rspamd_mmaped_file_t *file, - guint32 h1, guint32 h2, double value) + uint32_t h1, uint32_t h2, double value) { struct stat_file_block *block, *to_expire = NULL; struct stat_file_header *header; @@ -215,15 +215,15 @@ rspamd_mmaped_file_set_block_common(rspamd_mempool_t *pool, void rspamd_mmaped_file_set_block(rspamd_mempool_t *pool, rspamd_mmaped_file_t *file, - guint32 h1, - guint32 h2, + uint32_t h1, + uint32_t h2, double value) { rspamd_mmaped_file_set_block_common(pool, file, h1, h2, value); } gboolean -rspamd_mmaped_file_set_revision(rspamd_mmaped_file_t *file, guint64 rev, time_t time) +rspamd_mmaped_file_set_revision(rspamd_mmaped_file_t *file, uint64_t rev, time_t time) { struct stat_file_header *header; @@ -273,7 +273,7 @@ rspamd_mmaped_file_dec_revision(rspamd_mmaped_file_t *file) gboolean -rspamd_mmaped_file_get_revision(rspamd_mmaped_file_t *file, guint64 *rev, time_t *time) +rspamd_mmaped_file_get_revision(rspamd_mmaped_file_t *file, uint64_t *rev, time_t *time) { struct stat_file_header *header; @@ -293,13 +293,13 @@ rspamd_mmaped_file_get_revision(rspamd_mmaped_file_t *file, guint64 *rev, time_t return TRUE; } -guint64 +uint64_t rspamd_mmaped_file_get_used(rspamd_mmaped_file_t *file) { struct stat_file_header *header; if (file == NULL || file->map == NULL) { - return (guint64) -1; + return (uint64_t) -1; } header = (struct stat_file_header *) file->map; @@ -307,13 +307,13 @@ rspamd_mmaped_file_get_used(rspamd_mmaped_file_t *file) return header->used_blocks; } -guint64 +uint64_t rspamd_mmaped_file_get_total(rspamd_mmaped_file_t *file) { struct stat_file_header *header; if (file == NULL || file->map == NULL) { - return (guint64) -1; + return (uint64_t) -1; } header = (struct stat_file_header *) file->map; @@ -752,14 +752,14 @@ create: 0, sizeof(header) + sizeof(section) + sizeof(block) * nblocks); - header.create_time = (guint64) time(NULL); + header.create_time = (uint64_t) time(NULL); g_assert(stcf->clcf != NULL); g_assert(stcf->clcf->tokenizer != NULL); tokenizer = rspamd_stat_get_tokenizer(stcf->clcf->tokenizer->name); g_assert(tokenizer != NULL); tok_conf = tokenizer->get_config(pool, stcf->clcf->tokenizer, &tok_conf_len); header.tokenizer_conf_len = tok_conf_len; - g_assert(tok_conf_len < sizeof(header.unused) - sizeof(guint64)); + g_assert(tok_conf_len < sizeof(header.unused) - sizeof(uint64_t)); memcpy(header.unused, tok_conf, tok_conf_len); if (write(fd, &header, sizeof(header)) == -1) { @@ -775,7 +775,7 @@ create: return -1; } - section.length = (guint64) nblocks; + section.length = (uint64_t) nblocks; if (write(fd, §ion, sizeof(section)) == -1) { msg_info_pool("cannot write section header to file %s, error %d, %s", filename, @@ -944,7 +944,7 @@ rspamd_mmaped_file_process_tokens(struct rspamd_task *task, GPtrArray *tokens, gpointer p) { rspamd_mmaped_file_t *mf = p; - guint32 h1, h2; + uint32_t h1, h2; rspamd_token_t *tok; guint i; @@ -974,7 +974,7 @@ rspamd_mmaped_file_learn_tokens(struct rspamd_task *task, GPtrArray *tokens, gpointer p) { rspamd_mmaped_file_t *mf = p; - guint32 h1, h2; + uint32_t h1, h2; rspamd_token_t *tok; guint i; @@ -997,7 +997,7 @@ rspamd_mmaped_file_total_learns(struct rspamd_task *task, gpointer runtime, gpointer ctx) { rspamd_mmaped_file_t *mf = (rspamd_mmaped_file_t *) runtime; - guint64 rev = 0; + uint64_t rev = 0; time_t t; if (mf != NULL) { @@ -1012,7 +1012,7 @@ rspamd_mmaped_file_inc_learns(struct rspamd_task *task, gpointer runtime, gpointer ctx) { rspamd_mmaped_file_t *mf = (rspamd_mmaped_file_t *) runtime; - guint64 rev = 0; + uint64_t rev = 0; time_t t; if (mf != NULL) { @@ -1028,7 +1028,7 @@ rspamd_mmaped_file_dec_learns(struct rspamd_task *task, gpointer runtime, gpointer ctx) { rspamd_mmaped_file_t *mf = (rspamd_mmaped_file_t *) runtime; - guint64 rev = 0; + uint64_t rev = 0; time_t t; if (mf != NULL) { @@ -1045,7 +1045,7 @@ rspamd_mmaped_file_get_stat(gpointer runtime, gpointer ctx) { ucl_object_t *res = NULL; - guint64 rev; + uint64_t rev; rspamd_mmaped_file_t *mf = (rspamd_mmaped_file_t *) runtime; if (mf != NULL) { diff --git a/src/libstat/backends/sqlite3_backend.c b/src/libstat/backends/sqlite3_backend.c index 68b52128f..b26c1a86f 100644 --- a/src/libstat/backends/sqlite3_backend.c +++ b/src/libstat/backends/sqlite3_backend.c @@ -43,8 +43,8 @@ struct rspamd_stat_sqlite3_rt { struct rspamd_task *task; struct rspamd_stat_sqlite3_db *db; struct rspamd_statfile_config *cf; - gint64 user_id; - gint64 lang_id; + int64_t user_id; + int64_t lang_id; }; static const char *create_tables_sql = @@ -156,11 +156,11 @@ rspamd_sqlite3_backend_quark(void) return g_quark_from_static_string("sqlite3-stat-backend"); } -static gint64 +static int64_t rspamd_sqlite3_get_user(struct rspamd_stat_sqlite3_db *db, struct rspamd_task *task, gboolean learn) { - gint64 id = 0; /* Default user is 0 */ + int64_t id = 0; /* Default user is 0 */ gint rc, err_idx; const gchar *user = NULL; struct rspamd_task **ptask; @@ -215,11 +215,11 @@ rspamd_sqlite3_get_user(struct rspamd_stat_sqlite3_db *db, return id; } -static gint64 +static int64_t rspamd_sqlite3_get_language(struct rspamd_stat_sqlite3_db *db, struct rspamd_task *task, gboolean learn) { - gint64 id = 0; /* Default language is 0 */ + int64_t id = 0; /* Default language is 0 */ gint rc, err_idx; guint i; const gchar *language = NULL; @@ -293,7 +293,7 @@ rspamd_sqlite3_opendb(rspamd_mempool_t *pool, struct rspamd_stat_tokenizer *tokenizer; gpointer tk_conf; gsize sz = 0; - gint64 sz64 = 0; + int64_t sz64 = 0; gchar *tok_conf_encoded; gint ret, ntries = 0; const gint max_tries = 100; @@ -347,7 +347,7 @@ rspamd_sqlite3_opendb(rspamd_mempool_t *pool, if (rspamd_sqlite3_run_prstmt(pool, bk->sqlite, bk->prstmt, RSPAMD_STAT_BACKEND_SAVE_TOKENIZER, - (gint64) strlen(tok_conf_encoded), + (int64_t) strlen(tok_conf_encoded), tok_conf_encoded) != SQLITE_OK) { sqlite3_close(bk->sqlite); g_free(bk); @@ -526,7 +526,7 @@ rspamd_sqlite3_process_tokens(struct rspamd_task *task, { struct rspamd_stat_sqlite3_db *bk; struct rspamd_stat_sqlite3_rt *rt = p; - gint64 iv = 0; + int64_t iv = 0; guint i; rspamd_token_t *tok; @@ -629,7 +629,7 @@ rspamd_sqlite3_learn_tokens(struct rspamd_task *task, GPtrArray *tokens, { struct rspamd_stat_sqlite3_db *bk; struct rspamd_stat_sqlite3_rt *rt = p; - gint64 iv = 0; + int64_t iv = 0; guint i; rspamd_token_t *tok; @@ -735,7 +735,7 @@ rspamd_sqlite3_total_learns(struct rspamd_task *task, gpointer runtime, { struct rspamd_stat_sqlite3_rt *rt = runtime; struct rspamd_stat_sqlite3_db *bk; - guint64 res; + uint64_t res; g_assert(rt != NULL); bk = rt->db; @@ -751,7 +751,7 @@ rspamd_sqlite3_inc_learns(struct rspamd_task *task, gpointer runtime, { struct rspamd_stat_sqlite3_rt *rt = runtime; struct rspamd_stat_sqlite3_db *bk; - guint64 res; + uint64_t res; g_assert(rt != NULL); bk = rt->db; @@ -780,7 +780,7 @@ rspamd_sqlite3_dec_learns(struct rspamd_task *task, gpointer runtime, { struct rspamd_stat_sqlite3_rt *rt = runtime; struct rspamd_stat_sqlite3_db *bk; - guint64 res; + uint64_t res; g_assert(rt != NULL); bk = rt->db; @@ -809,7 +809,7 @@ rspamd_sqlite3_learns(struct rspamd_task *task, gpointer runtime, { struct rspamd_stat_sqlite3_rt *rt = runtime; struct rspamd_stat_sqlite3_db *bk; - guint64 res; + uint64_t res; g_assert(rt != NULL); bk = rt->db; @@ -828,7 +828,7 @@ rspamd_sqlite3_get_stat(gpointer runtime, struct rspamd_stat_sqlite3_db *bk; rspamd_mempool_t *pool; struct stat st; - gint64 rev; + int64_t rev; g_assert(rt != NULL); bk = rt->db; @@ -873,7 +873,7 @@ rspamd_sqlite3_load_tokenizer_config(gpointer runtime, gsize *len) { gpointer tk_conf, copied_conf; - guint64 sz; + uint64_t sz; struct rspamd_stat_sqlite3_rt *rt = runtime; struct rspamd_stat_sqlite3_db *bk; diff --git a/src/libstat/classifiers/bayes.c b/src/libstat/classifiers/bayes.c index 513db9af9..abefcd7d9 100644 --- a/src/libstat/classifiers/bayes.c +++ b/src/libstat/classifiers/bayes.c @@ -97,9 +97,9 @@ struct bayes_task_closure { double ham_prob; double spam_prob; gdouble meta_skip_prob; - guint64 processed_tokens; - guint64 total_hits; - guint64 text_tokens; + uint64_t processed_tokens; + uint64_t total_hits; + uint64_t text_tokens; struct rspamd_task *task; }; diff --git a/src/libstat/classifiers/lua_classifier.c b/src/libstat/classifiers/lua_classifier.c index 30b2a0abd..88ab015d6 100644 --- a/src/libstat/classifiers/lua_classifier.c +++ b/src/libstat/classifiers/lua_classifier.c @@ -136,7 +136,7 @@ lua_classifier_classify(struct rspamd_classifier *cl, lua_State *L; rspamd_token_t *tok; guint i; - guint64 v; + uint64_t v; ctx = g_hash_table_lookup(lua_classifiers, cl->subrs->name); g_assert(ctx != NULL); @@ -157,9 +157,9 @@ lua_classifier_classify(struct rspamd_classifier *cl, v = tok->data; lua_createtable(L, 3, 0); /* High word, low word, order */ - lua_pushinteger(L, (guint32) (v >> 32)); + lua_pushinteger(L, (uint32_t) (v >> 32)); lua_rawseti(L, -2, 1); - lua_pushinteger(L, (guint32) (v)); + lua_pushinteger(L, (uint32_t) (v)); lua_rawseti(L, -2, 2); lua_pushinteger(L, tok->window_idx); lua_rawseti(L, -2, 3); @@ -191,7 +191,7 @@ lua_classifier_learn_spam(struct rspamd_classifier *cl, lua_State *L; rspamd_token_t *tok; guint i; - guint64 v; + uint64_t v; ctx = g_hash_table_lookup(lua_classifiers, cl->subrs->name); g_assert(ctx != NULL); @@ -213,9 +213,9 @@ lua_classifier_learn_spam(struct rspamd_classifier *cl, v = tok->data; lua_createtable(L, 3, 0); /* High word, low word, order */ - lua_pushinteger(L, (guint32) (v >> 32)); + lua_pushinteger(L, (uint32_t) (v >> 32)); lua_rawseti(L, -2, 1); - lua_pushinteger(L, (guint32) (v)); + lua_pushinteger(L, (uint32_t) (v)); lua_rawseti(L, -2, 2); lua_pushinteger(L, tok->window_idx); lua_rawseti(L, -2, 3); diff --git a/src/libstat/learn_cache/sqlite3_cache.c b/src/libstat/learn_cache/sqlite3_cache.c index d8ad20ad2..36e9382cd 100644 --- a/src/libstat/learn_cache/sqlite3_cache.c +++ b/src/libstat/learn_cache/sqlite3_cache.c @@ -1,11 +1,11 @@ -/*- - * Copyright 2016 Vsevolod Stakhov +/* + * Copyright 2024 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -165,7 +165,7 @@ gint rspamd_stat_cache_sqlite3_check(struct rspamd_task *task, gchar *user = NULL; guint i; gint rc; - gint64 flag; + int64_t flag; if (task->tokens == NULL || task->tokens->len == 0) { return RSPAMD_LEARN_IGNORE; @@ -193,7 +193,7 @@ gint rspamd_stat_cache_sqlite3_check(struct rspamd_task *task, rspamd_sqlite3_run_prstmt(task->task_pool, ctx->db, ctx->prstmt, RSPAMD_STAT_CACHE_TRANSACTION_START_DEF); rc = rspamd_sqlite3_run_prstmt(task->task_pool, ctx->db, ctx->prstmt, - RSPAMD_STAT_CACHE_GET_LEARN, (gint64) rspamd_cryptobox_HASHBYTES, + RSPAMD_STAT_CACHE_GET_LEARN, (int64_t) rspamd_cryptobox_HASHBYTES, out, &flag); rspamd_sqlite3_run_prstmt(task->task_pool, ctx->db, ctx->prstmt, RSPAMD_STAT_CACHE_TRANSACTION_COMMIT); @@ -226,7 +226,7 @@ gint rspamd_stat_cache_sqlite3_learn(struct rspamd_task *task, struct rspamd_stat_sqlite3_ctx *ctx = runtime; gboolean unlearn = !!(task->flags & RSPAMD_TASK_FLAG_UNLEARN); guchar *h; - gint64 flag; + int64_t flag; h = rspamd_mempool_get_variable(task->task_pool, "words_hash"); @@ -242,7 +242,7 @@ gint rspamd_stat_cache_sqlite3_learn(struct rspamd_task *task, RSPAMD_STAT_CACHE_TRANSACTION_START_IM); rspamd_sqlite3_run_prstmt(task->task_pool, ctx->db, ctx->prstmt, RSPAMD_STAT_CACHE_ADD_LEARN, - (gint64) rspamd_cryptobox_HASHBYTES, h, flag); + (int64_t) rspamd_cryptobox_HASHBYTES, h, flag); rspamd_sqlite3_run_prstmt(task->task_pool, ctx->db, ctx->prstmt, RSPAMD_STAT_CACHE_TRANSACTION_COMMIT); } @@ -252,7 +252,7 @@ gint rspamd_stat_cache_sqlite3_learn(struct rspamd_task *task, rspamd_sqlite3_run_prstmt(task->task_pool, ctx->db, ctx->prstmt, RSPAMD_STAT_CACHE_UPDATE_LEARN, flag, - (gint64) rspamd_cryptobox_HASHBYTES, h); + (int64_t) rspamd_cryptobox_HASHBYTES, h); rspamd_sqlite3_run_prstmt(task->task_pool, ctx->db, ctx->prstmt, RSPAMD_STAT_CACHE_TRANSACTION_COMMIT); } diff --git a/src/libstat/stat_api.h b/src/libstat/stat_api.h index 798d0b481..af3cdc8b9 100644 --- a/src/libstat/stat_api.h +++ b/src/libstat/stat_api.h @@ -55,7 +55,7 @@ typedef struct rspamd_stat_token_s { #define RSPAMD_TOKEN_VALUE_TYPE float typedef struct token_node_s { - guint64 data; + uint64_t data; guint window_idx; guint flags; rspamd_stat_token_t *t1; @@ -136,7 +136,7 @@ rspamd_stat_result_t rspamd_stat_learn(struct rspamd_task *task, */ rspamd_stat_result_t rspamd_stat_statistics(struct rspamd_task *task, struct rspamd_config *cfg, - guint64 *total_learns, + uint64_t *total_learns, ucl_object_t **res); void rspamd_stat_unload(void); diff --git a/src/libstat/stat_internal.h b/src/libstat/stat_internal.h index 8d0ebd4fa..604a2af91 100644 --- a/src/libstat/stat_internal.h +++ b/src/libstat/stat_internal.h @@ -31,8 +31,8 @@ extern "C" { struct rspamd_statfile_runtime { struct rspamd_statfile_config *st; gpointer backend_runtime; - guint64 hits; - guint64 total_hits; + uint64_t hits; + uint64_t total_hits; }; /* Common classifier structure */ diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index c1d194694..c15c32bf0 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -1189,7 +1189,7 @@ rspamd_stat_check_autolearn(struct rspamd_task *task) rspamd_stat_result_t rspamd_stat_statistics(struct rspamd_task *task, struct rspamd_config *cfg, - guint64 *total_learns, + uint64_t *total_learns, ucl_object_t **target) { struct rspamd_stat_ctx *st_ctx; @@ -1197,7 +1197,7 @@ rspamd_stat_statistics(struct rspamd_task *task, struct rspamd_statfile *st; gpointer backend_runtime; ucl_object_t *res = NULL, *elt; - guint64 learns = 0; + uint64_t learns = 0; guint i, j; gint id; diff --git a/src/libstat/tokenizers/osb.c b/src/libstat/tokenizers/osb.c index e96748a93..3f770c69e 100644 --- a/src/libstat/tokenizers/osb.c +++ b/src/libstat/tokenizers/osb.c @@ -62,7 +62,7 @@ struct rspamd_osb_tokenizer_config { gshort version; gshort window_size; enum rspamd_osb_hash_type ht; - guint64 seed; + uint64_t seed; rspamd_sipkey_t sk; }; @@ -262,7 +262,7 @@ rspamd_tokenizer_osb_is_compat (struct rspamd_tokenizer_runtime *rt) #endif struct token_pipe_entry { - guint64 h; + uint64_t h; rspamd_stat_token_t *t; }; @@ -276,9 +276,9 @@ gint rspamd_tokenizer_osb(struct rspamd_stat_ctx *ctx, rspamd_token_t *new_tok = NULL; rspamd_stat_token_t *token; struct rspamd_osb_tokenizer_config *osb_cf; - guint64 cur, seed; + uint64_t cur, seed; struct token_pipe_entry *hashpipe; - guint32 h1, h2; + uint32_t h1, h2; gsize token_size; guint processed = 0, i, w, window_size, token_flags = 0; @@ -369,10 +369,10 @@ gint rspamd_tokenizer_osb(struct rspamd_stat_ctx *ctx, new_tok->t1 = hashpipe[0].t; \ new_tok->t2 = hashpipe[i].t; \ if (osb_cf->ht == RSPAMD_OSB_HASH_COMPAT) { \ - h1 = ((guint32) hashpipe[0].h) * primes[0] + \ - ((guint32) hashpipe[i].h) * primes[i << 1]; \ - h2 = ((guint32) hashpipe[0].h) * primes[1] + \ - ((guint32) hashpipe[i].h) * primes[(i << 1) - 1]; \ + h1 = ((uint32_t) hashpipe[0].h) * primes[0] + \ + ((uint32_t) hashpipe[i].h) * primes[i << 1]; \ + h2 = ((uint32_t) hashpipe[0].h) * primes[1] + \ + ((uint32_t) hashpipe[i].h) * primes[(i << 1) - 1]; \ memcpy((guchar *) &new_tok->data, &h1, sizeof(h1)); \ memcpy(((guchar *) &new_tok->data) + sizeof(h1), &h2, sizeof(h2)); \ } \ diff --git a/src/libstat/tokenizers/tokenizers.c b/src/libstat/tokenizers/tokenizers.c index ee7234df7..702668142 100644 --- a/src/libstat/tokenizers/tokenizers.c +++ b/src/libstat/tokenizers/tokenizers.c @@ -1,5 +1,5 @@ /* - * Copyright 2023 Vsevolod Stakhov + * Copyright 2024 Vsevolod Stakhov * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -162,8 +162,8 @@ static inline gboolean rspamd_tokenize_check_limit(gboolean decay, guint word_decay, guint nwords, - guint64 *hv, - guint64 *prob, + uint64_t *hv, + uint64_t *prob, const rspamd_stat_token_t *token, gssize remain, gssize total) @@ -171,8 +171,8 @@ rspamd_tokenize_check_limit(gboolean decay, static const gdouble avg_word_len = 6.0; if (!decay) { - if (token->original.len >= sizeof(guint64)) { - guint64 tmp; + if (token->original.len >= sizeof(uint64_t)) { + uint64_t tmp; memcpy(&tmp, token->original.begin, sizeof(tmp)); *hv = mum_hash_step(*hv, tmp); } @@ -192,7 +192,7 @@ rspamd_tokenize_check_limit(gboolean decay, *prob = G_MAXUINT64; } else { - *prob = (guint64) (decay_prob * (double) G_MAXUINT64); + *prob = (uint64_t) (decay_prob * (double) G_MAXUINT64); } return TRUE; @@ -213,7 +213,7 @@ rspamd_tokenize_check_limit(gboolean decay, static inline gboolean rspamd_utf_word_valid(const guchar *text, const guchar *end, - gint32 start, gint32 finish) + int32_t start, int32_t finish) { const guchar *st = text + start, *fin = text + finish; UChar32 c; @@ -283,7 +283,7 @@ rspamd_tokenize_text(const gchar *text, gsize len, enum rspamd_tokenize_type how, struct rspamd_config *cfg, GList *exceptions, - guint64 *hash, + uint64_t *hash, GArray *cur_words, rspamd_mempool_t *pool) { @@ -293,9 +293,9 @@ rspamd_tokenize_text(const gchar *text, gsize len, GArray *res; GList *cur = exceptions; guint min_len = 0, max_len = 0, word_decay = 0, initial_size = 128; - guint64 hv = 0; + uint64_t hv = 0; gboolean decay = FALSE, long_text_mode = FALSE; - guint64 prob = 0; + uint64_t prob = 0; static UBreakIterator *bi = NULL; static const gsize long_text_limit = 1 * 1024 * 1024; static const ev_tstamp max_exec_time = 0.2; /* 200 ms */ @@ -422,7 +422,7 @@ rspamd_tokenize_text(const gchar *text, gsize len, if (last > p) { /* Exception spread over the boundaries */ while (last > p && p != UBRK_DONE) { - gint32 old_p = p; + int32_t old_p = p; p = ubrk_next(bi); if (p != UBRK_DONE && p <= old_p) { @@ -462,7 +462,7 @@ rspamd_tokenize_text(const gchar *text, gsize len, if (last > p) { /* Exception spread over the boundaries */ while (last > p && p != UBRK_DONE) { - gint32 old_p = p; + int32_t old_p = p; p = ubrk_next(bi); if (p != UBRK_DONE && p <= old_p) { msg_warn_pool_check( @@ -607,14 +607,14 @@ rspamd_add_metawords_from_str(const gchar *beg, gsize len, while (i < len) { U8_NEXT(beg, i, len, uc); - if (((gint32) uc) < 0) { + if (((int32_t) uc) < 0) { valid_utf = FALSE; break; } #if U_ICU_VERSION_MAJOR_NUM < 50 if (u_isalpha(uc)) { - gint32 sc = ublock_getCode(uc); + int32_t sc = ublock_getCode(uc); if (sc == UBLOCK_THAI) { valid_utf = FALSE; @@ -697,7 +697,7 @@ rspamd_uchars_to_ucs32(const UChar *src, gsize srclen, rspamd_mempool_t *pool) { UChar32 *dest, t, *d; - gint32 i = 0; + int32_t i = 0; dest = rspamd_mempool_alloc(pool, srclen * sizeof(UChar32)); d = dest; @@ -787,7 +787,7 @@ void rspamd_normalize_single_word(rspamd_stat_token_t *tok, rspamd_mempool_t *po else { #if U_ICU_VERSION_MAJOR_NUM >= 44 const UNormalizer2 *norm = rspamd_get_unicode_normalizer(); - gint32 end; + int32_t end; /* We can now check if we need to decompose */ end = unorm2_spanQuickCheckYes(norm, tmpbuf, ulen, &uc_err); diff --git a/src/libstat/tokenizers/tokenizers.h b/src/libstat/tokenizers/tokenizers.h index d696364e2..ff5c530c5 100644 --- a/src/libstat/tokenizers/tokenizers.h +++ b/src/libstat/tokenizers/tokenizers.h @@ -65,7 +65,7 @@ GArray *rspamd_tokenize_text(const gchar *text, gsize len, enum rspamd_tokenize_type how, struct rspamd_config *cfg, GList *exceptions, - guint64 *hash, + uint64_t *hash, GArray *cur_words, rspamd_mempool_t *pool); |