commit 00135c8: [Minor] Slight types improvement
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Jun 28 08:42:05 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-06-28 09:40:04 +0100
URL: https://github.com/rspamd/rspamd/commit/00135c8f9a8dda4fe3ccdfe8a05bea691e73930a (HEAD -> master)
[Minor] Slight types improvement
---
src/libserver/html.c | 4 ++--
src/libserver/html.h | 2 +-
src/libserver/html_entities.h | 4 ++--
src/libserver/url.c | 2 +-
src/libserver/url.h | 2 +-
src/libserver/worker_util.c | 8 ++++----
src/libserver/worker_util.h | 2 +-
src/libutil/util.c | 10 ++++++----
src/libutil/util.h | 4 ++--
src/rspamd.h | 14 +++++++-------
10 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/src/libserver/html.c b/src/libserver/html.c
index ca4ad5d38..8f6b3d291 100644
--- a/src/libserver/html.c
+++ b/src/libserver/html.c
@@ -2337,8 +2337,8 @@ rspamd_html_process_block_tag (rspamd_mempool_t *pool, struct html_tag *tag,
case RSPAMD_HTML_COMPONENT_CLASS:
fstr.begin = (gchar *) comp->start;
fstr.len = comp->len;
- bl->class = rspamd_mempool_ftokdup (pool, &fstr);
- msg_debug_html ("got class: %s", bl->class);
+ bl->html_class = rspamd_mempool_ftokdup (pool, &fstr);
+ msg_debug_html ("got class: %s", bl->html_class);
break;
case RSPAMD_HTML_COMPONENT_SIZE:
/* Not supported by html5 */
diff --git a/src/libserver/html.h b/src/libserver/html.h
index f3515d627..ada6dca68 100644
--- a/src/libserver/html.h
+++ b/src/libserver/html.h
@@ -85,7 +85,7 @@ struct html_block {
struct html_tag_component style;
guint font_size;
gboolean visible;
- gchar *class;
+ gchar *html_class;
};
/* Public tags flags */
diff --git a/src/libserver/html_entities.h b/src/libserver/html_entities.h
index 8b323e9b3..1079f2b0e 100644
--- a/src/libserver/html_entities.h
+++ b/src/libserver/html_entities.h
@@ -21,9 +21,9 @@ struct _entity;
typedef struct _entity entity;
struct _entity {
- gchar *name;
+ const gchar *name;
uint code;
- gchar *replacement;
+ const gchar *replacement;
};
static entity entities_defs[] = {
diff --git a/src/libserver/url.c b/src/libserver/url.c
index 36c9a157a..0b31007bb 100644
--- a/src/libserver/url.c
+++ b/src/libserver/url.c
@@ -380,7 +380,7 @@ static const unsigned int url_scanner_table[256] = {
#define is_urlsafe(x) ((url_scanner_table[(guchar)(x)] & (IS_URLSAFE)) != 0)
const gchar *
-rspamd_url_strerror (enum uri_errno err)
+rspamd_url_strerror (int err)
{
switch (err) {
case URI_ERRNO_OK:
diff --git a/src/libserver/url.h b/src/libserver/url.h
index 59dcd1615..734f48bbf 100644
--- a/src/libserver/url.h
+++ b/src/libserver/url.h
@@ -150,7 +150,7 @@ gboolean rspamd_url_find (rspamd_mempool_t *pool,
/*
* Return text representation of url parsing error
*/
-const gchar * rspamd_url_strerror (enum uri_errno err);
+const gchar * rspamd_url_strerror (int err);
/**
diff --git a/src/libserver/worker_util.c b/src/libserver/worker_util.c
index 3ad528d1e..4aff94a38 100644
--- a/src/libserver/worker_util.c
+++ b/src/libserver/worker_util.c
@@ -235,7 +235,7 @@ rspamd_worker_signal_handle (EV_P_ ev_signal *w, int revents)
{
struct rspamd_worker_signal_handler *sigh =
(struct rspamd_worker_signal_handler *)w->data;
- struct rspamd_worker_signal_cb *cb, *cbtmp;
+ struct rspamd_worker_signal_handler_elt *cb, *cbtmp;
/* Call all signal handlers registered */
DL_FOREACH_SAFE (sigh->cb, cb, cbtmp) {
@@ -272,7 +272,7 @@ static void
rspamd_sigh_free (void *p)
{
struct rspamd_worker_signal_handler *sigh = p;
- struct rspamd_worker_signal_cb *cb, *tmp;
+ struct rspamd_worker_signal_handler_elt *cb, *tmp;
DL_FOREACH_SAFE (sigh->cb, cb, tmp) {
DL_DELETE (sigh->cb, cb);
@@ -287,11 +287,11 @@ rspamd_sigh_free (void *p)
void
rspamd_worker_set_signal_handler (int signo, struct rspamd_worker *worker,
struct ev_loop *event_loop,
- rspamd_worker_signal_handler handler,
+ rspamd_worker_signal_cb_t handler,
void *handler_data)
{
struct rspamd_worker_signal_handler *sigh;
- struct rspamd_worker_signal_cb *cb;
+ struct rspamd_worker_signal_handler_elt *cb;
sigh = g_hash_table_lookup (worker->signal_events, GINT_TO_POINTER (signo));
diff --git a/src/libserver/worker_util.h b/src/libserver/worker_util.h
index 49bbda62b..d3ea738aa 100644
--- a/src/libserver/worker_util.h
+++ b/src/libserver/worker_util.h
@@ -57,7 +57,7 @@ rspamd_prepare_worker (struct rspamd_worker *worker, const char *name,
void rspamd_worker_set_signal_handler (int signo,
struct rspamd_worker *worker,
struct ev_loop *event_loop,
- rspamd_worker_signal_handler handler,
+ rspamd_worker_signal_cb_t handler,
void *handler_data);
/**
diff --git a/src/libutil/util.c b/src/libutil/util.c
index e7a5c2601..6f139d018 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -2507,15 +2507,17 @@ rspamd_time_jitter (gdouble in, gdouble jitter)
}
gboolean
-rspamd_constant_memcmp (const guchar *a, const guchar *b, gsize len)
+rspamd_constant_memcmp (const void *a, const void *b, gsize len)
{
gsize lena, lenb, i;
guint16 d, r = 0, m;
guint16 v;
+ const guint8 *aa = (const guint8 *)a,
+ *bb = (const guint8 *)b;
if (len == 0) {
- lena = strlen (a);
- lenb = strlen (b);
+ lena = strlen ((const char*)a);
+ lenb = strlen ((const char*)b);
if (lena != lenb) {
return FALSE;
@@ -2527,7 +2529,7 @@ rspamd_constant_memcmp (const guchar *a, const guchar *b, gsize len)
for (i = 0; i < len; i++) {
v = ((guint16)(guint8)r) + 255;
m = v / 256 - 1;
- d = (guint16)((int)a[i] - (int)b[i]);
+ d = (guint16)((int)aa[i] - (int)bb[i]);
r |= (d & m);
}
diff --git a/src/libutil/util.h b/src/libutil/util.h
index 21e4b320e..7f13ded06 100644
--- a/src/libutil/util.h
+++ b/src/libutil/util.h
@@ -411,7 +411,7 @@ void rspamd_random_seed_fast (void);
/**
* Constant time version of memcmp
*/
-gboolean rspamd_constant_memcmp (const guchar *a, const guchar *b, gsize len);
+gboolean rspamd_constant_memcmp (const void *a, const void *b, gsize len);
/**
* Open file without following symlinks or special stuff
@@ -472,7 +472,7 @@ void rspamd_gmtime (gint64 ts, struct tm *dest);
*/
void rspamd_localtime (gint64 ts, struct tm *dest);
-#define PTR_ARRAY_FOREACH(ar, i, cur) for ((i) = 0; (ar) != NULL && (i) < (ar)->len && (((cur) = g_ptr_array_index((ar), (i))) || 1); ++(i))
+#define PTR_ARRAY_FOREACH(ar, i, cur) for ((i) = 0; (ar) != NULL && (i) < (ar)->len && (((cur) = (__typeof__(cur))g_ptr_array_index((ar), (i))) || 1); ++(i))
/**
* Compresses the input string using gzip+zlib. Old string is replaced and freed
diff --git a/src/rspamd.h b/src/rspamd.h
index fff373397..a56fab2b4 100644
--- a/src/rspamd.h
+++ b/src/rspamd.h
@@ -114,13 +114,13 @@ struct rspamd_abstract_worker_ctx {
};
struct rspamd_worker_signal_handler;
-typedef gboolean (*rspamd_worker_signal_handler) (
+typedef gboolean (*rspamd_worker_signal_cb_t) (
struct rspamd_worker_signal_handler *, void *ud);
-struct rspamd_worker_signal_cb {
- rspamd_worker_signal_handler handler;
+struct rspamd_worker_signal_handler_elt {
+ rspamd_worker_signal_cb_t handler;
void *handler_data;
- struct rspamd_worker_signal_cb *next, *prev;
+ struct rspamd_worker_signal_handler_elt *next, *prev;
};
struct rspamd_worker_signal_handler {
@@ -129,7 +129,7 @@ struct rspamd_worker_signal_handler {
ev_signal ev_sig;
struct ev_loop *event_loop;
struct rspamd_worker *worker;
- struct rspamd_worker_signal_cb *cb;
+ struct rspamd_worker_signal_handler_elt *cb;
};
struct rspamd_controller_pbkdf {
@@ -222,8 +222,8 @@ typedef struct worker_s {
const gchar *name;
gpointer (*worker_init_func)(struct rspamd_config *cfg);
void (*worker_start_func)(struct rspamd_worker *worker);
- enum rspamd_worker_flags flags;
- enum rspamd_worker_socket_type listen_type;
+ int flags;
+ int listen_type;
guint worker_version;
guint64 rspamd_version;
const gchar *rspamd_features;
More information about the Commits
mailing list