]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Slight types improvement
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 28 Jun 2019 08:40:04 +0000 (09:40 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 28 Jun 2019 08:40:04 +0000 (09:40 +0100)
src/libserver/html.c
src/libserver/html.h
src/libserver/html_entities.h
src/libserver/url.c
src/libserver/url.h
src/libserver/worker_util.c
src/libserver/worker_util.h
src/libutil/util.c
src/libutil/util.h
src/rspamd.h

index ca4ad5d38b35d3f3f74e151fa5c183fb8f920a14..8f6b3d291c718d98021546aa5f8c3b722c60ae2e 100644 (file)
@@ -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 */
index f3515d627b59ac9288cd922601038d99a88a44d9..ada6dca68e68178ed74aec878db692d1bcff0134 100644 (file)
@@ -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 */
index 8b323e9b388d9302de21cec6e532ee843ad981e5..1079f2b0e1a540808e20c0b724a536f6b2e08b0b 100644 (file)
@@ -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[] = {
index 36c9a157ac4fa518b5e0b26d79c7694a773c7ea9..0b31007bbe7076a17c6c2282229078cb4922bbf8 100644 (file)
@@ -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:
index 59dcd16156fb7f8b936d6cfdbbfdcd41439279e2..734f48bbf1cf780b1dc61ebd1caab8c059df2593 100644 (file)
@@ -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);
 
 
 /**
index 3ad528d1ec2e5431341e71f9d5dbc6999d50e257..4aff94a38098f10b59b2d23e059bad0b7fe0d84d 100644 (file)
@@ -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));
 
index 49bbda62b9d11b118a25b3395ed3598e82def2dd..d3ea738aa1ba6f8feafe6f55b522a9cd178c50e7 100644 (file)
@@ -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);
 
 /**
index e7a5c26019dd7233c6bad674fc3a44020c0d376d..6f139d018227e69ab348ad3dbdcc1895d51694d2 100644 (file)
@@ -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);
        }
 
index 21e4b320eafe8399a1a3a582a3cc64196a4a9b0e..7f13ded0635d5b05d49c92a1043398ff2e346d9b 100644 (file)
@@ -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
index fff373397ccb3718a0e46d22374627e9aac9f67e..a56fab2b46f3148a315d10a541d62a4cc60d30fb 100644 (file)
@@ -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;