CHECK_C_COMPILER_FLAG(-Wpointer-arith SUPPORT_WPOINTER)
CHECK_C_COMPILER_FLAG(-Wno-unused-parameter SUPPORT_WPARAM)
CHECK_C_COMPILER_FLAG(-Wno-unused-function SUPPORT_WFUNCTION)
-CHECK_C_COMPILER_FLAG(-Wno-sign-compare SUPPORT_WSIGNCOMPARE)
CHECK_C_COMPILER_FLAG(-Wunused-variable SUPPORT_WUNUSED_VAR)
-CHECK_C_COMPILER_FLAG(-Wno-declaration-after-statement SUPPORT_WDECL)
CHECK_C_COMPILER_FLAG(-Wno-pointer-sign SUPPORT_WPOINTER_SIGN)
CHECK_C_COMPILER_FLAG(-pedantic SUPPORT_PEDANTIC_FLAG)
CHECK_C_COMPILER_FLAG("-std=c99" SUPPORT_STD_FLAG)
IF(SUPPORT_WFUNCTION)
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-unused-function")
ENDIF(SUPPORT_WFUNCTION)
-IF(SUPPORT_WSIGNCOMPARE)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-sign-compare ")
-ENDIF(SUPPORT_WSIGNCOMPARE)
IF(SUPPORT_WUNUSED_VAR)
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wunused-variable")
ENDIF(SUPPORT_WUNUSED_VAR)
-IF(SUPPORT_WDECL)
- SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-declaration-after-statement")
-ENDIF(SUPPORT_WDECL)
IF(SUPPORT_WPOINTER_SIGN)
SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -Wno-pointer-sign")
ENDIF(SUPPORT_WPOINTER_SIGN)
case 1:
/* Read boolean result */
if (*p == ';') {
- if (p - c >= sizeof("Skip")) {
+ if (p - c >= (gint)sizeof("Skip")) {
if (memcmp (c, "Skip", p - c - 1) == 0) {
new->is_skipped = TRUE;
}
/* Try to obtain string from the input buffer */
if (c->in_buf->len > 0) {
len = 0;
- while (len < c->in_buf->len) {
+ while (len < (gint)c->in_buf->len) {
p = c->in_buf->str[len];
if (p == '\r' || p == '\n') {
if (parse_rspamd_reply_line (c, len, err)) {
/* Strip '\r\n' */
- while (len < c->in_buf->len && (p == '\r' || p == '\n')) {
+ while (len < (gint)c->in_buf->len && (p == '\r' || p == '\n')) {
p = c->in_buf->str[++len];
}
/* Move remaining buffer to the begin of string */
}
if ((r = read (c->socket, tmpbuf, sizeof (tmpbuf))) > 0) {
/* Check the end of the buffer for END marker */
- if (r >= sizeof (end_marker) - 1 &&
+ if (r >= (gint)sizeof (end_marker) - 1 &&
memcmp (tmpbuf + r - sizeof (end_marker) + 1, end_marker, sizeof (end_marker) - 1) == 0) {
r -= sizeof (end_marker) - 1;
/* Copy the rest to the result string */
return FALSE;
}
if ((r = read (c->socket, inbuf, sizeof (inbuf))) > 0) {
- if (r >= sizeof (greeting_str) - 1 &&
+ if (r >= (gint)sizeof (greeting_str) - 1 &&
memcmp (inbuf, greeting_str, sizeof (greeting_str) - 1) == 0) {
return TRUE;
}
{
guint64 now = time (NULL);
- if (log->rotate_time && ((now - log->header.create_time) > log->rotate_time + log->rotate_jitter)) {
+ if (log->rotate_time && ((now - log->header.create_time) > (guint)(log->rotate_time + log->rotate_jitter))) {
return TRUE;
}
return FALSE;
{
bloom_filter_t *bloom;
va_list l;
- gint n;
+ gsize n;
if (!(bloom = g_malloc (sizeof (bloom_filter_t)))) {
return NULL;
event_add (d->ev, d->tv);
}
}
- else if (r + d->offset < d->file_size) {
+ else if (r + d->offset < (ssize_t)d->file_size) {
debug_ip("partially write data, retry");
/* Wait for other event */
event_del (d->ev);
* c - pointer to current position (buffer->begin + r)
* res - result string
*/
- while (r < len) {
+ while (r < (ssize_t)len) {
if (*c == '\n') {
res.begin = b;
res.len = c - b;
break;
case BUFFER_CHARACTER:
r = d->nchars;
- if (len >= r) {
+ if ((ssize_t)len >= r) {
res.begin = b;
res.len = r;
c = b + r;
return;
}
/* Move remaining string to begin of buffer (draining) */
- if (len > r) {
+ if ((ssize_t)len > r) {
len -= r;
memmove (d->in_buf->data->begin, c, len);
d->in_buf->data->len = len;
d->in_buf->data->len = 0;
d->in_buf->pos = d->in_buf->data->begin;
}
- if (d->policy != saved_policy && len != r) {
+ if (d->policy != saved_policy && (ssize_t)len != r) {
debug_ip("policy changed during callback, restart buffer's processing");
read_buffers (fd, d, TRUE);
return;
{
gchar **strvec, **p;
struct filter *cur;
- gint i;
+ guint i;
if (str == NULL) {
return;
{
struct xml_parser_rule *rule;
struct xml_config_param *param;
- gint i;
+ guint i;
/* First find required section */
for (i = 0; i < G_N_ELEMENTS (grammar); i ++) {
glob_t globbuf;
gchar *pattern;
size_t len;
- gint i;
+ guint i;
if (stat (data, &st) == -1) {
msg_err ("cannot stat path %s, %s", data, strerror (errno));
token_node_t *node = key;
struct bayes_callback_data *cd = data;
double renorm = 0;
- gint i;
+ guint i;
double local_hits = 0;
struct bayes_statfile_data *cur;
struct bayes_callback_data data;
gchar *value;
gint nodes, i = 0, cnt, best_num = 0;
- gsize minnodes;
+ gint minnodes;
guint64 rev, total_learns = 0;
double best = 0;
struct statfile *st;
struct bayes_callback_data data;
gchar *value;
gint nodes;
- gsize minnodes;
+ gint minnodes;
struct statfile *st, *sel_st = NULL;
stat_file_t *to_learn;
GList *cur;
struct bayes_callback_data data;
gchar *value;
gint nodes;
- gsize minnodes;
+ gint minnodes;
struct statfile *st;
stat_file_t *file;
GList *cur;
struct classifier *
get_classifier (char *name)
{
- int i;
+ guint i;
for (i = 0; i < sizeof (classifiers) / sizeof (classifiers[0]); i++) {
if (strcmp (classifiers[i].name, name) == 0) {
stat_file_t *statfile;
struct statfile *st;
gchar out_buf[BUFSIZ];
- gint i;
+ guint i;
guint64 rev, ti, len, pos, blocks;
gchar *out;
struct rspamd_binlog_element log_elt;
static struct controller_command *
process_normal_command (const gchar *line)
{
- gint i;
+ guint i;
struct controller_command *c;
for (i = 0; i < G_N_ELEMENTS (commands); i ++) {
{
GArray *ses;
struct diff_edit *e;
- gint i;
+ guint i;
guint32 distance = 0;
ses = g_array_sized_new (FALSE, TRUE, sizeof (struct diff_edit), MAX_DIFF);
msg_info ("bad RR name");
return -1;
}
- if (p - *pos >= *remain - sizeof (guint16) * 5 || *remain <= 0) {
+ if ((gint)(p - *pos) >= (gint)(*remain - sizeof (guint16) * 5) || *remain <= 0) {
msg_info ("stripped dns reply");
return -1;
}
p += datalen;
}
else {
- if (p - *pos > *remain - sizeof (guint16) * 3) {
+ if (p - *pos > (gint)(*remain - sizeof (guint16) * 3)) {
msg_info ("stripped dns reply while reading SRV record");
return -1;
}
if ((pos = dns_request_reply_cmp (req, in + sizeof (struct dns_header), r - sizeof (struct dns_header))) == NULL) {
return FALSE;
}
- /*
- * Remove delayed retransmits for this packet
- */
- event_del (&req->timer_event);
/*
* Now pos is in answer section, so we should extract data and form reply
*/
/* First read packet from socket */
r = read (fd, in, sizeof (in));
- if (r > sizeof (struct dns_header) + sizeof (struct dns_query)) {
+ if (r > (gint)(sizeof (struct dns_header) + sizeof (struct dns_query))) {
if (dns_parse_reply (in, r, resolver, &req, &rep)) {
/* Decrease errors count */
if (rep->request->resolver->errors > 0) {
}
static inline gboolean
-compare_len (struct mime_part *part, gint min, gint max)
+compare_len (struct mime_part *part, guint min, guint max)
{
if (min == 0 && max == 0) {
return TRUE;
ssize_t
fstrchr (f_str_t * src, gchar c)
{
- register ssize_t cur = 0;
+ register size_t cur = 0;
while (cur < src->len) {
if (*(src->begin + cur) == c) {
ssize_t
fstrstr (f_str_t * orig, f_str_t * pattern)
{
- register ssize_t cur = 0, pcur = 0;
+ register size_t cur = 0, pcur = 0;
if (pattern->len > orig->len) {
return -1;
ssize_t
fstrstri (f_str_t * orig, f_str_t * pattern)
{
- register ssize_t cur = 0, pcur = 0;
+ register size_t cur = 0, pcur = 0;
if (pattern->len > orig->len) {
return -1;
fstrstrip (f_str_t * str)
{
gchar *p = str->begin;
- gint r = 0;
+ guint r = 0;
while (r < str->len) {
if (g_ascii_isspace (*p)) {
fuzzy_init (f_str_t * in, memory_pool_t * pool)
{
fuzzy_hash_t *new;
- gint i, repeats = 0;
+ guint i, repeats = 0;
gchar *c = in->begin, last = '\0';
gsize real_len = 0;
if (part->is_utf) {
while (c < end) {
- if (cur_ex != NULL && cur_ex->pos == c - begin) {
+ if (cur_ex != NULL && (gint)cur_ex->pos == c - begin) {
c += cur_ex->len + 1;
cur_offset = g_list_next (cur_offset);
if (cur_offset != NULL) {
}
else {
while (c < end) {
- if (cur_ex != NULL && cur_ex->pos == c - begin) {
+ if (cur_ex != NULL && (gint)cur_ex->pos == c - begin) {
c += cur_ex->len + 1;
cur_offset = g_list_next (cur_offset);
if (cur_offset != NULL) {
if (part->is_utf) {
while (c < end) {
- if (cur_ex != NULL && cur_ex->pos == c - begin) {
+ if (cur_ex != NULL && (gint)cur_ex->pos == c - begin) {
c += cur_ex->len + 1;
cur_offset = g_list_next (cur_offset);
if (cur_offset != NULL) {
}
else {
while (c < end) {
- if (cur_ex != NULL && cur_ex->pos == c - begin) {
+ if (cur_ex != NULL && (gint)cur_ex->pos == c - begin) {
c += cur_ex->len + 1;
cur_offset = g_list_next (cur_offset);
if (cur_offset != NULL) {
}
else {
#endif
- if (node->value > ctx->frequent_score) {
+ if (node->value > (gint)ctx->frequent_score) {
g_queue_push_head (frequent, node);
}
else {
h->value += update_value;
msg_info ("new hash weight: %d", h->value);
}
- if (h->value > ctx->frequent_score) {
+ if (h->value > (gint)ctx->frequent_score) {
g_queue_unlink (hash, cur);
g_queue_push_head_link (frequent, cur);
msg_info ("moved hash to frequent list");
rspamd_lru_element_t *res;
gint removed = 0;
- if (g_hash_table_size (hash->storage) >= hash->maxsize) {
+ if ((gint)g_hash_table_size (hash->storage) >= hash->maxsize) {
/* Expire some elements */
res = g_queue_pop_tail (hash->q);
while (res != NULL && now - res->store_time > hash->maxage) {
break;
}
}
- rspamd_strlcpy (tagbuf, c, MIN (sizeof(tagbuf), p - c + 1));
+ rspamd_strlcpy (tagbuf, c, MIN ((gint)sizeof(tagbuf), p - c + 1));
if ((tag = get_tag_by_name (tagbuf)) != NULL) {
if (tag->id == id) {
break;
}
len = 0;
p = c;
- while (*p && p - tag_text < tag_len) {
+ while (*p && (guint)(p - tag_text) < tag_len) {
if (got_double_quote) {
if (*p == '"') {
break;
{
gchar *c, *rcpt;
f_str_t fstr;
- guint i = 0, l = 0, size;
+ gint i = 0, l = 0, size;
switch (lmtp->state) {
case LMTP_READ_LHLO:
i += lhlo_command.len;
c = line->begin + i;
/* Skip spaces */
- while (g_ascii_isspace (*c) && i < line->len) {
+ while (g_ascii_isspace (*c) && i < (gint)line->len) {
i++;
c++;
}
else {
l = lmtp->task->msg->len;
size = lmtp->task->msg->size;
- if (l + line->len > size) {
+ if ((gint)(l + line->len) > size) {
/* Grow buffer */
- if (line->len > size) {
+ if ((gint)line->len > size) {
size += line->len << 1;
}
else {
gint
lua_call_chain_filter (const gchar *function, struct worker_task *task, gint *marks, guint number)
{
- gint result, i;
+ gint result;
+ guint i;
lua_State *L = task->cfg->lua_state;
lua_getglobal (L, function);
};
const gchar *sel;
- if (part != NULL && part->script > 0 && part->script < G_N_ELEMENTS (languages)) {
+ if (part != NULL && part->script > 0 && part->script < (gint)G_N_ELEMENTS (languages)) {
sel = languages[part->script];
if (*sel != '\0') {
lua_pushstring (L, sel);
if (family == AF_INET) {
/* Make fnv hash from bytes of addr and port */
key = (gchar *)&addr->s_addr;
- while (key - (gchar *)&addr->s_addr < sizeof (addr->s_addr)) {
+ while (key - (gchar *)&addr->s_addr < (gint)sizeof (addr->s_addr)) {
res ^= (gchar)*key++;
res += (res << 1) + (res << 4) + (res << 7) + (res << 8) + (res << 24);
}
key = (gchar *)&port;
- while (key - (gchar *)&port < sizeof (addr->s_addr)) {
+ while (key - (gchar *)&port < (gint)sizeof (addr->s_addr)) {
res ^= (gchar)*key++;
res += (res << 1) + (res << 4) + (res << 7) + (res << 8) + (res << 24);
}
* FSM for parsing HTTP reply
*/
static gchar *
-parse_http_reply (gchar * chunk, size_t len, struct http_reply *reply)
+parse_http_reply (gchar * chunk, gint len, struct http_reply *reply)
{
gchar *s, *p, *err_str, *tmp;
p = chunk;
* Read and parse chunked header
*/
static gint
-read_chunk_header (gchar * buf, size_t len, struct http_map_data *data)
+read_chunk_header (gchar * buf, gint len, struct http_map_data *data)
{
gchar chunkbuf[32], *p, *c, *err_str;
gint skip = 0;
p = chunkbuf;
c = buf;
/* Find hex digits */
- while (g_ascii_isxdigit (*c) && p - chunkbuf < sizeof (chunkbuf) - 1 && skip < len) {
+ while (g_ascii_isxdigit (*c) && p - chunkbuf < (gint)(sizeof (chunkbuf) - 1) && skip < len) {
*p++ = *c++;
skip++;
}
hostend = p;
i = 0;
p++;
- while (g_ascii_isdigit (*p) && i < sizeof (portbuf) - 1) {
+ while (g_ascii_isdigit (*p) && i < (gint)sizeof (portbuf) - 1) {
portbuf[i++] = *p++;
}
if (*p != '/') {
* FSM for parsing lists
*/
gchar *
-abstract_parse_kv_list (memory_pool_t * pool, gchar * chunk, size_t len, struct map_cb_data *data, insert_func func)
+abstract_parse_kv_list (memory_pool_t * pool, gchar * chunk, gint len, struct map_cb_data *data, insert_func func)
{
gchar *c, *p, *key = NULL, *value = NULL;
}
gchar *
-abstract_parse_list (memory_pool_t * pool, gchar * chunk, size_t len, struct map_cb_data *data, insert_func func)
+abstract_parse_list (memory_pool_t * pool, gchar * chunk, gint len, struct map_cb_data *data, insert_func func)
{
gchar *s, *p, *str, *start;
/* Helpers */
gchar *
-read_host_list (memory_pool_t * pool, gchar * chunk, size_t len, struct map_cb_data *data)
+read_host_list (memory_pool_t * pool, gchar * chunk, gint len, struct map_cb_data *data)
{
if (data->cur_data == NULL) {
data->cur_data = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);
}
gchar *
-read_kv_list (memory_pool_t * pool, gchar * chunk, size_t len, struct map_cb_data *data)
+read_kv_list (memory_pool_t * pool, gchar * chunk, gint len, struct map_cb_data *data)
{
if (data->cur_data == NULL) {
data->cur_data = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);
}
gchar *
-read_radix_list (memory_pool_t * pool, gchar * chunk, size_t len, struct map_cb_data *data)
+read_radix_list (memory_pool_t * pool, gchar * chunk, gint len, struct map_cb_data *data)
{
if (data->cur_data == NULL) {
data->cur_data = radix_tree_create ();
/**
* Callback types
*/
-typedef gchar* (*map_cb_t)(memory_pool_t *pool, gchar *chunk, size_t len, struct map_cb_data *data);
+typedef gchar* (*map_cb_t)(memory_pool_t *pool, gchar *chunk, gint len, struct map_cb_data *data);
typedef void (*map_fin_cb_t)(memory_pool_t *pool, struct map_cb_data *data);
/**
/**
* Radix list is a list like ip/mask
*/
-gchar* read_radix_list (memory_pool_t *pool, gchar *chunk, size_t len, struct map_cb_data *data);
+gchar* read_radix_list (memory_pool_t *pool, gchar *chunk, gint len, struct map_cb_data *data);
void fin_radix_list (memory_pool_t *pool, struct map_cb_data *data);
/**
* Host list is an ordinal list of hosts or domains
*/
-gchar* read_host_list (memory_pool_t *pool, gchar *chunk, size_t len, struct map_cb_data *data);
+gchar* read_host_list (memory_pool_t *pool, gchar *chunk, gint len, struct map_cb_data *data);
void fin_host_list (memory_pool_t *pool, struct map_cb_data *data);
/**
* Kv list is an ordinal list of keys and values separated by whitespace
*/
-gchar* read_kv_list (memory_pool_t *pool, gchar *chunk, size_t len, struct map_cb_data *data);
+gchar* read_kv_list (memory_pool_t *pool, gchar *chunk, gint len, struct map_cb_data *data);
void fin_kv_list (memory_pool_t *pool, struct map_cb_data *data);
/**
* FSM for lists parsing (support comments, blank lines and partial replies)
*/
-gchar * abstract_parse_list (memory_pool_t * pool, gchar * chunk, size_t len, struct map_cb_data *data, insert_func func);
+gchar * abstract_parse_list (memory_pool_t * pool, gchar * chunk, gint len, struct map_cb_data *data, insert_func func);
#endif
* Function that return free space in pool page
* @param x pool page struct
*/
-static gsize
+static gint
pool_chain_free (struct _pool_chain *chain)
{
- guint8 *p;
-
- p = align_ptr (chain->pos, MEM_ALIGNMENT);
- return chain->len - (p - chain->begin);
+ return (gint)chain->len - (chain->pos - chain->begin + MEM_ALIGNMENT);
}
static struct _pool_chain *
abort ();
}
- chain->len = size;
chain->pos = align_ptr (chain->begin, MEM_ALIGNMENT);
+ chain->len = size;
chain->next = NULL;
STAT_LOCK ();
mem_pool_stat->bytes_allocated += size;
#else
# error No mmap methods are defined
#endif
- chain->len = size;
- chain->pos = chain->begin;
chain->pos = align_ptr (chain->begin, MEM_ALIGNMENT);
+ chain->len = size;
chain->lock = NULL;
chain->next = NULL;
STAT_LOCK ();
{
guint8 *tmp;
struct _pool_chain *new, *cur;
- gsize free;
+ gint free;
if (pool) {
#ifdef MEMORY_GREEDY
cur = pool->cur_pool;
#endif
/* Find free space in pool chain */
- while ((free = pool_chain_free (cur)) < size && cur->next) {
+ while ((free = pool_chain_free (cur)) < (gint)size && cur->next) {
cur = cur->next;
}
- if (free < size && cur->next == NULL) {
+ if (free < (gint)size && cur->next == NULL) {
/* Allocate new pool */
- if (cur->len >= size) {
+ if (cur->len >= size + MEM_ALIGNMENT) {
new = pool_chain_new (cur->len);
}
else {
mem_pool_stat->oversized_chunks++;
- new = pool_chain_new (size + pool->first_pool->len);
+ new = pool_chain_new (size + pool->first_pool->len + MEM_ALIGNMENT);
}
/* Attach new pool to chain */
cur->next = new;
pool->cur_pool = new;
- new->pos += size;
-
- return new->begin;
+ /* No need to align again */
+ tmp = new->pos;
+ new->pos = tmp + size;
+ return tmp;
}
tmp = align_ptr (cur->pos, MEM_ALIGNMENT);
cur->pos = tmp + size;
+ g_assert (cur->pos - cur->begin <= (gint)cur->len);
return tmp;
}
return NULL;
{
guint8 *tmp;
struct _pool_chain_shared *new, *cur;
+ gint free;
if (pool) {
g_return_val_if_fail (size > 0, NULL);
}
/* Find free space in pool chain */
- while (pool_chain_free ((struct _pool_chain *)cur) < size && cur->next) {
+ while ((free = pool_chain_free ((struct _pool_chain *)cur)) < (gint)size && cur->next) {
cur = cur->next;
}
- if (cur->next == NULL) {
+ if (free < (gint)size && cur->next == NULL) {
/* Allocate new pool */
- if (cur->len >= size) {
+ if (cur->len >= size + MEM_ALIGNMENT) {
new = pool_chain_new_shared (cur->len);
}
else {
mem_pool_stat->oversized_chunks++;
- new = pool_chain_new_shared (size + cur->len);
+ new = pool_chain_new_shared (size + pool->first_pool->len + MEM_ALIGNMENT);
}
/* Attach new pool to chain */
cur->next = new;
return;
}
/* Check if we already have all data in buffer */
- if (r >= datalen + sizeof (END_TRAILER) + sizeof (CRLF) - 2) {
+ if (r >= (ssize_t)(datalen + sizeof (END_TRAILER) + sizeof (CRLF) - 2)) {
/* Store all data in param's buffer */
memcpy (ctx->param->buf + ctx->param->bufpos, p, datalen);
/* Increment count */
iov[1].iov_base = read_buf;
iov[1].iov_len = r;
ctx->param->bufpos = writev (ctx->sock, iov, 2);
- if (ctx->param->bufpos == -1) {
+ if (ctx->param->bufpos == (size_t)-1) {
memc_log (ctx, __LINE__, "memc_write: writev failed: %s", strerror (errno));
}
}
end = src->data + src->len;
br = 0;
- while (i < src->len) {
+ while (i < (gint)src->len) {
switch (c) {
case '\0':
break;
break;
}
i++;
- if (i < src->len) {
+ if (i < (gint)src->len) {
c = *(++p);
}
}
}
scc = g_unichar_get_script (c);
- if (scc < G_N_ELEMENTS (scripts)) {
+ if (scc < (gint)G_N_ELEMENTS (scripts)) {
scripts[scc] ++;
}
p1 = g_utf8_next_char (p);
gint servers_num;
memory_pool_t *fuzzy_pool;
double max_score;
- gint32 min_hash_len;
+ guint32 min_hash_len;
radix_tree_t *whitelist;
GHashTable *mappings;
GList *mime_types;
- gint32 min_bytes;
- gint32 min_height;
- gint32 min_width;
+ guint32 min_bytes;
+ guint32 min_height;
+ guint32 min_width;
guint32 io_timeout;
};
if ((p = strchr (strvec[i], ':')) != NULL) {
j = 0;
p++;
- while (g_ascii_isdigit (*(p + j)) && j < sizeof (portbuf) - 1) {
+ while (g_ascii_isdigit (*(p + j)) && j < (gint)sizeof (portbuf) - 1) {
portbuf[j] = *(p + j);
j++;
}
break;
case 1:
/* Begin parse ip */
- if (p - ip_buf >= sizeof (ip_buf) || dots > 3) {
+ if (p - ip_buf >= (gint)sizeof (ip_buf) || dots > 3) {
return FALSE;
}
if (g_ascii_isdigit (*pos)) {
/* Callbacks for reading json dynamic rules */
gchar *
-json_regexp_read_cb (memory_pool_t * pool, gchar * chunk, size_t len, struct map_cb_data *data)
+json_regexp_read_cb (memory_pool_t * pool, gchar * chunk, gint len, struct map_cb_data *data)
{
struct regexp_json_buf *jb;
- size_t free, off;
+ gint free, off;
if (data->cur_data == NULL) {
jb = g_malloc (sizeof (struct regexp_json_buf));
json_regexp_fin_cb (memory_pool_t * pool, struct map_cb_data *data)
{
struct regexp_json_buf *jb;
- gint nelts, i, j;
+ guint nelts, i, j;
json_t *js, *cur_elt, *cur_nm, *it_val;
json_error_t je;
gchar *cur_rule, *cur_symbol;
}
static gchar *
-read_exceptions_list (memory_pool_t * pool, gchar * chunk, size_t len, struct map_cb_data *data)
+read_exceptions_list (memory_pool_t * pool, gchar * chunk, gint len, struct map_cb_data *data)
{
if (data->cur_data == NULL) {
data->cur_data = memory_pool_alloc0 (pool, sizeof (GHashTable *) * MAX_LEVELS);
}
static gchar *
-read_redirectors_list (memory_pool_t * pool, gchar * chunk, size_t len, struct map_cb_data *data)
+read_redirectors_list (memory_pool_t * pool, gchar * chunk, gint len, struct map_cb_data *data)
{
if (data->cur_data == NULL) {
data->cur_data = g_hash_table_new_full (rspamd_strcase_hash, rspamd_strcase_equal, g_free, redirector_item_free);
len = hostname->len + slen + 2;
p = hostname->begin;
- while (p - hostname->begin < hostname->len && dots_num < MAX_LEVELS) {
+ while (p - hostname->begin < (gint)hostname->len && dots_num < MAX_LEVELS) {
if (*p == '.') {
dots[dots_num] = p;
dots_num ++;
else {
url_count = (gint *)param->ctx->param->buf;
/* Do not check DNS for urls that have count more than max_urls */
- if (*url_count > surbl_module_ctx->max_urls) {
+ if (*url_count > (gint)surbl_module_ctx->max_urls) {
msg_info ("url '%s' has count %d, max: %d", struri (param->url), *url_count, surbl_module_ctx->max_urls);
/*
* XXX: try to understand why we should use memcached here
static gchar *
separate_command (f_str_t * in, gchar c)
{
- gint r = 0;
+ guint r = 0;
gchar *p = in->begin, *b;
b = p;
gchar *
-json_read_cb (memory_pool_t * pool, gchar * chunk, size_t len, struct map_cb_data *data)
+json_read_cb (memory_pool_t * pool, gchar * chunk, gint len, struct map_cb_data *data)
{
struct json_buf *jb;
size_t free, off;
off = jb->pos - jb->buf;
free = jb->buflen - off;
- if (free < len) {
+ if ((gint)free < len) {
jb->buflen = MAX (jb->buflen * 2, jb->buflen + len * 2);
jb->buf = g_realloc (jb->buf, jb->buflen);
jb->pos = jb->buf + off;
field ++;
}
len = strcspn (field, ">");
- rspamd_strlcpy (cmp_buf, field, MIN (sizeof (cmp_buf), len + 1));
+ rspamd_strlcpy (cmp_buf, field, MIN ((gint)sizeof (cmp_buf), len + 1));
*user_settings = g_hash_table_lookup (task->cfg->user_settings, cmp_buf);
}
if (domain != NULL) {
len = strcspn (domain, ">");
- rspamd_strlcpy (cmp_buf, domain, MIN (sizeof (cmp_buf), len + 1));
+ rspamd_strlcpy (cmp_buf, domain, MIN ((gint)sizeof (cmp_buf), len + 1));
*domain_settings = g_hash_table_lookup (task->cfg->domain_settings, cmp_buf);
}
}
/* Now mmap temp file if it is small enough */
session->temp_size = st.st_size;
- if (session->ctx->max_size == 0 || st.st_size < session->ctx->max_size) {
+ if (session->ctx->max_size == 0 || st.st_size < (off_t)session->ctx->max_size) {
session->task = construct_task (session->worker);
session->task->resolver = session->resolver;
session->task->fin_callback = smtp_write_socket;
return process_smtp_data (session);
}
- if (write (session->temp_fd, in->begin, in->len) != in->len) {
+ if (write (session->temp_fd, in->begin, in->len) != (ssize_t)in->len) {
msg_err ("cannot write to temp file: %s", strerror (errno));
session->error = SMTP_ERROR_FILE;
session->state = SMTP_STATE_CRITICAL_ERROR;
SMTP_PARSE_DONE
} state;
gchar *p, *c, ch, cmd_buf[4];
- gint i;
+ guint i;
f_str_t *arg = NULL;
struct smtp_command *pcmd;
static gboolean
check_smtp_path (f_str_t *path)
{
- gint i;
+ guint i;
gchar *p;
p = path->begin;
break;
case 1:
/* Begin parse ip */
- if (p - ip_buf >= sizeof (ip_buf) || dots > 3) {
+ if (p - ip_buf >= (gint)sizeof (ip_buf) || dots > 3) {
return FALSE;
}
if (g_ascii_isdigit (*pos)) {
gchar ipbuf[sizeof("255.255.255.255") - 1], *p, *c;
gint t = 0, l = len;
- if (len > sizeof (ipbuf)) {
+ if (len > (gint)sizeof (ipbuf)) {
msg_info ("cannot reverse string of length %d", len);
return;
}
}
pos = map + (sizeof (struct stat_file) - sizeof (struct stat_file_block));
- while (pos - map < old_size) {
+ while (pos - map < (gint)old_size) {
block = (struct stat_file_block *)pos;
if (block->hash1 != 0 && block->value != 0) {
statfile_pool_set_block_common (pool, new, block->hash1, block->hash2, 0, block->value, FALSE);
return NULL;
}
- if (!forced && st.st_size > pool->max) {
+ if (!forced && (gsize)st.st_size > pool->max) {
msg_info ("cannot attach file to pool, too large: %Hz", (size_t) st.st_size);
return NULL;
}
memory_pool_lock_mutex (pool->lock);
- if (!forced && abs (st.st_size - size) > sizeof (struct stat_file)) {
+ if (!forced && abs (st.st_size - size) > (gint)sizeof (struct stat_file)) {
memory_pool_unlock_mutex (pool->lock);
msg_warn ("need to reindex statfile old size: %Hz, new size: %Hz", st.st_size, size);
return statfile_pool_reindex (pool, filename, st.st_size, size);
else {
cur_offset = file->seek_pos - sizeof (struct stat_file_section);
}
- while (cur_offset < file->len) {
+ while (cur_offset < (off_t)file->len) {
sec = (struct stat_file_section *)((gchar *)file->map + cur_offset);
if (sec->code == code) {
file->cur_section.code = code;
static gboolean
parse_revision_line (struct rspamd_sync_ctx *ctx, f_str_t *in)
{
- gint i, state = 0;
+ guint i, state = 0;
gchar *p, *c, numbuf[sizeof("18446744073709551615")];
guint64 *val;
/* One more character */
p ++;
}
- rspamd_strlcpy (numbuf, c, MIN (p - c + 1, sizeof (numbuf)));
+ rspamd_strlcpy (numbuf, c, MIN (p - c + 1, (gint)sizeof (numbuf)));
errno = 0;
*val = strtoull (numbuf, NULL, 10);
if (errno != 0) {
read_blocks (struct rspamd_sync_ctx *ctx, f_str_t *in)
{
struct rspamd_binlog_element *elt;
- gint i;
+ guint i;
statfile_pool_lock_file (ctx->pool, ctx->real_statfile);
elt = (struct rspamd_binlog_element *)in->begin;
double *w;
guint32 mask = 0xFFFFFFFF;
struct dynamic_map_item *it;
+ gint rr;
if (*cache == NULL) {
pcache = g_new0 (struct symbols_cache, 1);
t = g_list_prepend (t, item);
/* Replace pointers in radix tree and in destructor function */
memory_pool_replace_destructor (dynamic_pool, (pool_destruct_func)g_list_free, (gpointer)r, t);
- r = radix32tree_replace (pcache->negative_dynamic_map, ntohl (it->addr.s_addr), mask, (uintptr_t)t);
- if (r == -1) {
+ rr = radix32tree_replace (pcache->negative_dynamic_map, ntohl (it->addr.s_addr), mask, (uintptr_t)t);
+ if (rr == -1) {
msg_warn ("cannot replace ip to tree: %s, mask %X", inet_ntoa (it->addr), mask);
}
}
else {
t = g_list_prepend (NULL, item);
memory_pool_add_destructor (dynamic_pool, (pool_destruct_func)g_list_free, t);
- r = radix32tree_insert (pcache->negative_dynamic_map, ntohl (it->addr.s_addr), mask, (uintptr_t)t);
- if (r == -1) {
+ rr = radix32tree_insert (pcache->negative_dynamic_map, ntohl (it->addr.s_addr), mask, (uintptr_t)t);
+ if (rr == -1) {
msg_warn ("cannot insert ip to tree: %s, mask %X", inet_ntoa (it->addr), mask);
}
- else if (r == 1) {
+ else if (rr == 1) {
msg_warn ("ip %s, mask %X, value already exists", inet_ntoa (it->addr), mask);
}
}
t = g_list_prepend (t, item);
/* Replace pointers in radix tree and in destructor function */
memory_pool_replace_destructor (dynamic_pool, (pool_destruct_func)g_list_free, (gpointer)r, t);
- r = radix32tree_replace (pcache->dynamic_map, ntohl (it->addr.s_addr), mask, (uintptr_t)t);
- if (r == -1) {
+ rr = radix32tree_replace (pcache->dynamic_map, ntohl (it->addr.s_addr), mask, (uintptr_t)t);
+ if (rr == -1) {
msg_warn ("cannot replace ip to tree: %s, mask %X", inet_ntoa (it->addr), mask);
}
}
else {
t = g_list_prepend (NULL, item);
memory_pool_add_destructor (dynamic_pool, (pool_destruct_func)g_list_free, t);
- r = radix32tree_insert (pcache->dynamic_map, ntohl (it->addr.s_addr), mask, (uintptr_t)t);
- if (r == -1) {
+ rr = radix32tree_insert (pcache->dynamic_map, ntohl (it->addr.s_addr), mask, (uintptr_t)t);
+ if (rr == -1) {
msg_warn ("cannot insert ip to tree: %s, mask %X", inet_ntoa (it->addr), mask);
}
- else if (r == 1) {
+ else if (rr == 1) {
msg_warn ("ip %s, mask %X, value already exists", inet_ntoa (it->addr), mask);
}
}
struct tokenizer *
get_tokenizer (char *name)
{
- int i;
+ guint i;
for (i = 0; i < sizeof (tokenizers) / sizeof (tokenizers[0]); i++) {
if (strcmp (tokenizers[i].name, name) == 0) {
* Insert a single character as level of binary trie
*/
static struct rspamd_trie_state *
-rspamd_trie_insert_char (rspamd_trie_t *trie, gint depth, struct rspamd_trie_state *q, gchar c)
+rspamd_trie_insert_char (rspamd_trie_t *trie, guint depth, struct rspamd_trie_state *q, gchar c)
{
struct rspamd_trie_match *m;
const guchar *p = pattern;
struct rspamd_trie_state *q, *q1, *r;
struct rspamd_trie_match *m, *n;
- gint i, depth = 0;
+ guint i, depth = 0;
gchar c;
/* Insert pattern to the trie */
void
revive_all_upstreams (void *ups, size_t members, size_t msize)
{
- gint i;
- struct upstream *cur;
- u_char *p;
+ guint i;
+ struct upstream *cur;
+ guchar *p;
U_WLOCK ();
p = ups;
static gint
rescan_upstreams (void *ups, size_t members, size_t msize, time_t now, time_t error_timeout, time_t revive_timeout, size_t max_errors)
{
- gint i, alive;
+ guint i, alive;
struct upstream *cur;
- u_char *p;
+ guchar *p;
/* Recheck all upstreams */
p = ups;
static struct upstream *
get_upstream_by_number (void *ups, size_t members, size_t msize, gint selected)
{
- gint i;
+ guint i;
u_char *p, *c;
struct upstream *cur;
continue;
}
/* Return selected upstream */
- if (i == selected) {
+ if ((gint)i == selected) {
U_UNLOCK ();
return cur;
}
struct upstream *
get_upstream_round_robin (void *ups, size_t members, size_t msize, time_t now, time_t error_timeout, time_t revive_timeout, size_t max_errors)
{
- gint alive, max_weight, i;
+ guint alive, max_weight, i;
struct upstream *cur, *selected = NULL;
u_char *p;
for (i = 0; i < members; i++) {
cur = (struct upstream *)p;
if (!cur->dead) {
- if (max_weight < cur->weight) {
+ if (max_weight < (guint)cur->weight) {
max_weight = cur->weight;
selected = cur;
}
struct upstream *
get_upstream_master_slave (void *ups, size_t members, size_t msize, time_t now, time_t error_timeout, time_t revive_timeout, size_t max_errors)
{
- gint alive, max_weight, i;
+ guint alive, max_weight, i;
struct upstream *cur, *selected = NULL;
u_char *p;
{
guint32 h = 0;
gchar tmp[4];
- gint i;
+ guint i;
/* Allocate ketama points array */
if (up->ketama_points == NULL) {
struct upstream *
get_upstream_by_hash_ketama (void *ups, size_t members, size_t msize, time_t now, time_t error_timeout, time_t revive_timeout, size_t max_errors, gchar *key, size_t keylen)
{
- gint alive, i;
+ guint alive, i;
guint32 h = 0, step, middle, d, min_diff = UINT_MAX;
gchar *p;
struct upstream *cur = NULL, *nearest = NULL;
middle = step;
while (step != 1) {
d = cur->ketama_points[middle] - h;
- if (abs (d) < min_diff) {
+ if (abs (d) < (gint)min_diff) {
min_diff = abs (d);
nearest = cur;
}
static gint
url_init (void)
{
- gint i;
+ guint i;
if (url_scanner == NULL) {
url_scanner = g_malloc (sizeof (struct url_match_scanner));
url_scanner->matchers = matchers;
{
const gchar *p;
gchar stop;
- gint i;
+ guint i;
p = pos + strlen (match->pattern);
if (*p == '/') {
{
const gchar *p, *c;
gchar open_brace = '\0', close_brace = '\0';
- gint i, brace_stack = 0;
+ gint brace_stack = 0;
gboolean passwd = FALSE;
- guint port;
+ guint port, i;
p = pos + strlen (match->pattern);
for (i = 0; i < G_N_ELEMENTS (url_braces) / 2; i += 2) {
guint h = 0;
p = f->begin;
- while (p - f->begin < f->len) {
+ while (p - f->begin < (gint)f->len) {
h = (h << 5) - h + g_tolower (*p);
p++;
}
gchar *res, *orig, *p;
orig = in->begin;
- while ((g_ascii_isspace (*orig) || *orig == '<') && orig - in->begin < in->len) {
+ while ((g_ascii_isspace (*orig) || *orig == '<') && orig - in->begin < (gint)in->len) {
orig ++;
}
p = orig;
- while ((!g_ascii_isspace (*p) && *p != '>') && p - in->begin < in->len) {
+ while ((!g_ascii_isspace (*p) && *p != '>') && p - in->begin < (gint)in->len) {
p ++;
len ++;
}
cur = task->rcpt;
while (cur) {
if ((p = strchr (cur->data, '@')) != NULL) {
- l = MIN (sizeof (rcpt_user) - 1, p - (gchar *)cur->data);
+ l = MIN ((gint)sizeof (rcpt_user) - 1, p - (gchar *)cur->data);
memcpy (rcpt_user, cur->data, l);
rcpt_user[l] = '\0';
/* First try to lookup in hashtable */
return FALSE;
}
- for (i = 0; i < gp.gl_pathc; i++) {
+ for (i = 0; i < (gint)gp.gl_pathc; i++) {
if (!load_custom_filter (worker->srv->cfg, gp.gl_pathv[i], ctx)) {
globfree (&gp);
return FALSE;